PatchworkOS  d0b3021
A non-POSIX operating system.
Loading...
Searching...
No Matches
Shared Memory

Shared Memory. More...

Collaboration diagram for Shared Memory:

Detailed Description

Shared Memory.

Shared memory is exposed in the /dev/shmem directory. Shared memory allows multiple processes to share a section of memory for inter-process communication (IPC).

Creating Shared Memory

Shared memory objects are created using the /dev/shmem/new file. Opening this file using open() will create a new anonymous shared memory object and return a file descriptor to it.

Using Shared Memory

Shared memory objects can be mapped to the current process's address space using the mmap() system call. The first call to mmap() will decide the size of the shared memory object. Subsequent calls to mmap() will map the existing shared memory object.

Data Structures

struct  shmem_object_t
 Represents a shared memory object. More...
 

Functions

static void shmem_object_free (shmem_object_t *shmem)
 
static shmem_object_tshmem_object_new (void)
 
static void shmem_vmm_callback (void *private)
 
static voidshmem_object_allocate_pages (shmem_object_t *shmem, uint64_t pageAmount, space_t *space, void *address, pml_flags_t flags)
 
static uint64_t shmem_open (file_t *file)
 
static void shmem_close (file_t *file)
 
static voidshmem_mmap (file_t *file, void *address, size_t length, size_t *offset, pml_flags_t flags)
 
static uint64_t shmem_init (void)
 
static void shmem_deinit (void)
 

Variables

static dentry_tshmemDir = NULL
 
static dentry_tnewFile = NULL
 
static file_ops_t fileOps
 

Function Documentation

◆ shmem_object_free()

static void shmem_object_free ( shmem_object_t shmem)
static

Definition at line 54 of file shmem.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ shmem_object_new()

static shmem_object_t * shmem_object_new ( void  )
static

Definition at line 74 of file shmem.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ shmem_vmm_callback()

static void shmem_vmm_callback ( void private)
static

Definition at line 89 of file shmem.c.

Here is the caller graph for this function:

◆ shmem_object_allocate_pages()

static void * shmem_object_allocate_pages ( shmem_object_t shmem,
uint64_t  pageAmount,
space_t space,
void address,
pml_flags_t  flags 
)
static

Definition at line 100 of file shmem.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ shmem_open()

static uint64_t shmem_open ( file_t file)
static

Definition at line 145 of file shmem.c.

Here is the call graph for this function:

◆ shmem_close()

static void shmem_close ( file_t file)
static

Definition at line 157 of file shmem.c.

◆ shmem_mmap()

static void * shmem_mmap ( file_t file,
void address,
size_t  length,
size_t offset,
pml_flags_t  flags 
)
static

Definition at line 168 of file shmem.c.

Here is the call graph for this function:

◆ shmem_init()

static uint64_t shmem_init ( void  )
static

Definition at line 229 of file shmem.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ shmem_deinit()

static void shmem_deinit ( void  )
static

Definition at line 249 of file shmem.c.

Here is the caller graph for this function:

Variable Documentation

◆ shmemDir

dentry_t* shmemDir = NULL
static

Definition at line 51 of file shmem.c.

◆ newFile

dentry_t* newFile = NULL
static

Definition at line 52 of file shmem.c.

◆ fileOps

file_ops_t fileOps
static
Initial value:
= {
.open = shmem_open,
.close = shmem_close,
.mmap = shmem_mmap,
}
static void * shmem_mmap(file_t *file, void *address, size_t length, size_t *offset, pml_flags_t flags)
Definition shmem.c:168
static void shmem_close(file_t *file)
Definition shmem.c:157
static uint64_t shmem_open(file_t *file)
Definition shmem.c:145

Definition at line 223 of file shmem.c.