Skip to content

Patches to support shared memory in DragonWare - #11

Closed
tseli0s wants to merge 6 commits into
masterfrom
shared-memory
Closed

Patches to support shared memory in DragonWare#11
tseli0s wants to merge 6 commits into
masterfrom
shared-memory

Conversation

@tseli0s

@tseli0s tseli0s commented Jul 22, 2026

Copy link
Copy Markdown
Owner

These are some patches I wrote over the past few days to implement shared memory. From some basic tests I wrote, shared memory does seem to work now, though the current workings are very hackish and probably fragile. Debugging a double free at the moment, and I know some shortcomings that need to be addressed, but the general concept works.

We need shared memory for disk drivers and efficient software framebuffer blitting in general. Messages are quite limited by their nature, so sending a 1MB file, for example, will be way too slow and hackish to do with message payloads.

@tseli0s tseli0s self-assigned this Jul 22, 2026
@tseli0s tseli0s added enhancement New feature or request kernel Kernel-related feature or bug user-programs Userland related feature or bug breaking Breaking change (For pull requests only) performance Performance and throughput related bug or feature labels Jul 22, 2026
tseli0s added 6 commits August 7, 2026 23:33
Hackish workaround to allow processes to transfer handles to other
processes and therefore implement shared memory and everything else we
need really fast and easily.

Probably going to write a proper API for this in the future, but for now
my priority is to get a simple shared memory application running.

Signed-off-by: Aggelos Tselios <aggelostselios777@gmail.com>
There is a limit on how large a Section object can be due to kmalloc()
design constraints, but this gives a single section a maximum
addressable region of nearly two megabytes, plenty for very basic stuff
like small files.

In the meantime I should really think of something else, but for now,
this is a quick way to get some heap running.

Signed-off-by: Aggelos Tselios <aggelostselios777@gmail.com>
Will be needed to track how many processes have mapped the section and
therefore avoid freeing shared memory, causing security vulnerabilities
and bugs across programs.

Signed-off-by: Aggelos Tselios <aggelostselios777@gmail.com>
Both are going to be used to do automatic reference counting instead of
typing out the same if/else block every time. Will also be needed now
that section objects have reference counting internally.

Signed-off-by: Aggelos Tselios <aggelostselios777@gmail.com>
With memory sharing, tearing down the whole section will affect
applications that wish to keep reading the data even after the server or
the original application exited.

Add a new operation instead to simply unmap a section from the current
address space if needed, without touching other processes' memory view.

Signed-off-by: Aggelos Tselios <aggelostselios777@gmail.com>
…teardown

With reference counting, it is now possible to track whether a section
can be safely unmapped from one application and remain mapped on the
other, and this commit (hackishly) adds support for this.

I wrote some units to test how well this works, it appears that memory
sharing works but has some pitfalls still. Therefore we can now begin
the first steps towards a proper disk driver.

Signed-off-by: Aggelos Tselios <aggelostselios777@gmail.com>
tseli0s added a commit that referenced this pull request Aug 24, 2026
That previous hack in the other pull request is too ugly, but worse, it
doesn't scale well (let's say I need to translate 10 handles, I'll need
10 messages for that). About time we implement this function actually.

I believe pull request #11 should go away with this commit...

Signed-off-by: Aggelos Tselios <aggelostselios777@gmail.com>
@tseli0s

tseli0s commented Aug 24, 2026

Copy link
Copy Markdown
Owner Author

Some commits in this pull request have been cherry picked into master, the rest are useless with the progress done in #16 and master recently, so this pull request isn't needed anymore.

@tseli0s tseli0s closed this Aug 24, 2026
@tseli0s tseli0s removed their assignment Aug 24, 2026
@tseli0s
tseli0s deleted the shared-memory branch August 24, 2026 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Breaking change (For pull requests only) enhancement New feature or request kernel Kernel-related feature or bug performance Performance and throughput related bug or feature user-programs Userland related feature or bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant