l4_thread_schedule -- Define priority, timeslice length and external preempter of other threads.

1 Synopsis

#include <l4/sys/syscalls.h>

static inline volatile l4_cpu_time_t
l4_thread_schedule(l4_threadid_t dest , l4_sched_param_t param l4_threadid_t *ext_preempter , l4_threadid_t *partner , l4_sched_param_t *old_param );

2 Description

The l4_thread_schedule() system call can be used by schedulers to define priority, timeslice length and external preempter of other threads. Furthermore it delivers thread states.

The system call is only effective, if the current priority of the specified destination is less than or equal to the current task's maximum controlled priority (mcp).

3 Arguments

The identifier of the destination thread. The destination thread must currently exist and run on a priority level less than or equal to the current thread's mcp.
This word specifies scheduling parameters:

typedef struct {
  unsigned prio:8;
  unsigned small:8;
  unsigned zero:4;
  unsigned time_exp:4;
  unsigned time_man:8;
} l4_sched_param_struct_t;

typedef union {
  l4_umword_t sched_param;
  l4_sched_param_struct_t sp;
} l4_sched_param_t;

If 0xFFFFFFFF is given, the thread's current scheduling parameters are not modified.

Otherwise, the value contains the following parameters:

The thread's static system-wide priority. 255 is the highest and 0 the lowest priority.
The number and size of the small address space assigned to the thread, if any. All small address spaces have the same size. Once a thread get assigned a new size, all previous assignments automatically become invalid. Possible sizes are 2, 4, 8, ... 256 megabytes. Valid numbers are 1 .. (512/size_MB)-1.

Valid small address space specifiers can be built using the macro L4_SMALL_SPACE(size_MB, nr).

zero Reserved, must be zero.
time_man, time_exp Timeslice length, specified in timeout format (see l4_ipc ).
The id of the external preempter for the thread. If L4_INVALID_ID is given, the current external preempter of the thread is not changed.
Id of a partner of an active user-invoked ipc operation. This parameter is only valid, if the thread's user state is sending, receiving, pending or waiting. L4_INVALID_ID is delivered if there is no specific partner, i.e. if the thread is in an open receive state.
This value contains the old priority, timeslice length, state and priority of the destination thread. For an exact description of the format refer to the L4 Reference Manual.

If 0xFFFFFFFF is delivered, the addressed thread does either not exist or has a priority which exceeds the current thread's mcp.

4 Return Values

The returned 64 bit value contains the following information (beginning with most significant bit):

mw (8 bits), ew (4 bits)
Current user-level wakeup of the destination thread, encoded like a timeout. The value denotes the still remaining timeout intervall. Valid only if the user state is waiting or pending.
ep (4 bits)
Effective pagefault wakeup of the destination thread, encoded like a 4-bit pagefault timeout. The value denotes the still remaining timeout interval. Valid only if the kernel state is pager.
T (48 bits)
Cpu time in microseconds which has been consumed by the destination thread.

5 See Also

l4_thread_ex_regs , l4_myself , l4_nchief , l4_thread_switch , l4_fpage_unmap , l4_task_new