[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] System load

From: Joerg F. Wittenberger
Subject: Re: [Chicken-users] System load
Date: 16 Jan 2003 15:39:45 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Common Lisp)

Felix Winkelmann <address@hidden> writes:

> Joerg F. Wittenberger wrote:

> > Can I have a ready queue, which is just that, i.e, a test
> > (null? ##sys#ready-queue) => #t would mean 'the current thread is the
> > only one ready to run'.  I need a constant time predicate here for
> > proper handling of select(2).
> I guess this is the right moment to overhaul the scheduler...
> But that needs care. What we need is a more efficient representation
> for ready and blocked threads. Currently there is only a single
> queue that contains all threads which are ready or blocked.
> A blocked thread has a thunk that is invoked and which should
> return #t, if the thread should be unblocked.
> Crude? Probably. Any ideas would be welcome.

Easy: have a queue for all threads, remove there only when thread
terminates, one queue for each reason to block (condition variable).
Those are there anyway.  One ready queue, which is just that.  A
pointer into the ready queue for the current thread.  Scheduling
advances this to the cdr of the ready queue of the whole queue, when
at end of list.  Unblocked or new threads to to the head of the ready

The scheduler should also set a global variable, which is returned by
(current-time) [or if this is not desirable then call it
(current-timeslice-start)], this safes a few system calls.

Another global variable keeps the time until the next time event is
going to be delivered.  If the ready queue becomes empty, we wait in
select for that much time.  Otherwise every 2ms do a select without

Anything missing or stupid?


The worst of harm may often result from the best of intentions.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]