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.


zhang wrote:
> 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.

Did you also comment out the mutex lock/unlock lines? Otherwise disabling
that option will have no effect.

But it turns out I missed out that there is yet another mutex lock buried
deep in the serial code (called from serial_write() specifically). So even
with the above option disabled, *and* the mutexes removed, it is still
possible for the threads to not strictly alternate on a timeslice, because
one of them is holding that mutex. But it will be a lot closer. Try it and
see.

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

It depends on the exact code you are using, but my guess is that in this
case the threads are not being timesliced. Instead they are being scheduled
strictly according to their priorities, with the possibility of there also
being mutex priority inheritance.

Without seeing the code you are using I can't be sure.

Jifl
-- 
Red Hat, 35 Cambridge Place, Cambridge, UK. CB2 1NS  Tel: +44 (1223) 728762
"Plan to be spontaneous tomorrow."  ||  These opinions are all my own fault

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