Use semaphore for producer/consumer case...
Quoted 4 lines
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
Quoted 7 lines · Manfred Spraul
Quoted 4 lines
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 mean that kernel semaphore can not be used for something else than mutual exclusion ?
Stelian.
Signature · 4 lines
Stelian Pop <[email protected]> |------------- Ingénieur Informatique Libre --------------| | Alcôve - http://www.alcove.com - Tel: +33 1 49 22 68 00 | |----------- Alcôve, l'informatique est libre ------------|
From: "Stelian Pop" <[email protected]>
Quoted 2 lines
Quoted 2 lines
That doesn't work, at least the i386 semaphore implementation
doesn't
Quoted 5 lines
Quoted 1 line
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 supported, i.e. you can call up() before down(), and that's used in several places.
The for loop that Nigel proposed should solve your problem. Multiple up's are handled correctly.
--
Manfred
Quoted 9 lines · Manfred Spraul
Quoted 1 line
Quoted 1 line
That doesn't work, at least the i386 semaphore implementation
doesn't
Quoted 5 lines
Quoted 1 line
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 supported, i.e. you can call
up()beforedown(), and that's used in several places.
I see... it's somewhat different than the classical semaphore implementation, but usable anyway.
Quoted 2 lines
The for loop that Nigel proposed should solve your problem. Multiple up's are handled correctly.
Now I understand his suggestion. Thanks to both of you.
Stelian.
Signature · 4 lines
Stelian Pop <[email protected]> |------------- Ingénieur Informatique Libre --------------| | Alcôve - http://www.alcove.com - Tel: +33 1 49 22 68 00 | |----------- Alcôve, l'informatique est libre ------------|