In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to read and write semaphores in Task in vxworks. I hope you will get something after reading this article. Let's discuss it together.
If multiple tasks operate on the same resource, it is best to use mutex semaphores for protection. What if these tasks are just performing reads? There is no need to serialize them all, especially in today's multi-core world. Therefore, Fenghe introduced a new mechanism-read-write semaphores (read/write semaphore) from Vx6, but this mechanism was not complete until Vx69.
The value of parameter options is basically the same as that of mutex semaphore. Therefore, the characteristics of read-write semaphores are very similar to mutex semaphores, such as
Can only be released by the holder.
Cannot operate in ISR
SemFlush () is not supported
The parameter maxReaders indicates how many readers can hold the semaphore at the same time, with values ranging from 1 to SEM_RW_MAX_CONCURRENT_READERS. This is its main difference: application patterns are classified as reading and writing.
When the semaphore is valid, either the reader or the writer can successfully apply.
When the semaphore is occupied by the reader, the new reader can successfully apply if the new reader does not exceed the maxReaders; the reader who exceeds the maxReaders, or the writer, will block
When the semaphore is occupied by the writer, new applicants will block
When releasing the semaphore, priority is given to unblocking the writer.
When the semaphore is occupied by the reader but blocked by the writer, the new reader will also block, regardless of whether it exceeds the maxReaders or not
It's a little more complicated than the previous semaphore. Write an example and you'll know what's going on.
After reading this article, I believe you have a certain understanding of "how to read and write semaphores 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.