DragonFly BSD
DragonFly kernel List (threaded) for 2013-07
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

[GSOC] System V IPC in userspace week4 report


From: grigore larisa <larisagrigore@xxxxxxxxx>
Date: Sun, 14 Jul 2013 23:50:32 +0300

--90e6ba6e873e1f9d1104e17ee5cf
Content-Type: text/plain; charset=ISO-8859-1

Hi everyone,

This week I have implemented the shared memory support in userland. I used
the actual kernel implementation and moved all structures and functions
needed by daemon in userspace.

Each shm function is described below:
- *shmget:*
  - userland
     - sends a message to the daemon with key, size and shmflags;
     - the daemon will search for the existing segment
     - if the segment already exists, some checks are made on permissions,
size, flags and the segment id is returned*
*
     - else allocates a new segment
     - the daemon replies with the segment identifier
  - kernel
     - tells the kernel to allocate a new vm_object_t if the segment does
not exist

- *shmctl*
  - userland
     - IPC_STAT - sends a request to the daemon and waits for information
needed; daemon has all information so it only sends them through pipe;
     - IPC_SET - sends request to the daemon and waits for the error code;
     - IPC_RMID - sends request to the daemon and waits for the error code;
  - kernel
     - for IPC_SET and IPC_RMID,  the daemon informs kernel about the state
of the segment; The kernel is informed because shmat calls directly ioctl,
without the daemon intervention.

- *shmat* - calls ioctl() function that will do mostly the same operations
as the current shm implementation (permission checks, add the *vm_object_t* in
the process address space); the driver mmap announces the daemon that
another process mapps the shared memory object;
*- shmdt* - same as in *shmat* case

Because, in the actual kernel implementation, more threads can access same
data, some states describing each segment are used. I kept those because I
think the daemon must use a poll of threads to handle the clients requests
for performances reasons.

Tomorrow I will do a code refactoring (including splitting daemon, library
and client code), following that next days I will start implement support
for semaphores.

Thanks,
Larisa

--90e6ba6e873e1f9d1104e17ee5cf
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi everyone,<div><br></div><div>This week I have implement=
ed the shared memory support in userland. I used the actual kernel implemen=
tation and moved all structures and functions needed by daemon in userspace=
.</div>
<div><br></div><div>Each shm function is described below:<br></div><div><di=
v style=3D"font-family:arial,sans-serif;font-size:13px">-=A0<i>shmget:</i><=
/div><div style=3D"font-family:arial,sans-serif;font-size:13px">=A0 - userl=
and</div>
<div style=3D"font-family:arial,sans-serif;font-size:13px">=A0 =A0 =A0- sen=
ds a message to the daemon with key, size and shmflags;</div><div style=3D"=
font-family:arial,sans-serif;font-size:13px">=A0 =A0 =A0- the daemon will s=
earch for the existing segment<br>
</div><div style=3D"font-family:arial,sans-serif;font-size:13px">=A0 =A0 =
=A0- if the segment already exists, some=A0checks are made on permissions, =
size, flags and the segment id is returned<i><br></i></div><div style=3D"fo=
nt-family:arial,sans-serif;font-size:13px">
=A0 =A0 =A0- else allocates a new segment</div><div style=3D"font-family:ar=
ial,sans-serif;font-size:13px">=A0 =A0 =A0- the daemon replies with the seg=
ment identifier</div><div style=3D"font-family:arial,sans-serif;font-size:1=
3px">=A0 - kernel</div>
<div style=3D"font-family:arial,sans-serif;font-size:13px">=A0 =A0 =A0- tel=
ls the kernel to allocate a new vm_object_t if the segment does not exist<b=
r></div><div style=3D"font-family:arial,sans-serif;font-size:13px"><br></di=
v><div style=3D"font-family:arial,sans-serif;font-size:13px">
-=A0<i>shmctl</i></div><div style=3D"font-family:arial,sans-serif;font-size=
:13px">=A0 - userland</div><div style=3D"font-family:arial,sans-serif;font-=
size:13px">=A0 =A0 =A0- IPC_STAT - sends a request to the daemon and waits =
for information needed; daemon has all information so it only sends them th=
rough pipe;</div>
<div style=3D"font-family:arial,sans-serif;font-size:13px">=A0 =A0 =A0- IPC=
_SET - sends request to the daemon and waits for the error code;</div><div =
style=3D"font-family:arial,sans-serif;font-size:13px">=A0 =A0 =A0- IPC_RMID=
 - sends request to the daemon and waits for the error code;</div>
<div style=3D"font-family:arial,sans-serif;font-size:13px">=A0 - kernel</di=
v><div style=3D"font-family:arial,sans-serif;font-size:13px">=A0 =A0 =A0- f=
or=A0IPC_SET and=A0IPC_RMID, =A0the daemon informs kernel about the state o=
f the segment; The kernel is informed because shmat calls directly ioctl, w=
ithout the daemon intervention.</div>
<div style=3D"font-family:arial,sans-serif;font-size:13px"><br></div><div s=
tyle=3D"font-family:arial,sans-serif;font-size:13px">-=A0<i>shmat</i>=A0- c=
alls=A0ioctl()=A0function that will do=A0mostly the same operations as the =
current shm implementation (permission checks, add the=A0<i>vm_object_t</i>=
=A0in the process address space); the driver mmap announces the daemon that=
 another process mapps the shared memory object;</div>
<div style=3D"font-family:arial,sans-serif;font-size:13px"><i>- shmdt</i>=
=A0- same as in=A0<i>shmat</i>=A0case</div><div style=3D"font-family:arial,=
sans-serif;font-size:13px"><br></div></div><div style=3D"font-family:arial,=
sans-serif;font-size:13px">
Because, in the actual kernel implementation, more threads can access same =
data, some states describing each segment are used. I kept those because I =
think the daemon must use a poll of threads to handle the clients requests =
for performances reasons.</div>
<div style=3D"font-family:arial,sans-serif;font-size:13px"><br></div><div s=
tyle=3D"font-family:arial,sans-serif;font-size:13px">Tomorrow I will do a c=
ode refactoring (including splitting daemon, library and client code),=A0fo=
llowing that next days I will start implement support for semaphores.</div>
<div style=3D"font-family:arial,sans-serif;font-size:13px"><br></div><div s=
tyle=3D"font-family:arial,sans-serif;font-size:13px">Thanks,</div><div styl=
e=3D"font-family:arial,sans-serif;font-size:13px">Larisa</div></div>

--90e6ba6e873e1f9d1104e17ee5cf--



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]