The Xenomai scheduler ensures that concurrent tasks are run according to one of the supported scheduling policies. Currently, the Xenomai scheduler supports fixed priority-based FIFO and round-robin policies.
Files | |
file | task.c |
This file is part of the Xenomai project. | |
Functions | |
int | rt_task_create (RT_TASK *task, const char *name, int stksize, int prio, int mode) |
Create a new real-time task. | |
int | rt_task_start (RT_TASK *task, void(*entry)(void *cookie), void *cookie) |
Start a real-time task. | |
int | rt_task_suspend (RT_TASK *task) |
Suspend a real-time task. | |
int | rt_task_resume (RT_TASK *task) |
Resume a real-time task. | |
int | rt_task_delete (RT_TASK *task) |
Delete a real-time task. | |
int | rt_task_yield (void) |
Manual round-robin. | |
int | rt_task_set_periodic (RT_TASK *task, RTIME idate, RTIME period) |
Make a real-time task periodic. | |
int | rt_task_wait_period (unsigned long *overruns_r) |
Wait for the next periodic release point. | |
int | rt_task_set_priority (RT_TASK *task, int prio) |
Change the base priority of a real-time task. | |
int | rt_task_sleep (RTIME delay) |
Delay the calling task (relative). | |
int | rt_task_sleep_until (RTIME date) |
Delay the calling task (absolute). | |
int | rt_task_unblock (RT_TASK *task) |
Unblock a real-time task. | |
int | rt_task_inquire (RT_TASK *task, RT_TASK_INFO *info) |
Inquire about a real-time task. | |
int | rt_task_add_hook (int type, void(*routine)(void *cookie)) |
Install a task hook. | |
int | rt_task_remove_hook (int type, void(*routine)(void *cookie)) |
Remove a task hook. | |
int | rt_task_catch (void(*handler)(rt_sigset_t)) |
Install a signal handler. | |
int | rt_task_notify (RT_TASK *task, rt_sigset_t signals) |
Send signals to a task. | |
int | rt_task_set_mode (int clrmask, int setmask, int *mode_r) |
Change task mode bits. | |
RT_TASK * | rt_task_self (void) |
Retrieve the current task. | |
int | rt_task_slice (RT_TASK *task, RTIME quantum) |
Set a task's round-robin quantum. | |
ssize_t | rt_task_send (RT_TASK *task, RT_TASK_MCB *mcb_s, RT_TASK_MCB *mcb_r, RTIME timeout) |
Send a message to a task. | |
int | rt_task_receive (RT_TASK_MCB *mcb_r, RTIME timeout) |
Receive a message from a task. | |
int | rt_task_reply (int flowid, RT_TASK_MCB *mcb_s) |
Reply to a task. | |
static int | rt_task_spawn (RT_TASK *task, const char *name, int stksize, int prio, int mode, void(*entry)(void *cookie), void *cookie) |
Spawn a new real-time task. | |
int | rt_task_shadow (RT_TASK *task, const char *name, int prio, int mode) |
Turns the current Linux task into a native Xenomai task. | |
int | rt_task_bind (RT_TASK *task, const char *name, RTIME timeout) |
Bind to a real-time task. | |
static int | rt_task_unbind (RT_TASK *task) |
Unbind from a real-time task. | |
int | rt_task_join (RT_TASK *task) |
Wait on the termination of a real-time task. |
|
Install a task hook. The real-time kernel allows to register user-defined routines which get called whenever a specific scheduling event occurs. Multiple hooks can be chained for a single event type, and get called on a FIFO basis. The scheduling is locked while a hook is executing.
Environments: This service can be called from:
Rescheduling: never. |
|
Bind to a real-time task. This user-space only service retrieves the uniform descriptor of a given Xenomai task identified by its symbolic name. If the task does not exist on entry, this service blocks the caller until a task of the given name is created.
Environments: This service can be called from:
Rescheduling: always unless the request is immediately satisfied or timeout specifies a non-blocking operation.
|
|
Install a signal handler. This service installs a signal handler for the current task. Signals are discrete events tasks can receive each time they resume execution. When signals are pending upon resumption, handler is fired to process them. Signals can be sent using rt_task_notify(). A task can block the signal delivery by passing the T_NOSIG bit to rt_task_set_mode(). Calling this service implicitely unblocks the signal delivery for the caller.
Environments: This service can be called from:
Rescheduling: possible. |
|
Create a new real-time task. Creates a real-time task, either running in a kernel module or in user-space depending on the caller's context.
Passing T_FPU|T_CPU(1) in the mode parameter thus creates a task with FPU support enabled and which will be affine to CPU #1.
Environments: This service can be called from:
Rescheduling: possible. |
|
Delete a real-time task. Terminate a task and release all the real-time kernel resources it currently holds. A task exists in the system since rt_task_create() has been called to create it, so this service must be called in order to destroy it afterwards. Native tasks implement a mechanism by which they are immune from deletion by other tasks while they run into a deemed safe section of code. This feature is used internally by the native skin in order to prevent tasks from being deleted in the middle of a critical section, without resorting to interrupt masking when the latter is not an option. For this reason, the caller of rt_task_delete() might be blocked and a rescheduling take place, waiting for the target task to exit such critical section. The DELETE hooks are called on behalf of the calling context (if any). The information stored in the task control block remains valid until all hooks have been called.
Environments: This service can be called from:
Rescheduling: always if task is NULL, and possible if the deleted task is currently running into a safe section. |
|
Inquire about a real-time task. Return various information about the status of a given task.
Environments: This service can be called from:
Rescheduling: never. |
|
Wait on the termination of a real-time task. This user-space only service blocks the caller in non-real-time context until task has terminated. Note that the specified task must have been created with the T_JOINABLE mode flag set.
This service can be called from:
Rescheduling: always unless the task was already terminated. |
|
Send signals to a task. This service sends a set of signals to a given task. A task can install a signal handler using the rt_task_catch() service to process them.
Environments: This service can be called from:
Rescheduling: possible. |
|
Receive a message from a task. This service is part of the synchronous message passing support available to Xenomai tasks. It allows the caller to receive a variable-sized message sent from another task using the rt_task_send() service. The sending task is blocked until the caller invokes rt_task_reply() to finish the transaction. A basic message control block is used to store the location and size of the data area to receive from the client, in addition to a user-defined operation code.
Upon return, mcb_r->opcode will contain the operation code sent from the remote task using rt_task_send().
Environments: This service can be called from:
Rescheduling: Always.
|
|
Remove a task hook. This service allows to remove a task hook previously registered using rt_task_add_hook().
Environments: This service can be called from:
Rescheduling: never. |
|
Reply to a task. This service is part of the synchronous message passing support available to Xenomai tasks. It allows the caller to send back a variable-sized message to the client task, once the initial message from this task has been pulled using rt_task_receive() and processed. As a consequence of this call, the remote task will be unblocked from the rt_task_send() service. A basic message control block is used to store the location and size of the data area to send back, in addition to a user-defined status code.
Environments: This service can be called from:
Rescheduling: Always.
|
|
Resume a real-time task. Forcibly resume the execution of a task which has been previously suspended by a call to rt_task_suspend(). The suspension nesting count is decremented so that rt_task_resume() will only resume the task if this count falls down to zero as a result of the current invocation.
Environments: This service can be called from:
Rescheduling: possible if the suspension nesting level falls down to zero as a result of the current invocation. |
|
Retrieve the current task. Return the current task descriptor address.
This service can be called from:
Rescheduling: never. |
|
Send a message to a task. This service is part of the synchronous message passing support available to Xenomai tasks. It allows the caller to send a variable-sized message to another task, waiting for the remote to receive the initial message by a call to rt_task_receive(), then reply to it using rt_task_reply(). A basic message control block is used to store the location and size of the data area to send or retrieve upon reply, in addition to a user-defined operation code.
Upon return, mcb_r->opcode will contain the status code sent back from the remote task using rt_task_reply(), or 0 if unspecified.
Environments: This service can be called from:
Rescheduling: Always.
|
|
Change task mode bits. Each Xenomai task has a set of internal bits determining various operating conditions; the rt_task_set_mode() service allows to alter three of them, respectively controlling:
To this end, rt_task_set_mode() takes a bitmask of mode bits to clear for disabling the corresponding modes, and another one to set for enabling them. The mode bits which were previously in effect can be returned upon request. The following bits can be part of the bitmask:
Normally, this service can only be called on behalf of a regular real-time task, either running in kernel or user-space. However, as a special exception, requests for setting/clearing the T_LOCK bit from asynchronous contexts are silently dropped, and the call returns successfully if no other mode bits have been specified. This is consistent with the fact that Xenomai enforces a scheduler lock until the outer interrupt handler has returned.
Environments: This service can be called from:
Rescheduling: possible, if T_LOCK has been passed into clrmask and the calling context is a task. |
|
Make a real-time task periodic. Make a task periodic by programing its first release point and its period in the processor time line. Subsequent calls to rt_task_wait_period() will delay the task until the next periodic release point in the processor timeline is reached.
Environments: This service can be called from:
Rescheduling: always if the operation affects the current task and idate has not elapsed yet.
|
|
Change the base priority of a real-time task. Changing the base priority of a task does not affect the priority boost the target task might have obtained as a consequence of a previous priority inheritance.
Side-effects:
Environments: This service can be called from:
Rescheduling: possible if task is the current one. |
|
Turns the current Linux task into a native Xenomai task. Creates a real-time task running in the context of the calling regular Linux task in user-space.
Passing T_CPU(0)|T_CPU(1) in the mode parameter thus defines a task affine to CPUs #0 and #1.
Environments: This service can be called from:
Rescheduling: possible. |
|
Delay the calling task (relative). Delay the execution of the calling task for a number of internal clock ticks.
Environments: This service can be called from:
Rescheduling: always unless a null delay is given.
|
|
Delay the calling task (absolute). Delay the execution of the calling task until a given date is reached.
Environments: This service can be called from:
Rescheduling: always unless a date in the past is given.
|
|
Set a task's round-robin quantum. Set the time credit allotted to a task undergoing the round-robin scheduling. As a side-effect, rt_task_slice() refills the current quantum of the target task.
Environments: This service can be called from:
Rescheduling: never.
|
|
Spawn a new real-time task. Creates and immediately starts a real-time task, either running in a kernel module or in user-space depending on the caller's context. This service is a simple shorthand for rt_task_create() followed by a call to rt_task_start().
Passing T_FPU|T_CPU(1) in the mode parameter thus creates a task with FPU support enabled and which will be affine to CPU #1.
Environments: This service can be called from:
Rescheduling: possible. |
|
Start a real-time task. Start a (newly) created task, scheduling it for the first time. This call releases the target task from the dormant state. The TSTART hooks are called on behalf of the calling context (if any, see rt_task_add_hook()).
Environments: This service can be called from:
Rescheduling: possible. |
|
Suspend a real-time task. Forcibly suspend the execution of a task. This task will not be eligible for scheduling until it is explicitly resumed by a call to rt_task_resume(). In other words, the suspended state caused by a call to rt_task_suspend() is cumulative with respect to the delayed and blocked states caused by other services, and is managed separately from them. A nesting count is maintained so that rt_task_suspend() and rt_task_resume() must be used in pairs.
Environments: This service can be called from:
Rescheduling: always if task is NULL. |
|
Unbind from a real-time task. This user-space only service unbinds the calling task from the task object previously retrieved by a call to rt_task_bind().
Rescheduling: never. |
|
Unblock a real-time task. Break the task out of any wait it is currently in. This call clears all delay and/or resource wait condition for the target task. However, rt_task_unblock() does not resume a task which has been forcibly suspended by a previous call to rt_task_suspend(). If all suspensive conditions are gone, the task becomes eligible anew for scheduling.
Environments: This service can be called from:
Rescheduling: possible. |
|
Wait for the next periodic release point. Make the current task wait for the next periodic release point in the processor time line.
Environments: This service can be called from:
Rescheduling: always, unless the current release point has already been reached. In the latter case, the current task immediately returns from this service without being delayed. |
|
Manual round-robin. Move the current task to the end of its priority group, so that the next equal-priority task in ready state is switched in.
Environments: This service can be called from:
Rescheduling: always if a next equal-priority task is ready to run, otherwise, this service leads to a no-op. |