[coyotos-dev] Sleep, wakeup, and persistence
Jonathan S. Shapiro
shap at eros-os.com
Fri Sep 14 14:37:51 EDT 2007
On Fri, 2007-09-14 at 11:19 -0700, Charles Landau wrote:
> At 2:03 PM -0400 9/14/07, Jonathan S. Shapiro wrote:
> >A process wants to sleep until time X. That is easy if the system keeps
> >running until then, but if the system re-starts what happens?
> >
> > 1. The underlying system may not have a monotonically increasing
> > clock. Many embedded systems do not.
>
> You can store the time base in the checkpoint, and restore it on
> restart. Problem solved.
That gets you a monotonically increasing clock. It does not get you an
accurate interval, which is also required.
>
> >To deal with these cases, I believe that the semantics of sleep() must
> >be as follows:
> >
> > 1. It means "wake me up as soon as possible after time X"
>
> By definition, you can't do any better than that.
Yes. That was my point.
> > 2. The caller needs to be able to specify whether a system
> > restart should terminate the sleep.
> > 3. The result needs to indicate whether an intervening restart
> > occurred.
>
> Perhaps it makes more sense to support different types of sleep:
> sleep until a given real time (and time zone)
> sleep for x seconds from now
> sleep for a given amount of system-up time
All of these can be expressed at user level. Inside the kernel, the
primitive is "sleep until absolute time X has arrived".
--
Jonathan S. Shapiro
Managing Director
The EROS Group, LLC
www.coyotos.org, www.eros-os.org
More information about the coyotos-dev
mailing list