CN113742092A - Concurrency algorithm - Google Patents
Concurrency algorithm Download PDFInfo
- Publication number
- CN113742092A CN113742092A CN202111051737.2A CN202111051737A CN113742092A CN 113742092 A CN113742092 A CN 113742092A CN 202111051737 A CN202111051737 A CN 202111051737A CN 113742092 A CN113742092 A CN 113742092A
- Authority
- CN
- China
- Prior art keywords
- mutual exclusion
- cpu
- algorithm
- code blocks
- lock
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 230000007717 exclusion Effects 0.000 claims abstract description 13
- 238000000034 method Methods 0.000 claims description 2
- 238000005457 optimization Methods 0.000 claims description 2
- 230000007246 mechanism Effects 0.000 description 4
- 238000013459 approach Methods 0.000 description 1
- 238000004590 computer program Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/52—Program synchronisation; Mutual exclusion, e.g. by means of semaphores
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
With the advent of the computer parallel era, lock-based concurrency control has tended to cause valuable CPU time to be wasted waiting. In order to solve this problem, the present invention proposes a lock-free concurrent algorithm, in which one program is divided into a plurality of code blocks in units of threads, and the code blocks are respectively handed to each CPU or an independent execution module (hereinafter, referred to as a CPU core) to be executed. The code blocks with the same mutual exclusion relation are sequentially executed, so that idle waiting of a CPU is avoided, and the execution sequence and priority can be set. With the present algorithm support, the computer system will not even need a hardware lock and its associated instructions.
Description
Technical Field
The technology belongs to the fields of computer software, hardware algorithm and compiling optimization.
Background
With the development of computer technology, computer hardware and software nowadays enter a parallel era, which makes the current software and hardware concurrent technology meet unprecedented challenges. In high concurrency situations where consistent synchronization of data becomes difficult, lock-based concurrency control is very likely to cause valuable CPU time to be wasted on wait. In order to solve the problem, the invention provides an algorithm which can be used from a bottom layer technology to an upper layer application, so that the waiting time of a system approaches to 0, the complexity of concurrent programming and hardware is simplified, the performance of a computer system is improved, and the design difficulty of the system is reduced.
Disclosure of Invention
The invention relates to a concurrency algorithm, which mainly comprises the following contents: one program is divided into a plurality of code blocks for each thread, and each code block is handed to each CPU or an independent execution module (hereinafter, referred to as a CPU core) to be executed. In the set of code blocks with the same mutual exclusion relationship, only one code block can be executed at the same time. The code block is executed before another code block of the same mutual exclusion relationship is executed. Thus, CPU idle waiting is avoided, and the execution order and priority can be set. With the present algorithm support, the computer system will not even need a hardware lock and its associated instructions.
Modern multi-core computer programs generally use mechanisms such as locks and critical sections to ensure the access security of a certain block of code among threads. However, this mechanism is preemptive, and has problems such as idle waiting of the CPU core. Therefore, the present invention proposes a new structure to logically guarantee that only one code block can be executed at a time in a set of mutually exclusive code blocks. Such code blocks are referred to as mutex blocks. The code blocks with the same mutual exclusion relationship are collected and called mutual exclusion group. This mechanism relies on the execution order of the programs rather than the hardware and software lock mechanism. The detailed process is as follows:
the program starts multiple threads (single-threaded programs are not under consideration) while running (see fig. 1), and each thread respectively dispatches code to the CPU core for execution (see fig. 2). For example, as shown in FIG. 1, there are m threads in the program, and each thread has n Code blocks, from Code _ blockm1 to Code _ blockmn, respectively. These code blocks are scheduled to k CPU cores, with the scheduling result assumed to be fig. 2, without including any mutual exclusion requirements. However, if there is a mutex group between threads (see fig. 3, Code _ mutex13 indicates mutex group 1, and the mutex block number is 3), only one mutex block is executed when any mutex block in the mutex group is executed, and other mutex blocks to be executed can only wait. After the execution of the mutex block is completed, another mutex block in the mutex group is executed again until the execution of the mutex block that needs to be executed in the complete mutex group is completed (see fig. 4, the execution of other code blocks may not be as regular as in the figure, and is only used for illustration). No locks are used during the entire execution, nor are any CPU idles generated.
On this basis, a priority rule may also be specified for a particular thread, causing the thread to execute according to the rule.
Claims (5)
1. A concurrent execution algorithm, characterized by:
s1, a plurality of units executing concurrently exist;
s2, existence of the mutual exclusion block defined in [0004 ];
s3, executing the mutual exclusion block according to the rule described in [0004 ].
2. A software concurrency algorithm according to claim 1, wherein:
s1, a plurality of concurrent execution units are contained in the software;
s2, including the mutual exclusion block defined in [0004] in the software;
s3, the software executes the mutual exclusion block according to the rule described in [0004 ].
3. The compilation optimization algorithm of claim 1, wherein:
s1, the compiled code comprises a plurality of concurrent execution units;
s2, the compiled code contains the mutual exclusion block defined in [0004 ];
s3, the compiled code executes the mutex block according to the rule described in [0004 ].
4. The hardware concurrency algorithm of claim 1, wherein:
s1, a plurality of units executing concurrently exist;
s2, existence of the mutual exclusion block defined in [0004 ];
s3, executing the mutual exclusion block according to the rule described in [0004 ].
5. The method of claim 1, wherein:
priority rules are specified on the basis of claim 1 or claim 2 or claim 3 or claim 4.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111051737.2A CN113742092A (en) | 2021-09-09 | 2021-09-09 | Concurrency algorithm |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111051737.2A CN113742092A (en) | 2021-09-09 | 2021-09-09 | Concurrency algorithm |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113742092A true CN113742092A (en) | 2021-12-03 |
Family
ID=78737212
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111051737.2A Pending CN113742092A (en) | 2021-09-09 | 2021-09-09 | Concurrency algorithm |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113742092A (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080028406A1 (en) * | 2006-07-31 | 2008-01-31 | Hewlett-Packard Development Company, L.P. | Process replication method and system |
CN102521007A (en) * | 2011-11-30 | 2012-06-27 | 烽火通信科技股份有限公司 | Network management system object concurrency editing method based on affair scheduling |
CN103080900A (en) * | 2010-09-03 | 2013-05-01 | 西门子公司 | Method for parallelizing automatic control programs and compiler |
CN110888727A (en) * | 2019-11-26 | 2020-03-17 | 北京达佳互联信息技术有限公司 | Method, device and storage medium for realizing concurrent lock-free queue |
-
2021
- 2021-09-09 CN CN202111051737.2A patent/CN113742092A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080028406A1 (en) * | 2006-07-31 | 2008-01-31 | Hewlett-Packard Development Company, L.P. | Process replication method and system |
CN103080900A (en) * | 2010-09-03 | 2013-05-01 | 西门子公司 | Method for parallelizing automatic control programs and compiler |
CN102521007A (en) * | 2011-11-30 | 2012-06-27 | 烽火通信科技股份有限公司 | Network management system object concurrency editing method based on affair scheduling |
CN110888727A (en) * | 2019-11-26 | 2020-03-17 | 北京达佳互联信息技术有限公司 | Method, device and storage medium for realizing concurrent lock-free queue |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7257814B1 (en) | Method and apparatus for implementing atomicity of memory operations in dynamic multi-streaming processors | |
US4636948A (en) | Method for controlling execution of application programs written in high level program language | |
CN101556545B (en) | Method for realizing process support, device and multithreading system | |
JPH03144847A (en) | Multi-processor system and process synchronization thereof | |
JP2005284749A (en) | Parallel computer | |
Jayanti | Adaptive and efficient abortable mutual exclusion | |
JPH0120466B2 (en) | ||
WO2003102758A1 (en) | Method and apparatus for real-time multithreading | |
Dechev et al. | Lc/dc: Lockless containers and data concurrency a novel nonblocking container library for multicore applications | |
Sharma et al. | A competitive analysis for balanced transactional memory workloads | |
Taubenfeld | Contention-sensitive data structures and algorithms | |
EP1299801B1 (en) | Method and apparatus for implementing atomicity of memory operations in dynamic multi-streaming processors | |
CN113742092A (en) | Concurrency algorithm | |
CN110083445B (en) | Multithreading deterministic execution method based on weak memory consistency | |
Lehey | Improving the FreeBSD SMP Implementation. | |
Yi et al. | A Universal Construction to implement Concurrent Data Structure for NUMA-muticore | |
CN115080670A (en) | Deterministic transaction concurrency control method based on GPU acceleration | |
Singh | Communication Coroutines For Parallel Program Using DW26010 Many Core Processor | |
Taubenfeld | Contention-sensitive data structures and algorithms | |
Jiang et al. | Real-time scheduling of parallel task graphs with critical sections across different vertices | |
Deshpande et al. | Analysis of the Go runtime scheduler | |
Polito et al. | GildaVM: a Non-Blocking I/O Architecture for the Cog VM | |
CN117032999B (en) | CPU-GPU cooperative scheduling method and device based on asynchronous running | |
Sun et al. | Concurrency and Operating Systems, Processors, and Programming Languages | |
CN117076145B (en) | Safe and efficient STM synchronization method based on fine-granularity read-write lock |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |