[GSOC] System V IPC in userspace week6 report
grigore larisa
larisagrigore at gmail.com
Sun Jul 28 14:57:26 PDT 2013
Hi all,
This week I have implemented sysv semaphores in userland. The hole idea is
based on the shared memory implementation. A call to *semget* is a *shmget* and
a *shmat.* The client stores information about each sysv resources in a
structure (file descriptor, the size of the file, the type of sysv
resource). In semaphores case, the client stores the address where there
are mapped in memory.
*shmctl* is implemented as messages sent to the daemon or as simple reads
from memory. IPC_RMID, IPC_STAT and IPC_SET call *smhctl* that sends a
message to the daemon. IPC_STAT is used to find out data about the sysv
resource. In semaphores case, there are some extra fields (that are not
available for shared memory). Those are read from the memory (same area the
semaphore is mapped). For all other commands, data are read/written from/in
the shared memory area.
*semop* is similar with the kernel implementation. For SEM_UNDO flag (used
to store changes made by a process in order to be undone when it finishes
its execution) I used a shared memory segment too. When this area is
created, the daemon mark it so that it can use it when the process dies.
Its initial size is PAGE_SIZE but it growths each time is no more space to
be written.
The client uses some structures (hashtables, locks) to store information
about the sysv resources. All can be safely used in multithreading
applications.
Larisa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dragonflybsd.org/pipermail/kernel/attachments/20130729/33dc5778/attachment.html>
More information about the Kernel
mailing list