This is the mail archive of the ecos-discuss@sourceware.cygnus.com mailing list for the eCos project.


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

Re: about timeslice and same priority thread switch.



 
> 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 !!



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