XenevaOS
Loading...
Searching...
No Matches
Functions | Variables
shm.cpp File Reference
#include <Mm/shm.h>
#include <Mm/kmalloc.h>
#include <Mm/pmmngr.h>
#include <Mm/vmmngr.h>
#include <Hal/x86_64_hal.h>
#include <Hal/serial.h>
#include <Sync/spinlock.h>
#include <list.h>
#include <aucon.h>
#include <_null.h>
#include <string.h>
Include dependency graph for shm.cpp:

Functions

void AuInitialiseSHMMan ()
 AuInitialiseSHMMan – initialise shm manager.
 
uint16_t AuSHMGetID ()
 
AuSHMAuGetSHMSeg (uint16_t key)
 
AuSHMAuGetSHMByID (uint16_t id)
 
int AuCreateSHM (AuProcess *proc, uint16_t key, size_t sz, uint8_t flags)
 AuCreateSHM – create a new shared memory segment or returns previously allocated one.
 
void AuSHMDelete (AuSHM *shm)
 
size_t AuSHMProcBreak (AuProcess *proc, size_t num_frames)
 
void AuSHMProcSwap (dataentry *current, dataentry *index)
 
void AuSHMProcOrderList (AuProcess *proc)
 
void * AuSHMObtainMem (AuProcess *proc, uint16_t id, void *shmaddr, int shmflg)
 AuSHMObtainMem – obtains a virtual memory from given shm segment.
 
void AuSHMUnmap (uint16_t key, AuProcess *proc)
 AuSHMUnmap – unmaps a shared memory segment.
 
void AuSHMUnmapAll (AuProcess *proc)
 AuSHMUnmapAll – unmaps all mappings for this process.
 

Variables

list_tshm_list
 
uint16_t shm_id
 
Spinlockshmlock
 

Function Documentation

◆ AuCreateSHM()

int AuCreateSHM ( AuProcess proc,
uint16_t  key,
size_t  sz,
uint8_t  flags 
)

AuCreateSHM – create a new shared memory segment or returns previously allocated one.

Parameters
proc– Creator process
key– unique key to use
sz– size in multiple of PAGE_SIZE
flags– security flags
Returns
id of newly created SHM, -1 on failure

◆ AuGetSHMByID()

AuSHM * AuGetSHMByID ( uint16_t  id)

◆ AuGetSHMSeg()

AuSHM * AuGetSHMSeg ( uint16_t  key)

◆ AuInitialiseSHMMan()

void AuInitialiseSHMMan ( )

AuInitialiseSHMMan – initialise shm manager.

◆ AuSHMDelete()

void AuSHMDelete ( AuSHM shm)

◆ AuSHMGetID()

uint16_t AuSHMGetID ( )

◆ AuSHMObtainMem()

void * AuSHMObtainMem ( AuProcess proc,
uint16_t  id,
void *  shmaddr,
int  shmflg 
)

AuSHMObtainMem – obtains a virtual memory from given shm segment.

Parameters
proc– Calling process
id– shm segment id
shmaddr– starting shared memory address to map @parma shmflg – flags
Returns
starting address of this shm on success, NULL on failure

◆ AuSHMProcBreak()

size_t AuSHMProcBreak ( AuProcess proc,
size_t  num_frames 
)

◆ AuSHMProcOrderList()

void AuSHMProcOrderList ( AuProcess proc)

◆ AuSHMProcSwap()

void AuSHMProcSwap ( dataentry current,
dataentry index 
)

◆ AuSHMUnmap()

void AuSHMUnmap ( uint16_t  key,
AuProcess proc 
)

AuSHMUnmap – unmaps a shared memory segment.

Parameters
key– key to search
proc– process to look

◆ AuSHMUnmapAll()

void AuSHMUnmapAll ( AuProcess proc)

AuSHMUnmapAll – unmaps all mappings for this process.

Parameters
proc– Pointer to process that needs unmapping

Variable Documentation

◆ shm_id

uint16_t shm_id

◆ shm_list

list_t* shm_list

BSD 2-Clause License

Copyright (c) 2022-2023, Manas Kamal Choudhury All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

◆ shmlock

Spinlock* shmlock