Method and device for preventing thread from blocking

A thread and one-line technology, applied in the field of preventing thread from blocking, can solve problems such as failure to trigger event A, program cannot be executed smoothly, thread B is blocked, etc., to achieve the effect of facilitating popularization and promotion, ensuring smooth execution, and overcoming blocking

Active Publication Date: 2013-08-14
TENCENT TECH (SHENZHEN) CO LTD
View PDF8 Cites 21 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

like Figure 5 As shown, assume that thread A is set to trigger event A only after event B is triggered, but for some reason, event B has not been triggered, then thread A will wait indefinitely for the triggering of event B, correspondingly, Therefore, event A cannot be triggered, and thread B is set to wait until eve

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 and device for preventing thread from blocking
  • Method and device for preventing thread from blocking
  • Method and device for preventing thread from blocking

Examples

Experimental program
Comparison scheme
Effect test

Example Embodiment

[0032] In view of the problems in the prior art, the present invention proposes a solution for preventing thread blocking in a multithreaded program.

[0033] Based on the previous introduction, it can be known that thread blocking may be caused by various reasons, such as deadlock, lock abandonment, and wait event triggering. The present invention provides corresponding solutions for the above reasons. The following are respectively Introduction.

[0034] In Windows systems, critical sections are usually used to implement the lock function.

[0035] 1) Wait for the event to trigger

[0036] In order to overcome the thread blocking caused by waiting for the event to be triggered, the following processing methods can be adopted: after the system is started, replace (HOOK) all the application programming interface (API, Application Programming Interface) functions in the system for waiting for the event to be triggered, so that When any API function after HOOK is called by a thread, if...

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 method and device for preventing a thread from blocking. The method includes: after a system starts, replacing all application program interface functions used for awaiting events to be triggered so that, when one replaced application program interface function is transferred by a thread, if that the length of set waiting time is unlimited is determined, changing the length of the set waiting time to a preset value; or after a system starts, replacing all application program interface functions used for ending events so that, when one replaced application program interface function is transferred by a thread, if that critical sections occupied by the thread to be ended is not released is determined, then releasing the critical sections; or performing thread poll periodically, if that the length of blocking time of a thread exceeds a preset length of time and the thread is blocked on transferring of application program interface functions used for occupying critical sections, then releasing a critical section corresponding to a first parameter of the transferred application program interface functions. By the method, successfully execution of the program can be guaranteed.

Description

technical field [0001] The invention relates to computer technology, in particular to a method and device for preventing thread from blocking. Background technique [0002] Each program running on the system is a process, and each process can include one or more threads, and a thread is the smallest unit of program execution flow. [0003] The execution order of instructions within each thread is fixed. figure 1 It is a schematic diagram of an instruction execution method in an existing thread. Such as figure 1 As shown, instruction 1 is executed first, then instruction 2 is executed, and so on until instruction n is executed (assuming n is greater than 2), and the process ends. [0004] Generally, a program including a plurality of threads is called a multi-threaded program. In a multi-threaded program, when multiple threads need to access the same piece of data, that is, shared data, because the order of execution of instructions is different, locks are required to imp...

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 TENCENT TECH (SHENZHEN) 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