[En-Nut-Discussion] Again Semaphore implementation
Ole Reinhardt
ole.reinhardt at kernelconcepts.de
Wed Jun 2 17:43:36 CEST 2004
Hi All,
I had a strange experience with the current semaphore implementation.
I implemented the well know reader / write problem with a ringbuffer
containing data:
I have three semaphores:
SEM empty;
SEM full;
SEM mutex;
Init:
NutSemInit(&buffer->mutex, 1);
NutSemInit(&buffer->full, 0);
NutSemInit(&buffer->empty, buffersize);
writer:
wait(empty);
wait(mutex);
write somethin into the buffer
post(mutex);
post(full);
reader:
wait(full);
wait(mutex);
read something from buffer
post(mutex);
post(empty);
While writing into the buffer this implementation works quite fine. It
blocks if my buffer runs full.
When reading from the buffer the value of the full semaphore becomes
less then 0 (Integer overflow) and then does not block any more...
Where to search the problem?
Regards,
Ole
--
kernel concepts Tel: +49-271-771091-14
Dreisbachstr. 24 Fax: +49-271-771091-19
D-57250 Netphen E+ : +49-177-7420433
--
More information about the En-Nut-Discussion
mailing list