Re: Use semaphore for producer/consumer case...

2001-03-26 Thread Stelian Pop
On Mon, Mar 26, 2001 at 07:12:55PM +0200, Manfred Spraul wrote: > > > That doesn't work, at least the i386 semaphore implementation > doesn't > > > support semaphore counts < 0. > > > > Does that mean that kernel semaphore can not be used for something > > else than mutual exclusion ? > > > It's

Re: Use semaphore for producer/consumer case...

2001-03-26 Thread Manfred Spraul
From: "Stelian Pop" <[EMAIL PROTECTED]> > > > > That doesn't work, at least the i386 semaphore implementation doesn't > > support semaphore counts < 0. > > Does that mean that kernel semaphore can not be used for something > else than mutual exclusion ? > It's a bit better: counts >= 0 are support

Re: Use semaphore for producer/consumer case...

2001-03-26 Thread Stelian Pop
On Fri, Mar 23, 2001 at 03:52:54PM -0800, Nigel Gamble wrote: > For the producer/consumer case, you want to initialize the semaphore to > 0, not 1 which DECLARE_MUTEX(sem) does. So I would use > > __DECLARE_SEMAPHORE_GENERIC(sem, 0) You're right that the DECLARE_MUTEX does not (entirely) do th

Re: Use semaphore for producer/consumer case...

2001-03-26 Thread Stelian Pop
On Fri, Mar 23, 2001 at 07:34:07PM +0100, Manfred Spraul wrote: > > consumer() > > > /* Let's wait for 10 items */ > > atomic_set(&sem->count, -10); > > That doesn't work, at least the i386 semaphore implementation doesn't > support semaphore counts < 0. Does that m

Re: Use semaphore for producer/consumer case...

2001-03-23 Thread Nigel Gamble
On Fri, 23 Mar 2001, Stelian Pop wrote: > I want to use a semaphore for the classic producer/consumer case > (put the consumer to wait until X items are produced, where X != 1). > > If X is 1, the semaphore is a simple MUTEX, ok. > > But if the consumer wants to wait for several items, it doesn'

Re: Use semaphore for producer/consumer case...

2001-03-23 Thread Manfred Spraul
> consumer() > /* Let's wait for 10 items */ > atomic_set(&sem->count, -10); That doesn't work, at least the i386 semaphore implementation doesn't support semaphore counts < 0. -- Manfred - To unsubscribe from this list: send the line "unsubscribe linux-kernel"

Use semaphore for producer/consumer case...

2001-03-23 Thread Stelian Pop
Hi, I want to use a semaphore for the classic producer/consumer case (put the consumer to wait until X items are produced, where X != 1). If X is 1, the semaphore is a simple MUTEX, ok. But if the consumer wants to wait for several items, it doesn't seem to work (or something is bad in my code