Semaphore processing method and semaphore processing system
A processing method and processing system technology, applied in the direction of program synchronization, multi-channel program device, etc., can solve the problems of small counter value range and not meeting the requirements of large counters, achieve a large value range, meet the needs of large counting quantities, The effect of expanding the range of values
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Publication Date
- 2014-05-14
- Estimated Expiration
- Not applicable · inactive patent
Smart Images
Figure 1 Figure 2
Abstract
Description
technical field
[0001] The present invention relates to the technical field of semaphore counting, and more specifically, to a processing method and system for semaphore. Background technique
[0002] The best choice for the producer-consumer model to be established on the current Unix system is to use SystemV semaphores as counters.
[0003] Semaphore, also known as semaphore, is a mechanism used to solve the problem of process synchronization and mutual exclusion. In the system, each process is given a semaphore, which represents the current state of each process, so as to ensure that no collision occurs when the process accesses shared data. SystemV semaphores are two sets of interface standards in Unix. SystemV's semaphore interface can execute multiple semaphore operations at the same time and maintain atomicity in one execution.
[0004] However, the value range of the SystemV semaphore is very limited, and the value range of each SystemV semaphore is 0 to 32767. T...
Examples
Embodiment Construction
[0031] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.
[0032] An embodiment of the present invention provides a semaphore processing method, comprising: acquiring a semaphore set; forming a semaphore group with every two semaphore in the semaphore set, and converting all semaphore groups into a counter; One semaphore in each semaphore group in the counter is used as a count bit, and another semaphore is used as a switch bit; when the switch bit of the semaphore group is turned on, the counting of the count bit of t...