This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: 1.7.7: stdio functions block each other in a multithreaded program

On Jan 25 14:31, wrote:
> I am trying to make a multi-threaded application, where one thread reads
> commands from stdin, and another thread is doing other things, such as
> reading files and printing messages to stdout.
> The problem I have is that the thread that reads files and writes to stdout
> locks while the other thread is reading from stdin. To demonstrate this,
> I created a small program that has this behavior. The C-code is present at
> the end of this e-mail.
> [...]

Thanks for the testcase!

First of all, I can confirm your observation and your testcase easily
allows to debug what happens.  What happens is that the read operation
in scanf and the read operation in fgetc are blocking each other out
because they access the same global lock.

I could track down this behaviour to a specific change in newlib from
2009, which also explains why this still worked in 1.5 (which I tested
as well).

So, the next task for me is to find out why this change has been made
and to talk to the contributor of the change to come to a solution
which does not show this unfortunate behaviour.

What you can do for the time being is to use the low-level IO functions
read and write, rather than the stdio functions fgetc and putchar, since
only the stdio functions are affected by this.

I hope to find a solution soon and the bugfix will definitely be in 1.7.8.

Again, thanks for testcase.  It's highly appreciated.


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]