Adding a new scheduling algorithm to Fiasco.OC

Adam Lackorzynski adam at os.inf.tu-dresden.de
Mon Jul 7 22:57:29 CEST 2014


Hi,

On Thu Jul 03, 2014 at 12:09:06 +0200, Valentin Hauner wrote:
> In a previous mail, you stated that a thread has a Sched_context object
> embedded that stores scheduling-related information. However, I cannot
> find a 1:1 relation from a Thread to a Sched_context object.
> I've found various calls of the sched_context() method in 'thread.cpp',
> which is defined in 'context.cpp'. Furthermore, there are several calls
> of the current() method in 'thread.cpp' (returning the current context),
> which is defined in 'context_base.cpp'.
> 
> So my main question is: What is the exact relation of a Thread object to
> all these classes?

A Thread is derived from Context which in turn is derived from
Context_base. So a Thread contains a Context and from a Thread
everything in Context can be accessed (except 'private' things of
course). A Sched_context is embedded in the Context class
(_sched_context).
 
> I assume that a Context object is cpu-specific, i.e. each Context object
> points to its home cpu. Is that right? This would make sense since there

A context 'lives' on a CPU but it can also change its CPU. The CPU info
is stored in the Context so that the code knows on which CPU it is
currently running.

> is a home_cpu attribute and a schedule() method in that class that
> handles the scheduling on a certain cpu.
> 
> But what's the matter with Sched_context?
> It seems to me that there is no 1:1 relation from a Thread to a
> Sched_context since the sched_context() method called in 'thread.cpp' is
> defined in 'context.cpp'. So is a Sched_context cpu-specific, too? This
> would not make sense to me as a Sched_context object stores
> thread-specific information such as the priority and the remaining
> quantum of a thread.

Generally, scheduling configuration is CPU specific.
However, in this case, the Sched_context is specific to the
Context/Thread, i.e. in this case a Context and Thread is the same
thing and each Thread has its Sched_context.




Adam
-- 
Adam                 adam at os.inf.tu-dresden.de
  Lackorzynski         http://os.inf.tu-dresden.de/~adam/




More information about the l4-hackers mailing list