mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* semaphores and noatomic flag
@ 2001-06-04 17:34 Mihai Moise
  2001-06-05  6:28 ` Anil Kumar
  2001-06-05 17:26 ` davide.rossetti
  0 siblings, 2 replies; 4+ messages in thread
From: Mihai Moise @ 2001-06-04 17:34 UTC (permalink / raw)
  To: linux-kernel

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-06-05 17:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-04 17:34 semaphores and noatomic flag Mihai Moise
2001-06-05  6:28 ` Anil Kumar
2001-06-05 10:37   ` Daniel Phillips
2001-06-05 17:26 ` davide.rossetti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®