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

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 event A is triggered before subsequent processing can be performed. Therefore, thread B will wait indefinitely for event A to be triggered, resulting in thread B being blocked, etc.
[0011] Whether it is deadlock, lock abandonment or blocking caused by waiting for an event to trigger, the program cannot be executed smoothly.

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

Embodiment Construction

[0032] Aiming at the problems existing in the prior art, the present invention proposes a solution to prevent threads from being blocked in a multi-threaded program.

[0033] Based on the previous introduction, it can be seen that thread blocking may be caused by various reasons, such as deadlock, lock abandonment, and waiting for event triggers. The present invention provides corresponding solutions for the above-mentioned reasons, and the following are respectively carried out introduce.

[0034] In the Windows system, the critical section is usually used to implement the lock function.

[0035] 1) Wait for the event to trigger

[0036] In order to overcome the blocking of threads caused by waiting for event triggering, the following processing methods can be adopted: after the system starts, replace (HOOK) all application program interface (API, Application Programming Interface) functions for waiting for event triggering in the system, so that When any HOOKed API functio...

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 Patsnap Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Patsnap Eureka Blog
Learn More
PatSnap group products