9 May 2006 19:06
IPC-Semaphore
Christian Stalp <stalp <at> imbei.uni-mainz.de>
2006-05-09 17:06:43 GMT
2006-05-09 17:06:43 GMT
Hello out there,
Im working on a solution to delete a semaphore, which is used by other
processes.
The semaphore was created by a server-process. It write the semaphore-key into
a file ( where the clients can read it, and get access to the semaphore )
After that the server proceeds its work.
When the server finished its work, it destroys the semaphore. And here we have
quandary. In this very moment the clients still need the semaphore.
In the semctl-manual we have a several arguments, amongst others.
GETZCNT The system call returns the value of semzcnt for the sem-
num-th semaphore of the set (i.e. the number of processes
waiting for semval of the semnum-th semaphore of the set to
become 0). The calling process must have read access priv-
ileges on the semaphore set.
or
GETNCNT The system call returns the value of semncnt for the sem-
num-th semaphore of the set (i.e. the number of processes
waiting for an increase of semval for the semnum-th
semaphore of the set). The calling process must have read
access privileges on the semaphore set.
based on this I made this function:
/* Loeschen einer Semaphore */
int loesche_semaphore ( int kennung )
{
union semun mysem;
int semnum = 0,
rueckgabe_1 = 0,
rueckgabe_2 = 0;
(Continue reading)

RSS Feed