> 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 the job,
but I set manually the value of sem->count:
> > atomic_set(&sem->count, -10);
> Then consumer could be:
> /* Wait for 10 items to be produced */
> for (i = 0; i < 10; i++)
> down(&sem);
IMHO, this will not work, because the producer could be issuing
more than one 'up(&sem)' at the time...
Stelian.
-- Stelian Pop <stelian.pop@fr.alcove.com> |------------- Ingénieur Informatique Libre --------------| | Alcôve - http://www.alcove.com - Tel: +33 1 49 22 68 00 | |----------- Alcôve, l'informatique est libre ------------| - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/