C interface of the Scheduler kernel object.
More...
|
l4_sched_cpu_set_t | l4_sched_cpu_set (l4_umword_t offset, unsigned char granularity, l4_umword_t map=1) L4_NOTHROW |
|
l4_msgtag_t | l4_scheduler_info (l4_cap_idx_t scheduler, l4_umword_t *cpu_max, l4_sched_cpu_set_t *cpus) L4_NOTHROW |
| Get scheduler information. More...
|
|
l4_sched_param_t | l4_sched_param (unsigned prio, l4_cpu_time_t quantum=0) L4_NOTHROW |
| Construct scheduler parameter.
|
|
l4_msgtag_t | l4_scheduler_run_thread (l4_cap_idx_t scheduler, l4_cap_idx_t thread, l4_sched_param_t const *sp) L4_NOTHROW |
| Run a thread on a Scheduler. More...
|
|
l4_msgtag_t | l4_scheduler_idle_time (l4_cap_idx_t scheduler, l4_sched_cpu_set_t const *cpus, l4_kernel_clock_t *us) L4_NOTHROW |
| Query the idle time (in µs) of a CPU. More...
|
|
int | l4_scheduler_is_online (l4_cap_idx_t scheduler, l4_umword_t cpu) L4_NOTHROW |
| Query if a CPU is online. More...
|
|
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
-
◆ L4_scheduler_ops
Operations on the Scheduler object.
Enumerator |
---|
L4_SCHEDULER_INFO_OP | Query infos about the scheduler.
|
L4_SCHEDULER_RUN_THREAD_OP | Run a thread on this scheduler.
|
L4_SCHEDULER_IDLE_TIME_OP | Query idle time for the scheduler.
|
Definition at line 201 of file scheduler.h.
◆ l4_sched_cpu_set()
◆ l4_scheduler_idle_time()
Query the idle time (in µs) of a CPU.
- Parameters
-
| scheduler | Scheduler object. |
| cpus | Set of CPUs to query. Only the idle time of the first selected CPU in cpus.map is queried. |
[out] | us | Idle time of queried CPU in µs. |
- Return values
-
0 | Success. |
-L4_EINVAL | Invalid 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.
Definition at line 323 of file scheduler.h.
◆ l4_scheduler_info()
Get scheduler information.
- Parameters
-
| scheduler | Scheduler object. |
[out] | cpu_max | Maximum number of CPUs ever available. |
[in,out] | cpus | cpus.offset is first CPU of interest. cpus.granularity (see l4_sched_cpu_set_t). cpus.map Bitmap of online CPUs. |
- Return values
-
0 | Success. |
-L4_EINVAL | The given CPU offset is larger than the maximum number of CPUs. |
Definition at line 309 of file scheduler.h.
◆ l4_scheduler_is_online()
Query if a CPU is online.
- Parameters
-
scheduler | Scheduler object. |
cpu | CPU number whose online status should be queried. |
- Return values
-
true | The CPU is online. |
false | The CPU is offline |
Definition at line 330 of file scheduler.h.
◆ l4_scheduler_run_thread()
Run a thread on a Scheduler.
- Parameters
-
scheduler | Scheduler object. |
thread | Capability of the thread to run. |
sp | Scheduling parameters. |
- Return values
-
0 | Success. |
-L4_EINVAL | Invalid 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.
- Examples
- examples/sys/aliens/main.c, examples/sys/singlestep/main.c, examples/sys/start-with-exc/main.c, and examples/sys/utcb-ipc/main.c.
Definition at line 316 of file scheduler.h.