L4Re - L4 Runtime Environment
L4::Scheduler Class Reference

C++ interface of the Scheduler kernel object. More...

+ Inheritance diagram for L4::Scheduler:
+ Collaboration diagram for L4::Scheduler:

Public Member Functions

l4_msgtag_t info (l4_umword_t *cpu_max, l4_sched_cpu_set_t *cpus, l4_utcb_t *utcb=l4_utcb()) const throw ()
 Get scheduler information. More...
 
l4_msgtag_t run_thread (Ipc::Cap< Thread > thread, l4_sched_param_t const &sp)
 Run a thread on a Scheduler. More...
 
l4_msgtag_t idle_time (l4_sched_cpu_set_t const &cpus, l4_kernel_clock_t *us)
 Query the idle time (in µs) of a CPU. More...
 
bool is_online (l4_umword_t cpu, l4_utcb_t *utcb=l4_utcb()) const throw ()
 Query if a CPU is online. More...
 
- Public Member Functions inherited from L4::Icu
l4_msgtag_t bind (unsigned irqnum, L4::Cap< Triggerable > irq, l4_utcb_t *utcb=l4_utcb()) throw ()
 Bind an interrupt line of an interrupt controller to an interrupt object. More...
 
l4_msgtag_t unbind (unsigned irqnum, L4::Cap< Triggerable > irq, l4_utcb_t *utcb=l4_utcb()) throw ()
 Remove binding of an interrupt line from the interrupt controller object. More...
 
l4_msgtag_t info (l4_icu_info_t *info, l4_utcb_t *utcb=l4_utcb()) throw ()
 Get information about the capabilities of the ICU. More...
 
l4_msgtag_t msi_info (l4_umword_t irqnum, l4_uint64_t source, l4_icu_msi_info_t *msi_info)
 Get MSI info about IRQ. More...
 
l4_msgtag_t mask (unsigned irqnum, l4_umword_t *label=0, l4_timeout_t to=L4_IPC_NEVER, l4_utcb_t *utcb=l4_utcb()) throw ()
 Mask an IRQ line. More...
 
l4_msgtag_t set_mode (unsigned irqnum, l4_umword_t mode, l4_utcb_t *utcb=l4_utcb()) throw ()
 Set interrupt mode. More...
 
- Public Member Functions inherited from L4::Irq_eoi
l4_msgtag_t unmask (unsigned irqnum, l4_umword_t *label=0, l4_timeout_t to=L4_IPC_NEVER, l4_utcb_t *utcb=l4_utcb()) throw ()
 Acknowledge the given interrupt line. More...
 

Additional Inherited Members

- Protected Types inherited from L4::Kobject_t< Scheduler, Icu, L4_PROTO_SCHEDULER, Type_info::Demand_t< 1 > >
typedef Scheduler Class
 The target interface type (inheriting from Kobject_t)
 
typedef Typeid::Iface< PROTO, Scheduler__Iface
 The interface description for the derived class.
 
typedef Typeid::Merge_list< Typeid::Iface_list< __Iface >, typename Icu ::__Iface_list > __Iface_list
 The list of all RPC interfaces provided directly or through inheritance.
 
- Protected Types inherited from L4::Kobject_t< Icu, Irq_eoi, L4_PROTO_IRQ, Type_info::Demand_t< 1 > >
typedef Icu Class
 The target interface type (inheriting from Kobject_t)
 
typedef Typeid::Iface< PROTO, Icu__Iface
 The interface description for the derived class.
 
typedef Typeid::Merge_list< Typeid::Iface_list< __Iface >, typename Irq_eoi ::__Iface_list > __Iface_list
 The list of all RPC interfaces provided directly or through inheritance.
 
- Protected Member Functions inherited from L4::Kobject_t< Scheduler, Icu, L4_PROTO_SCHEDULER, Type_info::Demand_t< 1 > >
L4::Cap< Classc () const
 Get the capability to ourselves.
 
- Protected Member Functions inherited from L4::Kobject_t< Icu, Irq_eoi, L4_PROTO_IRQ, Type_info::Demand_t< 1 > >
L4::Cap< Classc () const
 Get the capability to ourselves.
 
