<div dir="ltr">Hi all,<div><br></div><div>This week I have ported the message queues implementation in userland. <i>msgget</i> is implemented base on <i>shmget</i> and <i>shmat.</i> At the beginning a size of PAGE_SIZE segment is obtained. It contains all metadata (message headers, first free message header, etc) and the messages. In this way, limits like number of messages in system are irrelevant. In this case it is replaced with a limit per process and more messages can exist in the system in the same time.</div>
<div><br></div><div><i>msgctl</i> is implemented using <i>shmctl</i> and it is similar with the semaphores approach. When a thread wants to remove a message queue, it marks it as deleted to inform other processes. It sends the appropriate message to the daemon and frees the memory only when no other thread in its space address uses the message queue. For IPC_SET and IPC_STAT commands, as in semaphores case, a message is sent to daemon in order to set/get the msg permissions. All other fields are set/get by writing/reading in/from shared memory.</div>
<div><br></div><div><i>The msgsnd</i> and <i>msgrcv</i> implementation is similar with the kernel one. Differences are related to the locking mechanism (each queue is protected by a rwlock and it is released only when the process must wait for messages), limits and error checks.</div>
<div><br></div><div>Thanks,</div><div>Larisa</div></div>