Re: Scheduler

Mike Abbott <[email protected]> Fri, 21 Nov 2008 21:17:01 -0600
Newsgroups gmane.comp.lib.state-threads.user
Message-ID <[email protected]>
> How does ST's scheduler work?  Is it a simple round-robin queue?

In a word, yes.

The scheduler maintains a queue of runnable threads.  At each scheduling
opportunity it simply pulls the head element off the queue and runs it.
So the real question is, in what order does ST add threads to the run
queue?  Unfortunately that is completely unpredictable.  Some of the
actions that append threads to the run queue include:
	- select, poll, kevent etc. indicate that one or more
	  descriptors are ready for I/O, in which case the threads are
	  added to the run queue in the order they appear in the
	  I/O-pending queue
	- a timer expires
	- a zombie thread is joined
	- a sleeping thread is interrupted by st_thread_interrupt()
	- a thread is created
	- a mutex is unlocked or a condvar signalled

> Is it possible to exercise any control over the scheduler (such as
> dropping in my own), short of explicitly using synchronization
> primitives everywhere to control what threads are eligible for
> execution?

Why do you need such control over thread execution order?  If you really
do need such control then just use the synchronizers; that's what
they're there for.



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/