Download RTAI user manual
Transcript
Chapter 5 RTAI schedulers This function and the next two ones deal with the priority of a task. The priority values are defined in the include file base\include\rtai_sched.h as follow: #define #define #define RT_SCHED_HIGHEST_PRIORITY RT_SCHED_LOWEST_PRIORITY RT_SCHED_LINUX_PRIORITY 0 0x3fffFfff 0x7fffFfff Note that tasks with higher priority (lower values) are executed before and cannot be interrupted by tasks with lower priority (higher values). int rt_get_inher_prio (RT_TASK *task) This function checks the actual priority of a task. It returns the base priority task task has inherited from other tasks, either blocked on resources owned by or waiting to pass a message to task task. Parameters: task is the affected task. Returns: rt_get_inher_prio returns the priority of task task. There is also a function that returns all the priorities in just one call; this API is: int rt_get_priorities(RT_TASK *task, int *priority, int *base_priority) int rt_change_prio(RT_TASK *task,int priority) With this function it is possible to change the base priority of a given task task. Recall that a task has a base native priority, assigned at its birth and an actual, inherited, priority. They can be different because of priority inheritance. Parameters: task is the affected task. priority is the new priority, the range it 0<priority< RT_SCHED_LOWEST_PRIORITY. Returns: rt_change_prio returns the base priority that the task task had before the change. Note: Changing the priority of a task from a different one implies a propagation if the receiving task is locked on a resource. This means that the change must be executed in the right place and in the right time to achieve the maximum efficiency. RT_TASK* rt_whoami(void) This functions can be used to obtain a pointer of the current task. The return value is the structure of the calling task. The structure is defined in the base\include\rtai_sched.h include file and contains all the data relative to a single task. Returns: The pointer to the current task. A typical use of this function could be: rt_task_delete(rt_whoami()); or task=rt_whoami(); where task is defined as RT_TASK *task; RTAI User Manual 3.4 – October 2006 – rev 0.3 - pag 21