The RTAI scheduler ensures that concurrent tasks are run according to one of the supported scheduling policies. Currently, the RTAI scheduler supports fixed priority-based FIFO and round-robin policies.
Files | |
file | task.c |
This file is part of the RTAI 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 (void) |
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. | |
int | rt_task_bind (RT_TASK *task, const char *name) |
Bind to a real-time task. | |
int | rt_task_unbind (RT_TASK *task) |
Unbind from 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 ubiquitous descriptor of a given RTAI 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. |
|
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.
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. 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. |
|
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. |
|
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. |
|
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. |
|
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. |
|
Change task mode bits. Each RTAI 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 RTAI enforces a scheduler lock until the outer interrupt handler has returned.
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 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. |
|
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.
|
|
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(). 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 an overrun has been detected. 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. |