MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / CreateSharedMemory

Function CreateSharedMemory

Kernel/src/sharedmem.cpp:51–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49 }
50
51 int64_t CreateSharedMemory(uint64_t size, uint64_t flags, pid_t owner, pid_t recipient){
52 acquireLock(&lock);
53
54 int64_t key = NextKey();
55
56 if(!key) return 0;
57
58 uint64_t pgCount = (size + 0xFFF) >> 12;
59
60 shared_mem_t* sMem = (shared_mem_t*)kmalloc(sizeof(shared_mem_t));
61 table[key] = sMem;
62 sMem->pgCount = pgCount;
63 sMem->pages = (uint64_t*)kmalloc(sMem->pgCount * sizeof(uint64_t*));
64 sMem->mapCount = 0;
65
66 for(unsigned i = 0; i < sMem->pgCount; i++){
67 sMem->pages[i] = Memory::AllocatePhysicalMemoryBlock();
68 }
69
70 sMem->flags = flags;
71 sMem->owner = owner;
72 sMem->recipient = recipient;
73
74 releaseLock(&lock);
75
76 return key;
77 }
78
79 void* MapSharedMemory(int64_t key, process_t* proc, uint64_t hint){
80 acquireLock(&lock);

Callers 2

CreateWindowBufferMethod · 0.50
SysCreateSharedMemoryFunction · 0.50

Calls 3

NextKeyFunction · 0.85
kmallocFunction · 0.85

Tested by

no test coverage detected