[coyotos-dev] Sleep for interval
Sam Mason
sam at samason.me.uk
Thu Oct 4 06:50:28 EDT 2007
On Thu, Oct 04, 2007 at 04:30:48PM +1000, Math Gasm wrote:
> Does [the sleep call] need to be in the kernel?
As I understand it, it's perfectly possible to implement it in
user-space. The problem comes with the performance characteristics
if it is. Lots of programs perform lots of little waits/timeouts and
requiring an unnecessary context switch for all of them is bad.
> Sleep for interval seems trivial- don't
> bother scheduling the process before that time. Sleep until wall time is
> just as easy, a scheduler can keep a linked list of processes to be
> woken up and check it against a time server every now and then.
They're both really the same thing, it's just that for the relative-wait
we need to add the current time on and then we can do an absolute wait
(or your could implement it the other way around). Either way, we need
to maintain a list of processes that need to be woken up.
The Coyotos kernel has, as one of it's main design criteria, a
requirement that all operations should complete in a small (i.e.
can be modelled as O(1)) number of instructions. This rules out a
lot of common data structures/algorithms that are commonly used in
the design of these sort of things. The kernel also requires that
user-space designates the memory that it uses to store things, so if
we were maintaining a list of processes to run, then this list must
be accountable to the calling program. Again, this complicates the
maintenance of your "linked list of processes".
It seems annoying that the current design is left with this scheduling
artifact, but I can't think of any cases where it'll compromise
anything. I'm not nearly experienced enough with this sort of thing to
know if it's actually going to impact on anything later, so I'm happy to
assume Shap knows best and trust his judgement.
Sam
More information about the coyotos-dev
mailing list