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 what Event is in vxworks, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Event is an efficient inter-task synchronization mechanism, but it can also synchronize with some resources (semaphores and message queues). Use xxEvStart () to register the current task with the appropriate resource, and when the resource becomes valid and no other task is blocked on the resource, the system sends an Event to the registered task. Combined with the basic operation of Event, we can realize the synchronization of tasks and multiple resources at the same time.
/ * resource-related options * / # define EVENTS_OPTIONS_NONE 0x00#define EVENTS_SEND_ONCE 0x01 / * unregister events after eventSend * / # define EVENTS_ALLOW_OVERWRITE 0x02 / * can overwrite previous registration * / # define EVENTS_SEND_IF_FREE 0x04 / * send events in xxxEvStart () * /
STATUS semEvStart (SEM_ID semId, UINT32 events, UINT8 options); STATUS semEvStop (SEM_ID semId)
STATUS msgQEvStart (MSG_Q_ID msgQId, UINT32 events, UINT8 options); STATUS msgQEvStop (MSG_Q_ID msgQId)
Look at an example.
/ * Copyright 2020 VxWorks567 * / # include / * printf () * / # include / * eventReceive () * / # include / * semEvStart () * / # include / * msgQEvStart () * /
# define MSGS_NUM 5#define MSG_LEN 5
Static SEM_ID semId;static MSG_Q_ID msgQId
Void testEvent () {_ Vx_event_t eventsReceived
/ * use a binary semaphore to represent a resource * / semId = semBCreate (SEM_Q_FIFO, SEM_EMPTY); / * register the current task with the semaphore * / semEvStart (semId, VXEV01, EVENTS_OPTIONS_NONE)
/ * represent a resource with a message queue * / msgQId = msgQCreate (MSGS_NUM, MSG_LEN, MSG_Q_FIFO); / * register the current task with the message queue * / msgQEvStart (msgQId, VXEV02, EVENTS_OPTIONS_NONE)
While (1) {/ * when any resource is valid, it is processed * / eventReceive (VXEV01 | VXEV02, EVENTS_WAIT_ANY, WAIT_FOREVER, & eventsReceived); if (eventsReceived&VXEV01) {/ * semaphore is valid, and no other task application semaphore * / printf ("\ n\ tsemphore is free\ n") SemTake (semId, WAIT_FOREVER);} else if (eventsReceived&VXEV02) {/ * New message arrives and no other task reads message * / printf ("\ n\ tmsgQ is free\ n"); msgQReceive (msgQId, NULL, 0, WAIT_FOREVER);}
Void freeSem () {/ * release semaphore, indicating that the corresponding resource is valid * / semGive (semId);}
Void freeMsgQ () {/ * sends a message indicating that the corresponding resource is valid * / msgQSend (msgQId, 0,0,0,0);}
Execution effect
The above is all the content of this article "what is Event in vxworks?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.