Draft! feat: Shared memory #41
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This resolves #21
Shared memory is a high-performance inter process communication (IPC) mechanism that involves allocating ram regions accessible to multiple independent processes.
This is not the default way for IPC, as the OS kernel seeks to isolate the memory allocated to each process. It does this by allowing the use of different resources to achieve communication, such as pipes, files, sockets and queues. These methods require the kernel to copy and move information back and forth between processes, which can be expensive and/or slow.
Thus using shared memory we allow independent processes to read and write the information at the same memory region, gaining speed and efficiency. Processes access this space as if they were using local memory.
Its important to note that this can be an attack vector, as other processes can compromise the information read by other processes without kernel interference. Also, for maintaining data integrity, processes must implement their own synchronization mechanisms to coordinate access and prevent race conditions.
Despite this mechanism potentially seeming to permissive, shared memory is extensively used by modern applications and processes because of its performance benefits.
Databases uses them for tasks like caching data and transactions logs, and for facilitating IPC between worker processes and the main application. Web server also rely on this for rapidly sharing configuration data, session states and cached web content across multiple independent worker processes to handle client requests.
Changes
/dev/shmto be onlyro,noexec. (this was the only clean way to achive this as during the boot of the system a process was mounting the /dev/shm to be writable and withoutnoexecoption.)