In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you the example analysis of multitasking communication in VxWorks. I hope you will get something after reading this article. Let's discuss it together.
VxWorks is a typical multitasking operating system. These multiple tasks cannot be completely independent of each other, and they need some systematic mechanism to coordinate each other's actions. These mechanisms belong to multitasking communication, which can be divided into two categories: event notification and data transmission.
VxWorks system provides a variety of inter-task communication mechanisms: interrupt locks, task locks, multiple semaphores, message queues, pipes, VxWorks events (VxWorks Event), message channels. In addition, tasks in the same memory space (all in the kernel or in the same RTP) can be exchanged directly by accessing shared data structures. However, these shared resources are best protected by mutual exclusion mechanisms.
Interrupt lock-interrupts can be turned off to prevent ISR preemption. This is not a general mechanism. It must be used with caution.
Task lock-preemption of other tasks can be turned off. It is also not a general mechanism, so it should be used with caution.
Semaphore-the basic method of task synchronization and mutual exclusion. VxWorks provides four semaphores, as well as POSIX semaphores. Semaphores can also be created as common objects for interprocess communication
Message queuing-an advanced mechanism for passing messages (data) directly between tasks. It can also be created as a public object for interprocess communication
Pipeline-another message mechanism encapsulated on a message queue. It is operated by the standard Imap O function and select ().
VxWorks events-can be used for synchronization and communication between task-task, ISR- task, semaphore-task, message queue-task
Message channel-socket-based communication mechanism that can be used for inter-task, inter-process, inter-processor communication
There is also a signal (Signal) that can pass events between tasks and processes, although it is generally not used as a communication mechanism
Shared data structure
The most obvious way to communicate between tasks in the same memory space (all in the kernel or in the same RTP) is to access shared data structures because they use a single linear address space
Different tasks can directly access global variables, linear buffers, circular buffers, linked lists, and pointers. However, these shared data structures need to be protected by mutex mechanisms such as mutex semaphores.
Interrupt lock
The function intLock () turns off interrupts to prevent preemption of ISR. It can be called in either the task or the ISR. The function intUnLock () reenables interrupts. This pair of functions are usually used to protect the critical area.
When a task accesses data structures that ISR also accesses, intLock () is used to prevent preemption by ISR. Obviously, this operation should be as short as possible and do not even call any functions. Otherwise, it directly affects the interrupt delay and leads to the uncertainty of the system. If you also want to prevent preemption of tasks, use taskLock () at the same time
Warning: when using interrupt locks, calling system functions can cause interrupts to re-enable irregularly, such as blocking the called functions or activating high-priority tasks
Task lock
The function taskLock () turns off task preemption and only lets the current task execute unless the current task is blocked or suspended. When the task is unblocked and resumed, it once again forbids task preemption. The function taskUnlock () restores the preemption of other tasks. This pair of functions are also used to protect critical areas, but cannot be used in ISR
Task locks can be nested, and there are counters inside them, so only after the same number of taskUnlock () is called can the task be truly re-enabled.
Note: task locks may affect the system's real-time response time because it prevents the execution of high-priority tasks, and mutexes are usually a better choice. In addition, task locks do not prevent interrupts. If you want to prevent interrupt preemption at the same time, use intLock () at the same time
After reading this article, I believe you have some understanding of "sample Analysis of multitasking Communications in VxWorks". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.