This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: Time slice is not happening quiet alright
- From: Nick Garnett <nickg at ecoscentric dot com>
- To: "Mike A" <embeddedeng at hotmail dot com>
- Cc: gthomas at ecoscentric dot com, ecos-discuss at sources dot redhat dot com
- Date: 30 Aug 2002 23:56:08 +0100
- Subject: Re: [ECOS] Time slice is not happening quiet alright
- References: <F172vV4T3Xx95IiSAda00021f83@hotmail.com>
"Mike A" <embeddedeng@hotmail.com> writes:
> So, You mean that there is some code within printf that blocks the
> scheduler (something like a schedule_lock), or which prevents the
> running task from giving up the CPU.
> Wonderful!
No, you have misunderstood. The eCos C library is thread safe, so
whenever an IO operation takes place, such as prinyf(), a lock
associated with the stream is taken. Any other thread that tries to do
IO on the same stream will be blocked until the first thread releases
it. This is standard mutual exclusion. Any thread that is not doing IO
on that stream is not affected in any way.
In your program's case, both your threads got serialized by the lock
on the standard IO stream. Giving the non-intuitive results you saw.
>
> Now one more question.
> Is there a document that talks about this? If there is let me know.
>
Nothing explicit. This is standard C library behaviour.
--
Nick Garnett - eCos Kernel Architect
http://www.eCosCentric.com/
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss