Flushing a semaphore ?
Flushing a semaphore ?
- Subject: Flushing a semaphore ?
- From: Stéphane Letz <email@hidden>
- Date: Fri, 8 Apr 2005 16:12:39 +0200
We are using semaphores (the mach API defined in <mach/semaphore.h> )
to synchronize threads in different process in a server/client system.
The server signal a first client, that does some processing, then the
first client signal a second client, and so on :
client_1_thread :
-----------------------
loop {
semaphore_wait(client_1_sem)
....
do_some_process(...)
....
semaphore_signal(client_2_sem)
}
client_2_thread :
-----------------------
loop {
semaphore_wait(client_2_sem)
....
do_some_process(...)
....
semaphore_signal(client_3_sem)
}
.... third client
server_thread :
--------------------
loop {
semaphore_signal(client_1_sem)
wait_some_time()
}
The server_thread does not synchronize on client processing end but
runs at a periodic rate. In normal situation all clients are supposed
to run in the server period.
If clients are late, they are cases where the semaphore get signaled
several times before the waiting thread get actually waken up. When the
thread finally wakes up, it is able to "catch up" by running several
cycles up to the point the client input semaphore blocks again.
This is generally fine, but in some cases, we have to consider that a
client is really too late and we would like to "reset" its input
semaphore
(actually loosing all pending signals that where accumulated from the
previous component in the chain, the server of another client)
Is there a way to "flush/reset" a semaphore to have to desired
behaviour?
Thanks in advance
Stephane Letz
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden