somtingwong
somtingwong

Reputation: 359

Create shared memory segments in kernel space?

I'm trying to create a "mailbox" system call where processes can send messages to each other. I wanted to use some sort of shared memory so I can refer to a "mailbox" by its ID, but I can't call system calls from another system call right? Is there another way where I can "refer" to a particular "mailbox" by its ID? I was thinking of just using kmalloc and creating an array of structs. Not looking for code, just general pointers as to how I should do this. Thank you!

EDIT: Don't think I clarified but the mailboxes have to be in kernel space

Upvotes: 0

Views: 789

Answers (1)

Jonathon Reinhart
Jonathon Reinhart

Reputation: 137398

You certainly can't call kmalloc from userspace.

What you're looking for is actually called POSIX "shared memory".

In general, you call shm_open to open a shared memory object. Then you mmap it, so you can access it via a pointer, just like normal memory.

See also:

Upvotes: 1

Related Questions