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
CN103246552AActive Publication Date: 2013-08-14TENCENT TECH (SHENZHEN) CO LTD

Patent Information

Authority / Receiving Office
CN Β· China
Current Assignee / Owner
TENCENT TECH (SHENZHEN) CO LTD
Publication Date
2013-08-14

Smart Images

  • Figure 1
    Figure 1
  • Figure 2
    Figure 2
  • Figure 3
    Figure 3
Patent Text Reader

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.
Need to check novelty before this filing date? Find Prior Art

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