what is the most efficient wakeup method (signals,msgs,semaphores) ?

From: Benno Senoner (sbenno@gardena.net)
Date: Thu Oct 19 2000 - 08:58:39 EST


Hi,
I'd like to hear your opinions on the efficiency for the IPC mechanism
betweeen two processes. (from a kernel point of view)

I have a process (A) which wakes up another process (B) very often
(200-1000 times/sec).

eg:
A)
while(1) {
wait_a_few_msecs_using_RTC();
wake_up_B();
}

B)
while(1) {
wait_for_wakeup_signal_from_B();
do_my_stuff();
}

I was wondering what's the most lightweight wakeup method
(from process A point of view) looks like.
It is important that A does not block for any reason (in wake_up_B()) , and that
it should use very few CPU cycles even when many processes are active.

Is it better to use a messages queues (msgsnd()), or SYSV semaphores ,
or signals ( kill(2) ) ?

It is important that the methods be very fast and that there should be as
few as possible forms of non-determinism (no memory allocation etc,sleeping etc)
when performing a wake up action.

Notice that the I can't use pthreads because the wakeup process and the woken-up
process need to be separate processes.

Another method could be to use shared mem, and let B poll for the presence of a
flag and sleep 10-20msec between pollings
B)
while(1) {
while(1) {
if(wakeup_flag) break;
}
wakeup_flag=0;
do_my_stuff();
}

Althogh this is the most lightweight method from A POV (it sets only a flag),
it's not ideal from the B's side, since you need constant polling, plus the
granularity of timing is limited by HZ (reaction time would be 20msec min since
the minimum sleep time is 20msec)

opinions ?

PS: please CC me because I'm not on the LKML list.

thanks,
Benno.

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



This archive was generated by hypermail 2b29 : Mon Oct 23 2000 - 21:00:14 EST