Looking for breakthrough ideas for innovation challenges? Try Patsnap Eureka!

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

Inactive Publication Date: 2012-09-12
融创天下(上海)科技发展有限公司
View PDF6 Cites 18 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0010] The purpose of the embodiments of the present invention is to propose a method for threads to access critical sections, aiming to solve the technical problems of low access efficiency, long waiting time, and large CPU consumption when multiple processes mutually exclusive access to critical sections in the prior art

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Method, system and terminal device for threads to access critical zones
  • Method, system and terminal device for threads to access critical zones
  • Method, system and terminal device for threads to access critical zones

Examples

Experimental program
Comparison scheme
Effect test

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...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention discloses a method, a system and a terminal device for threads to access critical zones. The method establishes a thread mutual exclusion lock variable and a status value of the thread mutual exclusion lock variable, initializes the thread mutual exclusion lock variable to be the status value, obtains an access mode of the threads, and judges whether a current valve in the thread mutual exclusion lock variable is equal to the status value. If the current valve in the thread mutual exclusion lock variable is equal to the status value, the threads are allowed to access the critical zones in the access mode, and the current value in the thread mutual exclusion lock variable is modified according to the access mode. Whether the critical zones can be used can be determined rapidly before the threads access the critical zones. If the critical zones cannot be used, the threads can give up central processing unit (CPU) time slices automatically, a heavy and time-consuming system lock for thread access is avoided, access efficiency and multi-thread mutual exclusion access efficiency of the critical zones are improved, CPU consumption is reduced, and market competitiveness of software products is improved simultaneously. By means of atomic increasing or reducing, the critical zones can be accessed accurately and effectively.

Description

technical field [0001] The invention relates to the field of multi-thread calling, in particular to a method, system and terminal equipment for thread access critical section. Background technique [0002] In the prior art, whether it is a hardware-critical resource or a software-critical resource, multiple processes must mutually exclusive access to it. The section of code in each process that accesses a critical resource is called a critical section (a critical resource is a shared resource that only one process is allowed to use at a time). Only one process is allowed to enter the critical area at a time, and other processes are not allowed to enter after entering. Regardless of whether it is a hardware-critical resource or a software-critical resource, multiple processes must mutually exclusive access to it. [0003] The scheduling principle for a process entering a critical section is: [0004] 1) If several processes request to enter an idle critical section, only o...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
IPC IPC(8): G06F9/46
Inventor 刘骁
Owner 融创天下(上海)科技发展有限公司
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Patsnap Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Patsnap Eureka Blog
Learn More
PatSnap group products