ARM RTX Operating system-theory of Operation-system Task Manager & Task Management

Source: Internet
Author: User
Tags semaphore switches

System Task Manager

Task Manager is a system task process that runs every time a timer tick interrupt occurs in the RTX kernel clock, that is, every time the RTX core clock is interrupted. This process has the highest priority and is not replaced by other processes. The basic task of this process is to be responsible for scheduling the user's task process.

The user task process based on the RTX kernel is not really running at the same time, they are running in time-sliced. Available CPU timer, will be cut into a very small time slice. The RTX kernel assigns a time slice to a task process. Because a time slice is short (the default time slice is 10ms), it looks like the task process is running synchronously.

The minimum length of time per task process execution is the length of a time slice. If the task process has surrendered a time slice by calling Os_tsk_pass or called an API function in the wait library, the RTX kernel switches to the next ready process to run. You can rtx_config. C To configure the time slice length.

Task Manager, a system tick timer task process that is responsible for managing all other task processes. It manages the delay time-out of the process, placing the waiting process in the sleep state. When the desired event occurs, it will re-place the corresponding process into the read state to run. That's why it has the highest priority.

Task Manager runs not only when the RTX kernel clock is interrupted, but also when an interrupt function calls the isr_ function. This is because the interrupt does not allow the current task process to wait, because the interrupt does not work as a task process switch. Interrupts can then generate events, semaphores, and messages to high-priority tasks. A high-priority task will preempt the current task after the current outage is complete.

To do this, the current interrupt will force the RTX kernel clock to break at the time it will be completed. This forced generation of the RTX kernel clock interrupts and causes the Task Manager to start running. This allows the task Manager to start processing all the task processes and place the high-priority task process in running state. The last high-priority task process runs.

Attention:

The task management process, also called the System tick Timer task process, is a process that is automatically created by the system.

The RTX Library of the CORTEX-M processor uses the enhanced features of the series processing, all of the RTX system functions running in SVC mode.

Task Management

Each RTX task process must be in one of the following deterministic states:

1,running

The task process being running is in this state. There will only be one process in this state at a time. os_tsk_self () can return the task process ID that is currently running.

2,ready

The task process, which is ready to run, is not running yet and is in readiness. When a task process in running state finishes running, the RTX kernel will pick the highest priority from the task process in the ready status to run.

3, wait_dly

A task process that waits for a delay time to end in this state. When the delay is over, the task process switches to the ready state. The task process calls the os_dly_wait () function and can be in the wait_dly state.

4,wait_itv

Wait for a interval to complete the task process, in this state. When a interval is delayed, the task process switches to the ready state. The task process calls the os_itv_wait () function and can be in the Wait_itv state.

5,wait_or

Wait for at least one event flag bit to be set for the task process, in this state. When the awaited event occurs, the task process switches to the Ready state. The task process calls the os_evt_wait_or () function and can be in the wait_or state.

6, Wait_and

Waits for all event identifiers to be placed on the task process, in this state. When all the waiting events have occurred, the task process switches to the Ready state. The task process calls the Os_evt_wait_and () function and can be in the Wait_and state.

7, Wait_sem

A task process that waits for a semaphore is in this state. When token is returned to Semaphore, the task process switches to the ready state. The task process calls the os_sem_wait () function and can be in the Wait_sem state.

8, Wait_mut

A task process that waits for a mutex is in this state. When the mutex is freed, the task process obtains the mutex and switches to the ready state . The task process calls the os_mut_wait () function and can be in the Wait_mut state.

9, wait_mbx

Waits for a task process to receive a message from mailbox, in this state. When a message arrives, the task process switches to the ready state. The task process calls the os_mbx_wait () function and can be in the wait_mbx state.

When the mailbox is full, the task process that needs to send the message waits and is placed in the wait_mbx state. Knowing that there are 1 messages removed from mailbox, the task process switches to the ready state . In this case, the task process calls os_mbx_send (), which causes the process to be in the wait_mbx state.

Ten, Inactiv

A task process that is not started, or a task process that is logged off is in this state. Calling Os_tsk_create ()initiates a task process, which can be Inactiv by calling Os_tsk_delete () .

Idle Task

The RTX kernel executes the idle task process Os_idle_demonwhen no task process is ready to run. The process is an infinite loop, for example:

 for (;;);
Some ARM processors provide an idle mode to conserve power consumption. When the processor is in idle mode, program will be stopped, except for interrupts and peripherals.

The Os_idle_demon is created by the system and runs when there are no other task processes, at which point the RTX kernel sets the processor into idle mode. When the RTX kernel clock is interrupted or other interrupts occur, the processor wakes up and the program continues to run.

Users can create their own program code in Os_idle_demon .

ARM RTX Operating system-theory of Operation-system Task Manager & Task Management

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.