From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jonathan Larmour To: zhang Cc: ecos-discuss@sourceware.cygnus.com Subject: Re: [ECOS] about timeslice and same priority thread switch. Date: Fri, 02 Jun 2000 11:12:00 -0000 Message-id: <3937F921.6607680E@redhat.co.uk> References: <002001bfc9d5$a9f843a0$2901a8c0@21> <393436D7.104D0E0B@redhat.co.uk> <002c01bfca9f$d85197e0$2901a8c0@21> <3935726B.9AF476BC@redhat.co.uk> <001901bfcc53$527340a0$2801a8c0@lczhang> X-SW-Source: 2000-06/msg00043.html 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