From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Graf To: ecos-discuss@sources.redhat.com Subject: Re: [ECOS] sscanf() vs. fgetc() Date: Thu, 12 Jul 2001 03:45:00 -0000 Message-id: <3.0.5.32.20010712123601.0090f2e0@128.128.128.220> References: <3.0.5.32.20010712104805.00914420@128.128.128.220> <86sng24g1c.fsf@halftrack.hq.acn-group.ch> X-SW-Source: 2001-07/msg00347.html Hi Robin, >> But when I use sscanf() in the old thread, it hangs. >> Even if the new process completes fgetc(), because characters are received, >> the old process won't get any further. > >I suppose that only one thread at a time can read characters from a serial >port. When a thread wants to read, it probably has to obtain a mutex, then it >checks a condition such as input buffer not empty or waits on a condition >variable bound to this condition. When some characters come in, the condition >variable gets signalled and the thread with the higher priority runs and >consumes the available characters. Therefore, another thread with a lower >priority will never get a chance to see a non-empty buffer, or in one word: >starvation. You are obviously right, but: My sscanf() does access a *string*, which is absolutely not related to the *serial port* read by fgetc(). Peter