Method, system and terminal device for threads to access critical zones
A critical area and access method technology, applied in multi-program devices and other directions, can solve the problems of low access efficiency, long waiting time, high CPU consumption, etc., and achieve the effect of improving market competitiveness, reducing CPU consumption, and improving access efficiency
- Summary
- Abstract
- Description
- Claims
- Application Information
AI Technical Summary
Problems solved by technology
Method used
Image
Examples
Embodiment 1
[0041] figure 1 It is a flow chart of the first preferred embodiment of a thread access critical section method of the present invention. Described method comprises the following steps:
[0042] S101, creating a thread mutex variable;
[0043] The number of digits of the thread mutex variable is the maximum number of digits that the CPU can handle at one time;
[0044] The thread mutex variable is a thread mutex variable of a signed integer;
[0045] The highest bit of the thread mutex variable is a sign bit, and when the sign bit is 0, it means that the value in the thread mutex variable is a positive integer; when the sign bit is 1, it means that the The value in the thread mutex variable is a negative integer;
[0046] If the next bit of the highest bit of the thread mutex variable is 1, it means that the thread mutex is idle, allowing the thread to access the critical section; if it is 0, it means that there is already a thread accessing the critical section;
[0047]...
Embodiment 2
[0069] image 3 It is a flow chart of the second preferred embodiment of a thread access critical section method of the present invention. Described method comprises the following steps:
[0070] S301, creating a thread mutex variable;
[0071] The number of digits of the thread mutex variable is the maximum number of digits that the CPU can handle at one time;
[0072] S302, creating the state value of the thread mutex variable;
[0073] S303. Initialize the thread mutex variable as a state value;
[0074] S304, acquiring the read access mode of the thread;
[0075] S305, judging whether the current value in the thread mutex variable is equal to the read state value or the idle state value, if so, enter step S306; otherwise enter step S308;
[0076] S306. Allow the thread to read the critical section, and decrement the current value in the thread mutex variable by 1 according to the read access mode;
[0077] For ease of understanding, continue with an example:
[0078...
Embodiment 3
[0093] Figure 4 It is a flow chart of the third preferred embodiment of a thread access critical section method of the present invention. Described method comprises the following steps:
[0094] S401, creating a thread mutex variable;
[0095] The number of digits of the thread mutex variable is the maximum number of digits that the CPU can handle at one time;
[0096] S402, creating a state value of the thread mutex variable;
[0097] S403. Initialize the thread mutex variable as a state value;
[0098] S404, acquiring the write access mode of the thread;
[0099] S405, judging whether the current value in the thread mutex variable is equal to the idle state value, if so, enter step S406; otherwise enter step S408;
[0100] Only when the current value in the thread mutex variable is equal to the idle state value, the thread is allowed to write the critical section;
[0101] S406. Allow the thread to write to the critical section, and modify the current value in the thr...
PUM
Abstract
Description
Claims
Application Information
- R&D Engineer
- R&D Manager
- IP Professional
- Industry Leading Data Capabilities
- Powerful AI technology
- Patent DNA Extraction
Browse by: Latest US Patents, China's latest patents, Technical Efficacy Thesaurus, Application Domain, Technology Topic, Popular Technical Reports.
© 2024 PatSnap. All rights reserved.Legal|Privacy policy|Modern Slavery Act Transparency Statement|Sitemap|About US| Contact US: help@patsnap.com