This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Semaphores in libc
On Thu, Dec 31, 2009 at 3:15 PM, Ryan Arnold <ryan.arnold@gmail.com> wrote:
> Paulo,
>
> I see you haven't set your line buffering mode with setvbuf.
>
> Don't trust printf and the underlying write buffering to not mess up
> the write serialization.
>
> If you want to use printf in the critical section for your test then
> call setvbuf and set it to no buffering or call fflush() within the
> critical section as well to force the buffer to make the kernel write
> syscall after every printf call.
>
> Ryan S. Arnold
>
you;re right, buffering and not releasing the sem upon an interruption
signal was screwing up the test.
Thanks all for your help,
--
Paulo Jorge Matos - pocmatos at gmail.com
http://www.pmatos.net