Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Implementation principle of SylixOS event set

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

1 introduction to event set

Event set is a way of communication between threads, which can effectively deal with the synchronization of resource production and consumption between threads. In SylixOS, an event set is defined as a ULONG type, and each bit represents an event, that is, an event set can handle 32 different events. The event set provides the API for sending and waiting for events. The resource producer sends the event when the resource is ready, and the resource consumer waits to receive the event, as shown in figure 1.1.

Figure 1.1 event set

2 event set data structure

There are two main data structures related to event set in SylixOS, namely, event set object resource management block and event set buffer. The system prepares a fixed number of event set buffers in advance, and selects unused nodes from the buffer when applying for event sets. The event set buffer is managed by the event set object resource management block, as shown in figure 2.1.

Figure 2.1 event set structure

3. Event set creation process

The process of creating an event set is essentially the process of preparing the event set control node. First check whether there is any free space in the event set buffer, and return an error if it is full. If there is still a free location, obtain the location and configure the control node for later use as required by the interface parameters, as shown in figure 3.1.

Figure 3.1 event set creation process

4 event set sending process

The event set sending process first needs to find the corresponding event set control node in the buffer, and then set or clear the corresponding event state bits according to the requirements of the interface parameters. When the corresponding event state is modified, you also need to check whether there are waiting threads in the current event set. If so, determine whether the current modification meets the wake-up condition of this thread, and wake up the thread, that is, join the ready queue, as shown in figure 4.1

Figure 4.1 event set sending process

5 event set receiving process

When receiving the event set, it will first determine whether the activation condition is currently met, that is, whether there is a thread to send the event set that meets the condition. If not, the thread will be blocked and the waiting condition will be met. Thread blocking can set a timeout, and return a timeout flag if no set of events that meet the criteria are received within that time, as shown in figure 5.1.

Figure 5.1 event set receiving process

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report