This is the mail archive of the
ecos-discuss@sourceware.cygnus.com
mailing list for the eCos project.
Re: about timeslice and same priority thread switch.
- To: "Jonathan Larmour" <jlarmour at redhat dot co dot uk>
- Subject: Re: [ECOS] about timeslice and same priority thread switch.
- From: "zhang" <lczhang at csrd dot org>
- Date: Fri, 2 Jun 2000 13:28:02 +0800
- Cc: <ecos-discuss at sourceware dot cygnus dot com>
- References: <002001bfc9d5$a9f843a0$2901a8c0@21> <393436D7.104D0E0B@redhat.co.uk> <002c01bfca9f$d85197e0$2901a8c0@21> <3935726B.9AF476BC@redhat.co.uk>
> Ah, that happens because in each `for' loop, the majority of the execution
> time is spent in the printf function. printf is notoriously expensive. As a
> result, most of the time that a timeslice occurs, the mutex `cliblock' is
> locked, so the newly woken up thread cannot run; so it goes back to sleep
> again.
>
> Simply comment out the mutex lock and unlock calls in twothreads.c and you
> will see that things begin to behave slightly more sensibly. The mutex is
> completely unnecessary if the configuration option
> CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS is enabled, which controls the
> existence of a mutex deeper inside libc stdio.
>
> Note that if you disable that configuration option as well, then the
> threads should then strictly alternate as you expected; however it also
> means there is a chance of them corrupting common data inside libc stdio
> since they can then interrupt each other at any point.
>
> Jifl
Hi,sorry to bother you again ,as you explained ,we change the value of CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS from 1 to 0 in the file of ecos.ecc ,then we build the thread.c and run it ,but the result is the same ,
so ,we want to know whether we miss something to do or do not catch your real meaning.
Moreover we also have some question on your explain.As your say , the majority of the execution time is spent in the printf function, it seems that the printf is the real cause of the unablity of thread switch ,however if we build another source file of two thread switch ,with one thread having lower priority and the other having higher ,the result is that they can switch .We are puzzled because this time the source file also contain printf, if the printf expense too much time as you said ,even if another thread have a higher priority ,the thread switch may not be realized either.So we are not sure ,will any body hints me ?
Thanks a lot !!