|
Home > Archive > Unix Programming > May 2005 > sysv semaphores
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Patrick Plattes 2005-05-13, 8:05 am |
| hello,
is there any way to wake up the suspended processes in lifo (stack)
order, not in fifo.
thank you very much,
patrick
| |
| Michael Kerrisk 2005-05-13, 8:05 am |
| On Fri, 13 May 2005 11:53:12 +0200, Patrick Plattes
<newsgroup@erdbeere.net> wrote:
Hello Patrick,
>is there any way to wake up the suspended processes in lifo (stack)
>order, not in fifo.
No. And in fact the fifo order you are seeing is just an
implementation artifact. If multiple processes are blocked on a
semaphore, and a change means that any one of them could proceed,
there is no guarantee about which one will be (the choice could be
arbittrary, or based on scheduling priority). If you need to enforce
an order, then you need some other mechanism (perhaps something
message based, like a message queue or FIFO).
Cheers,
Michael
| |
| Patrick Plattes 2005-05-13, 8:05 am |
| Michael Kerrisk wrote:
>
>
> No. And in fact the fifo order you are seeing is just an
> implementation artifact. If multiple processes are blocked on a
> semaphore, and a change means that any one of them could proceed,
> there is no guarantee about which one will be (the choice could be
> arbittrary, or based on scheduling priority).
thank you for fast reply. if i understand the systemv correct. the
susbended processes are stored like a message queue, so there should be
an order.
otherwise it is just an implementation of a weak semaphore.
i see two different interfaces to semaphores the systemv and the posix
interface. both should call kernel functions of semaphores. if this is
correct a wait_queue structur is used by the semid_ds structur (the new
sem_array structure looks similar).
maybe i'm totally wrong, so please correct me.
thank you,
patrick
/* One semid data structure for each set of semaphores in the system. */
struct semid_ds {
struct ipc_perm sem_perm; /* permissions .. see ipc.h */
time_t sem_otime; /* last semop time */
time_t sem_ctime; /* last change time */
struct sem *sem_base; /* ptr to first semaphore in array */
struct wait_queue *eventn; /* wait for a semval to increase */
struct wait_queue *eventz; /* wait for a semval to become 0 */
struct sem_undo *undo; /* undo requests on this array */
ushort sem_nsems; /* no. of semaphores in array */
};
|
|
|
|
|