当前位置:网站首页>Cub school learning - Kernel Development
Cub school learning - Kernel Development
2022-07-24 10:50:00 【51CTO】
One task management
Basic concepts
1、 From a systematic point of view , The task is to compete for the smallest running unit of system resources . Tasks can be used or wait CPU、 Use system resources such as memory space , And alone Run on other tasks .
2、LiteOS The task module can provide users with multiple tasks , It realizes the switching and communication between tasks , Help users manage business process . So the user You can put more energy into the implementation of business functions .
3、LiteOS The task in is preemptive scheduling mechanism , High priority tasks can interrupt low priority tasks , Low priority tasks must be blocked or blocked by high priority tasks You can't get scheduling until it's over , At the same time, it supports time slice rotation scheduling .
4、LiteOS The default tasks are 32 Priority (0-31), The highest priority is 0, The lowest priority is 31
Task status
be ready : The task is on the ready list , Just wait CPU.
function : The task is in progress .
Blocking : The task is not on the ready list . Include task is suspended 、 The task is delayed 、 The task is waiting for semaphores 、 Read / write queues or wait for write continuation events .
Exit state : The task is finished , Wait for the system to recycle resources .
Other concepts related to the task
Mission ID: It is returned to the user through parameters when the task is created , As a very important indicator of the task
Task priority : Priority indicates the priority of task execution .
Task entry function : Function to be executed after each new task is scheduled .
Task control block TCB: Each task contains a task control block (TCB).TCB Contains task context stack pointer (stack pointer) 、 Task status 、 Task priority 、 Mission ID、 Task name 、 Task stack size and other information .TCB It can reflect the operation of each task .
Task stack : Each task has an independent stack space , We call it the task stack .
Task context : Some resources used in the running process of the task , Such as register, etc , We call it task context .LiteOS When the task is suspended, Ben The task of the task . Context information , Save it in your own task stack , So that when the mission resumes , Recover the suspended context information from the stack space , So as to continue to implement Code that is broken when a line is suspended .
Task switching : Task switching includes getting the highest priority task in the ready list 、 Cut out the task context to save 、 Cut in task context recovery and other actions .
Task mobilization mechanism
Description of task status migration :
The ready state → Running state : After the task is created, it enters ready state , When task switching occurs , The highest priority task in the ready list is executed , So as to enter into operation state , But the task is still on the ready list .
Running state → Blocking state : Task run suspended due to 、 Read semaphore, wait, etc , Deleted from the ready list and blocked .
Blocking state → The ready state ( Blocking state → Running state ) : When blocked tasks are restored ( Mission recovery 、 Delay time out 、 Read semaphore timeout or read semaphore, etc ), The recovered tasks will be added to the ready list , Thus, the blocking state becomes ready state ; At this time, if the priority of the recovered task is higher than that of the running task level , Task switching will occur , Change the task from ready state to running state .
The ready state → Blocking state : The task may also be blocked in the ready state ( Hang up ).
Running state → The ready state : After a higher priority task is created or restored , Enter the ready list after task switching .
Running state → Exit state : End of task operation , The kernel automatically removes this task , At this time, it changes from running state to exit state .
Blocking state → Exit state : Blocked task call delete interface , The task state changes from blocking state to exit state .

边栏推荐
- Real time weather API
- MySQL - 删除数据库表中的数据
- I admire a Google boss very much, and he left..
- Golang Li Kou leetcode 494. goals and
- [class, abstraction and inheritance]
- 【微服务】Eureka+Ribbon实现注册中心与负载均衡
- MySQL - 索引的隐藏和删除
- binlog、iptables防止nmap扫描、xtrabackup全量+增量备份以及redlog和binlog两者的关系
- 变频器的工作原理和功能应用
- binlog、iptables防止nmap扫描、xtrabackup全量+增量备份以及redlog和binlog两者的关系
猜你喜欢

机器学习小试(11)验证码识别测试-使用Qt与Tensorflow2进行深度学习实验

Sentinel implements the persistence of pull pattern rules

How to build a node development environment efficiently
![[FPGA]: IP core --divider (divider)](/img/bc/d8b7638e236c468ba23c8afc7ab70e.png)
[FPGA]: IP core --divider (divider)

QT application prevents multiple opening, that is, single instance operation

Hash, bitmap and bloom filter for mass data De duplication

【微服务】Eureka+Ribbon实现注册中心与负载均衡

零基础学习CANoe Panel(9)—— 组合框(ComboBox)

机器学习小试(10)使用Qt与Tensorflow创建CNN/FNN测试环境

MySQL - multi column index
随机推荐
MySQL - normal index
二叉树基础知识概览
Zero basic learning canoe panel (7) -- file selection (pathdiaglog)
《nlp入门+实战:第二章:pytorch的入门使用 》
机器学习小试(11)验证码识别测试-使用Qt与Tensorflow2进行深度学习实验
零基础学习CANoe Panel(7)—— 文件选择(PathDiaglog)
Partition data 1
Rtklib source code, RTK difference calculation, rtkpos and replos function process sorting
变频器的四大组成部分和工作原理
web咸鱼自救攻略--typescript的类没有你想象中的那么难
JS function call download file link
简单使用 MySQL 索引
Overview of basic knowledge of binary tree
Binlog and iptables prevent nmap scanning, xtrabackup full + incremental backup, and the relationship between redlog and binlog
5个最佳WordPress广告插件
Scope usage in POM file dependency
Partition data 2
Zero basic learning canoe panel (6) -- switch/indicator
零基础学习CANoe Panel(4)——按钮(Button )
Daily three questions 7.21