lkml.org 
[lkml]   [2000]   [Dec]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Semaphores slow???

On 2000.12.27 Rogier Wolff wrote:
> We have a typical semaphore application that has a producer and a
> consumer.
>
> Without the semaphores we are limited by the rest of the stuff to
> 10000 times around the loop per second. That's good.
>
> When we put the "push the semaphore" call in there, the rate drops to
> around 8000 per second. I'm not happy about that, but ok. When we add
> the "wait for bufferspace" semaphore wait in there, the rate drops to
> 4000 per second. This is way too low.
>

Look (s==write_sem, bs==write_buffer_sem):

cons prod
====================
wait(bs)
post(bs)
wait(s) <wake>
<work>
post(s)
<wake> wait(bs)
<work>
post(bs)
wait(s) <wake>
<work>
post(s)
<wake> wait(bs)
<work>
post(bs)
wait(s) <wake>
.................

So there is no way that <work> can be done at the same time on
producer and consumer. So if you measure the loops per sec of the
producer (for example), in 'free run' you get 10k, in synchro run
with consumer you have just the half, because really prod and cons
are running sequentially, one after the other.

You need to thighten the mutexed zone for the thing to work in parallel
in an efficient way.

--
J.A. Magallon $> cd pub
mailto:jamagallon@able.es $> more beer

Linux werewolf 2.2.19-pre3-aa3 #3 SMP Wed Dec 27 10:25:32 CET 2000 i686

-
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/

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