当前位置:网站首页>Synchronization control between tasks
Synchronization control between tasks
2022-07-03 09:52:00 【0725 you Guangchuan】
Synchronization control between tasks
- vxWorks Semaphores provide inter task communication 、 Sync 、 And mutually exclusive optimal choice
1.1 Synchronization refers to the coordination of multiple tasks in the execution order , Make sure it doesn't
Now there are errors related to time , In this case, the semaphore represents the waiting event , Initially, semaphores are not available , A task or interrupt handler releases the semaphore to notify the occurrence of this event , Once unblocked , The task executes the corresponding event to handle the program , It should be noted that the state of the semaphore used for synchronization should initially be empty , A task first waits for the semaphore released by other tasks .
Insert a code chip here
The execution sequence between tasks is described as follows :
SEM_ID semSync;
semErrorSync=semBCreate(SEM_Q_FIFO,SEM_
EMPTY);/* Create a semaphore that displays alarm information */
semNewErrorSync=semBCreate(SEM _Q_FIFO,
SEM_EMPTY);/* Create a semaphore that displays new alarm information */
taskErrorCheck(void){
···/* First display the error message */
semGive(semErrorSync);
semGive(semNewErrorSync);
}
}
`taskErrorDispCircle(void){
`semTake(semErrorSync,WAIT_FOREVER);
semTake(semNewErrorSync,WAIT_FOREVER);
···;/* Cycle the display of alarm information */
}
because semErrorSync and semNewErrorSync Of first beginning value Unavailable , If the task taskErrorDispCircle() First execution will inevitably block , Only in the task taskErrorCheck() After execution semGive() After the operation , send 2 After semaphores are available , Mission taskErrorDispCircle() To execute .
`
边栏推荐
- Getting started with JMX, MBean, mxbean, mbeanserver
- How does the nr-prach receiver detect the relationship between prembleid and Ta
- Happy Dragon Boat Festival—— Zongzi written by canvas~~~~~
- Development of electrical fire system
- Electronic product design
- 【力扣刷题笔记(二)】特别技巧,模块突破,45道经典题目分类总结,在不断巩固中精进
- Implementing distributed lock with redis
- Shell logic case
- Leetcode daily question (1856. maximum subarray min product)
- Flink learning notes (VIII) multi stream conversion
猜你喜欢
Difference of EOF
[graduation successful] [1] - tour [Student Management Information System]
Development of fire power monitoring system
Nr-prach:prach format and time-frequency domain
How does the memory database give full play to the advantages of memory?
Flink learning notes (IX) status programming
Definition and use of enum in C language
Development of fire evacuation system
Solve editor MD uploads pictures and cannot get the picture address
STM32 serial port usart1 routine
随机推荐
Flink learning notes (IX) status programming
[CSDN]C1训练题解析_第二部分_Web基础
UCI and data multiplexing are transmitted on Pusch - Part I
万字手撕七大排序(代码+动图演示)
UCI and data multiplexing are transmitted on Pusch - placement of data and UCI positions (Part III)
MySQL 数据库基础知识(系统化一篇入门)
1300. sum of varied array closed to target
MySQL data manipulation language DML common commands
[22 graduation season] I'm a graduate yo~
Schematic diagram and connection method of six pin self-locking switch
How MySQL modifies null to not null
Fundamentals of Electronic Technology (III)_ Integrated operational amplifier and its application__ Basic arithmetic circuit
CEF下载,编译工程
UCI and data multiplexing are transmitted on Pusch (Part 4) --small block lengths
The number of weak characters in the game (1996)
对于新入行的同学,如果你完全没有接触单片机,建议51单片机入门
Leetcode daily question (516. long palindromic subsequence)
Epollet lessons
Stm32-hal library learning, using cubemx to generate program framework
Leetcode daily question (2212. maximum points in an archery competition)