lkml.org 
[lkml]   [2001]   [Jun]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectsemaphores and noatomic flag
I write this to discuss the reasons why the semop system call should
have an IPC_NOATOMIC flag.

Suppose we have two processes, called client and server, which
communicate through a shared memory segment and two semaphores, and need
to synchonize their activities so that they don't operate simultaneously
except at startup.

The server would do,

down(smephore 0)

to wait for a message from the client. When the client needs the server
to execute, it would,

up(semaphore 0) /* wake up server */
down(semaphore 1) /* put itself to sleep */

after the server has completed its portion of the task, it would,

up(semaphore 1) /* wake up client */
down(semaphore 0) /* put iself to sleep */

The problem is that the two system calls make the whole process twice as
slow as it needs to be, and they are both needed because the semop
system call is implemented in an atomic manner. If the semop system call
had an IPC_NOATOMIC flag, then the each process would only have to do
one call,

semop(up semaphore 0 & down semaphore 1, IPC_NOATOMIC)

which would be interpreted in the kernel as the sequence of two system
calls I have written previously.

I want to know what other people think about this idea.

Mihai
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:54    [W:0.095 / U:0.364 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site