|
|||||||||||
Technical Support On-Line Manuals RL-ARM User's Guide (MDK v4) RL-RTX Overview Product Description Product Specification Technical Data Timing Specifications Advantages Your First RTX Application Theory of Operation Timer Tick Interrupt System Task Manager Task Management Idle Task System Resources Scheduling Options Pre-emptive Scheduling Round-Robin Scheduling Cooperative Multitasking Priority Inversion Stack Management User Timers Interrupt Functions Configuring RL-RTX Configuration Options Tasks Stack Size Stack Checking Run in Privileged Mode Hardware Timer Round-Robin Multitasking User Timers FIFO Queue Buffer Idle Task Error Function Create New RTX_Config.c Configuration Macros Alternate Tick Timer Low Power RTX Library Files Using RL-RTX Writing Programs Include Files Defining Tasks Multiple Instances External References Using a Mailbox SWI Functions SVC Functions Debugging System Info Task Info Event Viewer Usage Hints ARM7/ARM9 Version Cortex-M Version Create New RTX Application Function Reference Event Flag Management Routines Mailbox Management Routines Memory Allocation Routines Mutex Management Routines Semaphore Management Routines System Functions Task Management Routines Time Management Routines User Timer Management Routines RL-FlashFS RL-TCPnet RL-CAN RL-USB Example Programs Library Reference Appendix |
Pre-emptive SchedulingRTX is a pre-emptive multitasking operating system. If a task with a higher priority than the currently running task becomes ready to run, RTX suspends the currently running task. A preemptive task switch occurs when:
The following example demonstrates one of the task switching mechanisms. Task job1 has a higher priority than task job2. When job1 starts, it creates task job2 and then enters the os_evt_wait_or function. The RTX kernel suspends job1 at this point, and job2 starts executing. As soon as job2 sets an event flag for job1, the RTX kernel suspends job2 and then resumes job1. Task job1 then increments counter cnt1 and calls the os_evt_wait_or function, which suspends it again. The kernel resumes job2, which increments counter cnt2 and sets an event flag for job1. This process of task switching continues indefinitely. #include <rtl.h> OS_TID tsk1,tsk2; int cnt1,cnt2; __task void job1 (void); __task void job2 (void); __task void job1 (void) { os_tsk_prio (2); tsk1 = os_tsk_self (); os_tsk_create (job2, 1); while (1) { os_evt_wait_or (0x0001, 0xffff); cnt1++; } } __task void job2 (void) { while (1) { os_evt_set (0x0001, tsk1); cnt2++; } } void main (void) { os_sys_init (job1); while (1); } | ||||||||||
|
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.