- Static Protected Member Functions inherited from L4::Kobject_t< Scheduler, Icu, L4_PROTO_SCHEDULER, Type_info::Demand_t< 1 > >
static void __check_protocols__ ()
 Helper to check for protocol conflicts.
 
- Static Protected Member Functions inherited from L4::Kobject_t< Icu, Irq_eoi, L4_PROTO_IRQ, Type_info::Demand_t< 1 > >
static void __check_protocols__ ()
 Helper to check for protocol conflicts.
 

Detailed Description

C++ interface of the Scheduler kernel object.

The Scheduler interface allows a client to manage CPU resources. The API provides functions to query scheduler information, check the online state of CPUs, query CPU idle time and to start threads on defined CPU sets.

Include File
#include <l4/sys/scheduler>

Definition at line 42 of file scheduler.

Member Function Documentation

◆ idle_time()

l4_msgtag_t L4::Scheduler::idle_time ( l4_sched_cpu_set_t const &  cpus,
l4_kernel_clock_t us 
)

Query the idle time (in µs) of a CPU.

Parameters
cpusSet of CPUs to query. Only the idle time of the first selected CPU in cpus.map is queried.
[out]usIdle time of queried CPU in µs.
Return values
0Success.
-L4_EINVALInvalid CPU requested in cpu set.

This function retrieves the idle time in µs of the first selected CPU in cpus.map. The idle time is the accumulated time a CPU has spent in the idle thread since its last reset. To calculate a load estimate l one has to retrieve the idle time at the beginning (i1) and the end (i2) of a known time interval t. The load is then calculated as l = 1 - (i2 - i1)/t.

The idle time is only defined for online CPUs. Reading the idle time from offline CPUs is undefined and may result in either getting -L4_EINVAL or calculating an estimated (incorrect) load of 1.

Note
The idle time statistics of remote CPUs is updated on context switch events only, hence may not be up-to-date when requested cross-CPU. To get up-to-date idle time you should use a thread running on the same CPU of which the idle time is requested.

◆ info()

l4_msgtag_t L4::Scheduler::info ( l4_umword_t cpu_max,
l4_sched_cpu_set_t cpus,
l4_utcb_t utcb = l4_utcb() 
) const
throw (
)
inline

Get scheduler information.

Parameters
[out]cpu_maxMaximum number of CPUs ever available.
[in,out]cpuscpus.offset is first CPU of interest. cpus.granularity (see l4_sched_cpu_set_t). cpus.map Bitmap of online CPUs.
utcbUTCB pointer of the calling thread. This defaults to the UTCB of the current thread.
Return values
0Success.
-L4_ERANGEThe given CPU offset is larger than the maximum number of CPUs.

Definition at line 66 of file scheduler.

◆ is_online()

bool L4::Scheduler::is_online ( l4_umword_t  cpu,
l4_utcb_t utcb = l4_utcb() 
) const
throw (
)
inline

Query if a CPU is online.

Parameters
cpuCPU number whose online status should be queried.
utcbUTCB pointer of the calling thread. Defaults to l4_utcb().
Return values
trueThe CPU is online.
falseThe CPU is offline

Definition at line 139 of file scheduler.

◆ run_thread()

l4_msgtag_t L4::Scheduler::run_thread ( Ipc::Cap< Thread thread,
l4_sched_param_t const &  sp 
)

Run a thread on a Scheduler.

Parameters
threadCapability of the thread to run.
spScheduling parameters.
Return values
0Success.
-L4_EINVALInvalid size of the scheduling parameter.

This function launches a thread on a CPU determined by the scheduling parameter sp.affinity. A thread can be intentionally stopped by migrating it on an offline or an invalid CPU. The thread is only guaranteed to run if the CPU it is migrated to is currently online.

Note
A scheduler may impose a policy with regard to selecting CPUs. However the scheduler is required to ensure the following two properties:
  • Two threads with disjoint CPU sets must be scheduled to different physical CPUs.
  • Two threads with a single identical CPU selected in the CPU set must be scheduled to the same physical CPU.

The documentation for this class was generated from the following file: