Thread synchronization method and thread synchronization system

A technology for synchronizing systems and threads, applied in the direction of program synchronization, program control design, multi-program device, etc., can solve problems such as deadlock, other threads cannot access the protected area, and the protected area cannot be released or reset. The effect of avoiding deadlock

Active Publication Date: 2017-07-25
BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF14 Cites 10 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

Thread synchronization methods for multi-threads in the prior art mainly include "critical section method", "event method", "mutex method" and "semaphore method", but in the actual application process, these thread synchronization methods may be When the thread accessing the protected area is killed, the protected area cannot be released or reset. In this case, other threads cannot access the protected area, resulting in deadlock

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
  • Thread synchronization method and thread synchronization system
  • Thread synchronization method and thread synchronization system
  • Thread synchronization method and thread synchronization system

Examples

Experimental program
Comparison scheme
Effect test

Embodiment Construction

[0033] 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.

[0034] The embodiment of this application provides a thread synchronization method, such as figure 1 shown, including:

[0035] S101: Define a global variable, the global variable includes a first variable and a second variable, the first variable includes a first state and a second state, and the second variable is used to lock the first variable;

[0036] S102: Create a new mutex class object in each protection area, the class includes a destructor and a po...

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 thread synchronization method and a thread synchronization system. According to the thread synchronization method, after a thread is ensured to access any protective region successfully through a destructor, a state of a first variable is changed to a first state to release locking of the protective region in an access process of the thread, so that the purpose of releasing the protective region in time is achieved; when the thread which is accessing the protective region is killed, normal operation of the destructor is not influenced, so that the deadlock phenomenon possibly caused by killing of the thread which is accessing the protective region is avoided; and in addition, a state about whether all protective regions can be accessed or not can be controlled by the state of one variable, so that the purpose that the states of all the protective regions are controllable is achieved.

Description

technical field [0001] The present application relates to the field of computer application technology, and more specifically, to a thread synchronization method and a thread synchronization system. Background technique [0002] Multi-threaded operation can realize the purpose of making full use of system resources, shortening program response time and improving user experience, so it is widely used in various computer programs. Thread synchronization is an indispensable step in multi-thread operation. Reasonable and effective thread synchronization can effectively ensure the correctness of data and the normal operation of programs. [0003] Since there are some sensitive data in the system, these sensitive data are not allowed to be accessed by multiple threads at the same time. At this time, it is necessary to perform thread synchronization on multiple threads to ensure that only one thread accesses the protected area containing sensitive data at the same time, thereby ens...

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
Patent Type & Authority Applications(China)
IPC IPC(8): G06F9/52
CPCG06F9/526
Inventor 陈阳春王雁
Owner BEIJING QIYI CENTURY SCI & TECH CO LTD
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products