newbie: threads and sched_yield ?

Mark Hounschell dmarkh@cfl.rr.com
Sat Mar 19 14:48:00 GMT 2005


I have a threaded application that uses process affinity and real-time 
priorities (SCHED_FIFO). Each of my thread-groups run at a unique 
real-time priority. Thread groups are dispersed over the available 
processors. To my question/problem. When any of my threads, even the one 
running at the lowest priority, gets into a loop like

    while (!something)
	sched_yield();

The whole machine freezes. When running a 2.6 kernel and NPTL I can 
replace the sched_yield with a very short pthread_cond_timedwait and all 
is fine, but on a 2.4 kernel using LinuxThreads this does not help. It 
appears that sched_yield used in a thread nor pthread_cond_timedwat do 
what I would expect it to do while running a 2.4 kernel and 
LinuxThreads. On my alpha ES45 I can use pthread_yield here and all is 
fine. There does not appear to be a pthread_yield for Linux. What is the 
proper way to do this on a 2.4 kernel using LinuxThreads? Surely 
sched_yield is not broken?

Also, when no process affinity or real-time scheduling is used this 
problem does not show its self at all.

I am already using most all the pthread calls and this part of the code 
is not where I can use any of the normal sleep/wakeup methods used 
elsewhere in my threads.

Thanks for any suggestions.
Regards
Mark



More information about the Libc-alpha mailing list