public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* Question about locking in IO function
@ 2021-07-19 14:38 Martin Peterlin
  0 siblings, 0 replies; only message in thread
From: Martin Peterlin @ 2021-07-19 14:38 UTC (permalink / raw)
  To: newlib

Hi.

I stumbled upon an issue on an embedded platform, where a thread was
waiting for characters using fgetc(stdin) and another thread couldn't
complete a fileno(stdin) call.

The following snippet reproduces it:

std::thread t1([](){
    fgetc(stdin);
});
std::this_thread::sleep_for(std::chrono::seconds(1));
printf("fileno(stdin): %d\n", fileno(stdin));
t1.join();

I ran this on both embedded platform and host, and host successfully
executed fileno, while embedded platform got stuck on fileno, waiting for a
mutex which was taken by fgetc.

The embedded platform is supposedly running newlib-3.3.0 and host is Ubuntu
20.04 (glibc 2.31).

Is this expected behavior? Is there a configuration option for some kind of
multithreaded IO?
I'm new to newlib and am not aware of all its possibilities and options.

Best regards,
Martin Peterlin

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-19 14:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-19 14:38 Question about locking in IO function Martin Peterlin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).