Thread processing method, device, equipment and storage medium

By interrupting and resuming thread processing calls with uncertain time-consuming in the task processing system, the thread blocking problem is solved and the system performance is improved.

CN112181641BActive Publication Date: 2024-10-22CHINA UNIONPAY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010961501.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-14
Publication Date
2024-10-22
Estimated Expiration
2040-09-14

AI Technical Summary

Technical Problem

When a task processing system faces a large number of concurrent requests, threads are likely to be blocked for a long time due to internal or external calls that take uncertain time, resulting in reduced processing performance.

Method used

When a task is executed, if an internal or external call occurs that takes an uncertain time, interrupt the task and release the thread, wait for the response message and then resume the task, and reassign the thread to perform the recovery task to avoid thread blocking for a long time.

Benefits of technology

It improves thread utilization, reduces thread blocking, and improves the processing performance of the task processing system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112181641B_ABST
    Figure CN112181641B_ABST
Patent Text Reader

Abstract

The present application discloses a thread processing method, device, equipment and storage medium, and relates to the field of data processing. The method includes: obtaining a task request, assigning a first thread to execute the task for the task indicated by the task request; when a time-consuming and indeterminate internal call or a time-consuming and indeterminate external call occurs during the execution of the task, interrupting the task and releasing the first thread so that the first thread can be used to execute other tasks other than the task; when an internal call response message or an external call response message is received, resuming the task, occupying the second thread newly assigned to the task to execute the resumed task, the internal call response message is a response message of a time-consuming and indeterminate internal call, and the external call response message is a response message of a time-consuming and indeterminate external call. According to the embodiment of the present application, the processing performance of the task processing system can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing, and in particular to a thread processing method, apparatus, device and storage medium. Background Art

[0002] With the development of network technology and the increase of user demand, the task processing system used to execute tasks faces the problem of large number of concurrent requests.

[0003] When a task request enters the task processing system, the task processing system will create a thread for the task request. The thread is occupied to complete the task corresponding to the task request. However, a large number of concurrent requests will cause excessive pressure on the task processing system, especially when performing cross-system calls, database access, disk reading and writing, etc. The thread will be in a blocked state, reducing the processing performance of the task processing system. Summary of the invention

[0004] The embodiments of the present application provide a thread processing method, apparatus, device and storage medium, which can improve the processing performance of a task processing system.

[0005] In a first aspect, an embodiment of the present application provides a thread processing method, including: obtaining a task request, and assigning a first thread to execute the task indicated by the task request; when an internal call that is time-consuming and indeterminate or an external call that is time-consuming and indeterminate occurs during the execution of the task, interrupting the task and releasing the first thread so that the first thread can be used to execute tasks other than the task; when an internal call response message or an external call response message is received, resuming the task and occupying a second thread newly assigned to the task to execute the resumed task, the internal call response message being a response message of an internal call that is time-consuming and indeterminate, and the external call response message being a response message of an external call that is time-consuming and indeterminate.

[0006] In a second aspect, an embodiment of the present application provides a thread processing device, including: an allocation module, used to obtain a task request, and allocate a first thread to execute the task indicated by the task request; a thread interruption module, used to interrupt the task and release the first thread when an internal call that is time-consuming and indeterminate or an external call that is time-consuming and indeterminate occurs during the execution of the task, so that the first thread can be used to execute other tasks besides the task; a thread recovery module, used to recover the task and occupy the second thread newly allocated to the task to execute the recovered task when an internal call response message or an external call response message is received, the internal call response message is a response message of an internal call that is time-consuming and indeterminate, and the external call response message is a response message of an external call that is time-consuming and indeterminate.

[0007] In a third aspect, an embodiment of the present application provides a thread processing device, comprising: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the thread processing method of the first aspect is implemented.

[0008] In a fourth aspect, an embodiment of the present application provides a computer storage medium having computer program instructions stored thereon, and when the computer program instructions are executed by a processor, the thread processing method of the first aspect is implemented.

[0009] The embodiment of the present application provides a thread processing method, apparatus, device and storage medium, which allocates a first thread to a task indicated by a task request. In the process of executing a task, an internal call with uncertain time or an external call with uncertain time may occur, and the time of the internal call with uncertain time or the external call with uncertain time is uncertain, which may cause the first thread to be blocked for a long time. Therefore, when an internal call with uncertain time or an external call with uncertain time occurs during the execution of the task, the task is interrupted and the first thread is released. When a response message of the internal call with uncertain time or a response message of the external call with uncertain time is received, the task can be restored, and the restored task can be executed by the newly allocated second thread. The released first thread can execute other tasks except the task, avoid the first thread from being blocked for a long time, and can fully improve the utilization rate of the thread. The task restored after the interruption can be executed by the newly allocated second thread, and will not cause the task to be unable to be completed. On the basis of ensuring that the task indicated by the task request can be completed normally, the thread blocking is reduced, the thread utilization rate is improved, and the processing performance of the task processing system is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] In order to more clearly illustrate the technical solution of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0011] Figure 1 A flowchart of the thread processing method provided in the first aspect of the present application;

[0012] Figure 2 A flowchart of another embodiment of the thread processing method provided in the first aspect of the present application;

[0013] Figure 3 A schematic diagram of an example of storing register information and stack information in a storage container provided in an embodiment of the present application;

[0014] Figure 4 A schematic diagram of an example of restoring register information to a register and pointing a running stack pointer to stack information provided by an embodiment of the present application;

[0015] Figure 5 A structural schematic diagram of an embodiment of a thread processing device provided in the second aspect of the present application;

[0016] Figure 6 A schematic diagram of the hardware structure of an embodiment of a thread processing device provided in the third aspect of the present application. DETAILED DESCRIPTION

[0017] The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, rather than to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is only to provide a better understanding of the present application by illustrating the examples of the present application.

[0018] The task processing system is used to process tasks and can be applied to various fields, such as the communication field, the payment transaction field, etc., but is not limited here. With the development of network technology, the increase in users and the increase in user needs, the task processing system faces the problem of large concurrent requests.

[0019] When the task processing system receives a task request, it will assign a thread to the task request to process the task corresponding to the task request. In the process of processing the task, multiple processing logics will be passed, but the task will always occupy the thread during the entire process of processing the task. However, in some cases, there are multiple processing logics that are executed with uncertain processing time, such as disk reading and writing, database access, cross-system calls, etc. In the process of executing the processing logic with uncertain processing time, the thread needs to wait until the execution of the processing logic with uncertain processing time is completed and continue to process the task. However, since the task processing system faces a very large number of concurrent requests and the thread resources in the task processing system are limited, the performance of the task processing system in processing tasks is affected.

[0020] The embodiments of the present application provide a thread processing method, apparatus, device and storage medium. In the process of executing a task, when a time-consuming and uncertain processing logic appears, the task can be interrupted and the thread carrying the task can be released so that the thread can execute other tasks. When the time-consuming and uncertain processing logic ends, the thread can be allocated again for the task to resume the execution of the task. Through the flexible allocation and application of threads, the utilization rate of threads is improved, the blocking of threads is reduced, and the performance of the task processing system in processing tasks is improved.

[0021] The thread processing method provided in the first aspect of the present application is described in detail below. The thread processing method can be used in a task processing system, can be executed by the task processing system, and can also be executed by a thread processing device in the task processing system, which is not limited here. Figure 1 This is a flowchart of the thread processing method provided in the first aspect of the present application. Figure 1 As shown, the thread processing method may include steps S101 to S103.

[0022] In step S101, a task request is obtained, and a first thread for executing the task is allocated to the task indicated by the task request.

[0023] A task request is a request for processing a task, which contains information that can identify the task. In some examples, the task request may include a task identifier. The task identifier is unique, and different tasks can be distinguished by the task identifier. For example, the task identifier may be a task ID, which is not limited here.

[0024] The first thread is a thread assigned to the task indicated by the task request. The task indicated by the task request is executed by the first thread.

[0025] In step S102, when an internal call or an external call with an indeterminate time consumption occurs during the execution of a task, the task is interrupted and the first thread is released so that the first thread is used to execute other tasks besides the task.

[0026] An internal call with uncertain duration is an internal call with uncertain duration. The uncertain duration here can be regarded as the duration consumed exceeding the preset duration threshold. The preset duration threshold can be set according to the work scenario and work requirements, and is not limited here. For example, an internal call with uncertain duration may include but is not limited to disk reading and writing. An external call with uncertain duration is an external call with uncertain duration. For example, an external call with uncertain duration may include but is not limited to accessing a database and / or cross-system calls.

[0027] In some examples, whether a time-consuming indeterminate internal call or a time-consuming indeterminate external call occurs can be determined based on the input received from the operator. For example, the operator inputs in advance an instruction characterizing that the task indicated by the task request has a time-consuming indeterminate internal call or a time-consuming indeterminate external call, and the task processing system or thread processing device receives the instruction characterizing that the task indicated by the task request has a time-consuming indeterminate internal call or a time-consuming indeterminate external call input by the operator, and determines that the task has a time-consuming indeterminate internal call or a time-consuming indeterminate external call, so that when a time-consuming indeterminate internal call or a time-consuming indeterminate external call occurs, the task is terminated and the first thread is released.

[0028] In other examples, whether a time-consuming non-deterministic internal call or a time-consuming non-deterministic external call occurs can be determined based on a preset time-consuming non-deterministic call set. The preset time-consuming non-deterministic call set may include a sample of time-consuming non-deterministic internal calls and a sample of time-consuming non-deterministic external calls. When the internal call in the task indicated by the task request is consistent with the sample of time-consuming non-deterministic internal calls in the time-consuming non-deterministic call set, it is determined that a time-consuming non-deterministic internal call will occur during the execution of the task indicated by the task request; similarly, when the external call in the task indicated by the task request is consistent with the sample of time-consuming non-deterministic external calls in the time-consuming non-deterministic call set, it is determined that a time-consuming non-deterministic external call will occur during the execution of the task indicated by the task request.

[0029] In the embodiments of the present application, the method for determining whether a time-consuming non-deterministic internal call or a time-consuming non-deterministic external call has occurred includes but is not limited to the method in the above example. Other methods for determining whether a time-consuming non-deterministic internal call or a time-consuming non-deterministic external call has occurred are also within the scope of protection of the embodiments of the present application.

[0030] In the event of a time-consuming indeterminate internal call or a time-consuming indeterminate external call, the task is interrupted. However, it should be noted that during the task interruption process, the called resources of the time-consuming indeterminate internal call or the time-consuming indeterminate external call are still running, that is, the time-consuming indeterminate internal call or the time-consuming indeterminate external call is not interrupted. In the case of not occupying the first thread, the time-consuming indeterminate internal call or the time-consuming indeterminate external call that has been carried out is not affected. The first thread is released, and the released first thread can be assigned to other tasks so that other tasks occupy the first thread.

[0031] In step S103, when the internal call response message or the external call response message is received, the task is restored, and the second thread newly allocated for the task is occupied to execute the restored task.

[0032] Among them, the internal call response message is a response message of an internal call that is time-consuming and indeterminate, and is used to indicate that the time-consuming and indeterminate internal call has been completed. The external call response message is a response message of an external call that is time-consuming and indeterminate, and is used to indicate that the time-consuming and indeterminate external call has been completed. When the internal call response message or the external call response message is received, the task can be restored from the interrupt logic of the task indicated by the above-mentioned task request and the restored task can be continued to be executed. Moreover, a second thread is newly allocated to the task to execute the restored task. That is, the restored task occupies the newly allocated second thread. The second thread and the first thread can be the same thread or different threads, which is not limited here.

[0033] In an embodiment of the present application, a first thread is assigned to a task indicated by a task request. In the process of executing a task, an internal call that is not determined in time or an external call that is not determined in time may occur, and the time consumption of the internal call that is not determined in time or the external call that is not determined in time is uncertain, which may cause the first thread to be blocked for a long time. Therefore, in the case where an internal call that is not determined in time or an external call that is not determined in time occurs when a task is executed, the task is interrupted and the first thread is released. In the case of receiving a response message of an internal call that is not determined in time or a response message of an external call that is not determined in time, the task can be restored, and the restored task can be executed by a newly allocated second thread. The released first thread can execute other tasks except the task, avoid the first thread from being blocked for a long time, and can fully improve the utilization rate of the thread. The task restored after the interruption can be executed by the newly allocated second thread, and will not cause the task to be unable to be completed. On the basis of ensuring that the task indicated by the task request can be completed normally, the blocking of the thread is reduced, the utilization rate of the thread is improved, and the processing performance of the task processing system is improved.

[0034] Figure 2 This is a flowchart of another embodiment of the thread processing method provided in the first aspect of the present application. Figure 2 and Figure 1 The difference is that Figure 1 Step S102 in the above example can be specifically broken down into the following steps: Figure 2 Steps S1021 and S1022 in Figure 1 Step S103 in the above example can be specifically broken down into Figure 2 Steps S1031 to S1034 in .

[0035] In step S1021, when a time-consuming indeterminate internal call or a time-consuming indeterminate external call occurs during the execution of a task, register information corresponding to the task at the current moment and stack information corresponding to the task are stored in a preset storage container, and the task is interrupted.

[0036] The current time may be the task interruption time. The interruption task needs to store the register information corresponding to the task at the current time and the stack information corresponding to the task into a preset storage container.

[0037] The register information includes the information of the registers called by the execution of the task. For example, the register information may include but is not limited to data register information, instruction register information and stack pointer register information. The data register information includes the information of the data registers called by the execution of the task. The instruction register information includes the information of the instruction registers called by the execution of the task. The stack pointer register information includes the information of the stack pointer registers called by the execution of the task. The data registers may include but are not limited to the RBX register, the RBP register, the RDI register, the RSI register, the R12 register, etc. The instruction registers may include but are not limited to the RIP register, etc. The stack pointer register may include but are not limited to the RSP register, etc.

[0038] The stack information is information about the stack on which the task is executed. The stack pointer register information may point to the stack on which the task is executed.

[0039] The storage container may specifically include a memory block in the memory. The register information and stack information may be stored by applying for a memory block in the memory.

[0040] In some examples, the task request may include a task identifier of the task. The internal call response message or the external call response message may include a task identifier of the task. When register information corresponding to the task at the current moment and stack information corresponding to the task are stored in a preset storage container, a correspondence between the task identifier and the storage container may be established to facilitate subsequent restoration of the register information and the stack information. For example, if the storage container is a memory block in a memory, a correspondence between the task identifier and the address of the memory block may be established.

[0041] Figure 3 A schematic diagram of an example of storing register information and stack information in a storage container provided in an embodiment of the present application. Figure 3 As shown, in a task processing system or a thread processing device processor, such as a CPU, the registers called by the task indicated by the task request may include the RBX register, the RBP register, the R12 register, the RDI register, the RSI register, the RIP register, and the RSP register. Among them, the register information of the RIP register may indicate the address of the next instruction to execute the task. The register information of the RSP register may indicate the stack to execute the task. Figure 3 The running stack in the task can specifically indicate the top of the stack for executing the task. The storage container is a memory block pre-applied in the content. The data register information can be stored in the storage container first, and then the instruction register information can be stored in the storage container. Then, the stack for executing the task can be determined through the stack pointer register information, and the information of the stack can be stored in the storage container.

[0042] In step S1022, the first thread is released.

[0043] The above steps S1021 and S1022 are both executed when a task is executed and an internal call with an indeterminate time consumption or an external call with an indeterminate time consumption occurs.

[0044] In step S1031, when an internal call response message or an external call response message is received, register information corresponding to the task in the storage container is restored to the register.

[0045] Receiving an internal call response message indicates that the time-consuming indeterminate internal call has been completed. For example, the time-consuming indeterminate internal call is disk read / write, and receiving a disk read / write response message indicates that the disk read / write has been completed.

[0046] Receiving an external call response message indicates that the time-consuming indeterminate external call has been completed. For example, the time-consuming indeterminate external call is a database access, and receiving a database access response message indicates that the database access has been completed.

[0047] When a time-consuming non-deterministic internal substitution or a time-consuming non-deterministic external call has been completed, the interrupted task needs to be continued, and the registers called by the task need to restore the register information when the task was interrupted to continue the interrupted task.

[0048] In step S1032, the pointer pointing to the register of the execution stack is pointed to the stack information in the storage container.

[0049] The portion of the storage container that stores the stack information can be regarded as a saved running stack. The pointer to the register pointing to the running stack is pointed to the stack information in the storage container, so that the task that is executing the interrupt can read the stack information of the running stack when the task is interrupted, thereby continuing to execute the interrupted task.

[0050] In some examples, the task request may include a task identifier of the task. The internal call response message or the external call response message may include the task identifier of the task. Specifically, the corresponding relationship between the task identifier of the task and the storage container may be used to determine the storage container corresponding to the task identifier of the task, restore the register information in the determined storage container to the register, and point the pointer to the register of the running stack to the stack information in the determined storage container.

[0051] Figure 4 A schematic diagram of an example of restoring register information to a register and pointing a running stack pointer to stack information provided by an embodiment of the present application. Figure 4As shown, in a processor of a task processing system or a thread processing device, such as a CPU, the registers called by the task indicated by the task request may include the RBX register, the RBP register, the R12 register, the RDI register, the RSI register, the RIP register, and the RSP register. Among them, the register information of the RIP register may indicate the address of the next instruction to execute the task. The register information of the RSP register may indicate the stack on which the task is executed, and specifically may indicate the top of the stack on which the task is executed. The storage container is a memory block pre-applied in the content. The register information can be restored from the storage container to the corresponding register, and the pointer of the RSP register is pointed to the stack information in the storage container; specifically, the pointer of the RSP register is pointed to the top part of the stack information in the storage container.

[0052] In step S1033 , a second thread is allocated to the task.

[0053] The second thread is a thread assigned to the task to be restored. The second thread is a randomly assigned idle thread. The second thread and the first thread can be the same thread or different threads, which is not limited here.

[0054] In step S1034, the second thread is occupied to execute the restored task using the register information and stack information restored to the register.

[0055] When the register information is restored to the register and the pointer pointing to the register of the execution stack points to the stack information in the storage container, the newly allocated second thread may be used to execute the restored task.

[0056] The above steps S1031 to S1034 are all executed when an internal call response message or an external call response message is received.

[0057] In the above embodiment, interrupting the task and releasing the first thread can be achieved through an interruption script, that is, when a time-consuming and uncertain internal call or external call occurs during the execution of the task, the interruption script is read and executed to interrupt the task and release the first thread.

[0058] Among them, the interrupt script can be a Lua language script. In other embodiments, the interrupt script can also be other C language simulation assembly scripts, which are not limited here. Using Lua language scripts to implement task interruption, on the one hand, Lua language scripts run fast, have a simple running process, and low memory usage, which can avoid the complex process of function calls and function callbacks that occur when executing programs such as Java; on the other hand, for developers, Lua language scripts are easy to integrate and write, which can reduce the development difficulty and maintenance difficulty of thread processing.

[0059] A second aspect of the present application provides a thread processing device that can execute the thread processing method in the above embodiment. Figure 5 This is a structural diagram of an embodiment of a thread processing device provided in the second aspect of the present application. Figure 5 As shown, the thread processing device 200 may include an allocation module 201 , a thread interruption module 202 and a thread recovery module 203 .

[0060] The allocation module 201 may be used to obtain a task request and allocate a first thread for executing the task to the task indicated by the task request.

[0061] The thread interruption module 202 may be used to interrupt the task and release the first thread when an internal call or an external call that takes an indeterminate amount of time occurs during the execution of the task, so that the first thread can be used to execute other tasks besides the task.

[0062] In some examples, the time-consuming non-deterministic external calls include accessing a database and / or cross-system calls. The time-consuming non-deterministic internal calls include disk reading and writing.

[0063] The thread recovery module 203 may be used to recover the task when an internal call response message or an external call response message is received, and occupy the second thread newly allocated for the task to execute the recovered task.

[0064] The internal call response message is a response message of an internal call that takes an indeterminate amount of time. The external call response message is a response message of an external call that takes an indeterminate amount of time.

[0065] In an embodiment of the present application, a first thread is assigned to a task indicated by a task request. In the process of executing a task, an internal call that is not determined in time or an external call that is not determined in time may occur, and the time consumption of the internal call that is not determined in time or the external call that is not determined in time is uncertain, which may cause the first thread to be blocked for a long time. Therefore, in the case where an internal call that is not determined in time or an external call that is not determined in time occurs when a task is executed, the task is interrupted and the first thread is released. In the case of receiving a response message of an internal call that is not determined in time or a response message of an external call that is not determined in time, the task can be restored, and the restored task can be executed by a newly allocated second thread. The released first thread can execute other tasks except the task, avoid the first thread from being blocked for a long time, and can fully improve the utilization rate of the thread. The task restored after the interruption can be executed by the newly allocated second thread, and will not cause the task to be unable to be completed. On the basis of ensuring that the task indicated by the task request can be completed normally, the blocking of the thread is reduced, the utilization rate of the thread is improved, and the processing performance of the task processing system is improved.

[0066] In some examples, the thread interruption module 202 may be specifically used to store register information corresponding to the task at the current moment and stack information corresponding to the task into a preset storage container, and interrupt the task.

[0067] In some examples, the thread recovery module is specifically used to: restore the register information corresponding to the task in the storage container to the register; point the pointer pointing to the register of the running stack to the stack information in the storage container; assign a second thread to the task; and use the register information and stack information restored to the register to occupy the second thread to execute the restored task.

[0068] Specifically, the register information in the above embodiment includes data register information, instruction register information and stack pointer register information.

[0069] In some examples, the task request includes a task identifier of the task, and the internal call response message or the external call response message includes the task identifier of the task.

[0070] The thread interruption module 202 may also be used to establish a corresponding relationship between a task identifier of a task and a storage container.

[0071] The thread recovery module 203 may be specifically used to: determine the storage container corresponding to the task identifier of the task by using the correspondence between the task identifier of the task and the storage container; and restore the register information in the storage container to the register.

[0072] In some examples, the thread interruption module 202 may be specifically configured to read and execute an interruption script to interrupt the task and release the first thread when a time-consuming and indeterminate internal call or external call occurs during the execution of the task.

[0073] The interrupt script is a Lua language script.

[0074] A third aspect of the present application provides a thread processing device that can execute the thread processing method in the above embodiment. Figure 6 This is a hardware structure diagram of an embodiment of the thread processing device provided in the third aspect of the present application. Figure 6 As shown, the thread processing device 300 may include a memory 301 , a processor 302 , and a computer program stored in the memory 301 and executable on the processor 302 .

[0075] In an example, the processor 302 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.

[0076] The memory 301 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 301 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive, or a combination of two or more of these.

[0077] The memory may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk storage medium device, an optical storage medium device, a flash memory device, an electrical, optical or other physical / tangible memory storage device. Therefore, generally, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software including computer executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the thread processing method according to the present application.

[0078] The processor 302 runs a computer program corresponding to the executable program code by reading the executable program code stored in the memory 301, so as to implement the thread processing method in the embodiment of the first aspect.

[0079] In one example, the thread processing device 300 may further include a communication interface 303 and a bus 304. Figure 6 As shown, the memory 301, the processor 302, and the communication interface 303 are connected via a bus 304 and communicate with each other.

[0080] The communication interface 303 is mainly used to realize the communication between the modules, devices, units and / or equipment in the embodiment of the present application. The communication interface 303 can also be used to access input devices and / or output devices.

[0081] The bus 304 includes hardware, software, or both, coupling the components of the thread processing device 300 to each other. By way of example and not limitation, the bus 304 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a HyperTransport (HT) interconnect, an Industrial Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pincount (LPC) bus, a memory bus, a MicroChannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses or a combination of two or more of the above. Where appropriate, the bus 304 may include one or more buses. Although embodiments of the present application describe and illustrate a particular bus, the present application contemplates any suitable bus or interconnect.

[0082] The fourth aspect of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the thread processing method in the embodiment of the first aspect can be implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. Among them, the above-mentioned computer-readable storage medium may include a read-only memory (Read-Only Memory, referred to as ROM), a random access memory (Random Access Memory, referred to as RAM), a disk or an optical disk, etc., which is not limited here.

[0083] It should be clear that each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. For device embodiments, equipment embodiments, and computer-readable storage medium embodiments, the relevant parts can refer to the description part of the method embodiment. The present application is not limited to the specific steps and structures described above and shown in the figures. Those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application. In addition, for the sake of brevity, a detailed description of known method technologies is omitted here.

[0084] The above reference is according to the method of the embodiment of the present application, the flow chart of the device (system) and the computer program product and / or the block diagram described various aspects of the present application.It should be understood that each square box in the flow chart and / or the block diagram and the combination of each square box in the flow chart and / or the block diagram can be realized by computer program instructions.These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the realization of the function / action specified in one or more square boxes of the flow chart and / or the block diagram.Such a processor can be but is not limited to a general-purpose processor, a special-purpose processor, a special application processor or a field programmable logic circuit.It can also be understood that each square box in the block diagram and / or the flow chart and the combination of the square boxes in the block diagram and / or the flow chart can also be realized by the dedicated hardware that performs the specified function or action, or can be realized by the combination of dedicated hardware and computer instructions.

[0085] Those skilled in the art should understand that the above embodiments are exemplary rather than restrictive. Different technical features appearing in different embodiments can be combined to achieve beneficial effects. Based on the study of the drawings, the specification and the claims, those skilled in the art should be able to understand and implement other variations of the disclosed embodiments. In the claims, the term "comprising" does not exclude other devices or steps; the quantifier "one" does not exclude multiple; the terms "first" and "second" are used to indicate names rather than to indicate any specific order. Any figure marks in the claims should not be understood as limiting the scope of protection. The functions of multiple parts appearing in the claims can be implemented by a single hardware or software module. The appearance of certain technical features in different dependent claims does not mean that these technical features cannot be combined to achieve beneficial effects.

Claims

1. A thread processing method, It is characterized in that include: Obtaining a task request, and allocating a first thread to execute the task indicated by the task request; When an indeterminate internal call or an indeterminate external call occurs during the execution of the task, interrupting the task and releasing the first thread so that the first thread is used to execute other tasks except the task; In case of receiving an internal call response message or an external call response message, resuming the task and occupying a second thread newly allocated for the task to execute the resumed task, wherein the internal call response message is a response message of the time-consuming indeterminate internal call, and the external call response message is a response message of the time-consuming indeterminate external call; When an internal call or an external call that consumes an indeterminate amount of time occurs during the execution of the task, interrupting the task and releasing the first thread includes: When a time-consuming and non-deterministic internal call or external call occurs during the execution of the task, an interruption script is read and executed to interrupt the task and release the first thread, wherein the interruption script is a Lua language script; The interrupting of the task comprises: The register information corresponding to the task at the current moment and the stack information corresponding to the task are stored in a preset storage container, and the task is interrupted; The resuming the task, occupying the second thread newly allocated for the task to execute the resumed task, comprises: Restoring register information corresponding to the task in the storage container to the register; Pointing a pointer to a register of a running stack to the stack information in the storage container; Allocating the second thread to the task; The second thread is occupied to execute the restored task by utilizing the register information and the stack information restored to the register.

2. The method according to claim 1, It is characterized in that The task request includes the task identifier of the task, and the internal call response message or the external call response message includes the task identifier of the task. The method further comprises: Establishing a correspondence between the task identifier of the task and the storage container; The restoring the register information corresponding to the task in the storage container to the register includes: Determine the storage container corresponding to the task identifier of the task by using the correspondence between the task identifier and the storage container; The register information in the storage container is restored to the register.

3. The method according to claim 1 or 2, It is characterized in that The register information includes data register information, instruction register information and stack pointer register information.

4. The method according to claim 1 or 2, It is characterized in that The time-consuming and non-deterministic external calls include accessing a database and / or cross-system calls; The time-consuming non-deterministic internal calls include disk reading and writing.

5. A thread processing device, It is characterized in that include: An allocation module, configured to obtain a task request and allocate a first thread for executing the task indicated by the task request; A thread interruption module, used for interrupting the task and releasing the first thread when an internal call or an external call that takes an indeterminate amount of time occurs during the execution of the task, so that the first thread is used to execute other tasks except the task; A thread recovery module, used for recovering the task and occupying a second thread newly allocated for the task to execute the recovered task when receiving an internal call response message or an external call response message, wherein the internal call response message is a response message of the time-consuming indeterminate internal call, and the external call response message is a response message of the time-consuming indeterminate external call; The thread interruption module is specifically used for: when the task is executed and a time-consuming and non-determined internal call or external call occurs, reading and executing an interruption script to interrupt the task and release the first thread, wherein the interruption script is a Lua language script; The thread interrupt module is specifically used to: store register information corresponding to the task at the current moment and stack information corresponding to the task into a preset storage container, and interrupt the task; The thread recovery module is specifically used to: restore the register information corresponding to the task in the storage container to the register; point the pointer pointing to the register of the running stack to the stack information in the storage container; The second thread is allocated to the task; and the register information and the stack information restored to the register are utilized to occupy the second thread to execute the restored task.

6. The device according to claim 5, It is characterized in that The task request includes the task identifier of the task, and the internal call response message or the external call response message includes the task identifier of the task. The thread interrupt module is also used for: Establishing a correspondence between the task identifier of the task and the storage container; The thread recovery module is specifically used for: Determine the storage container corresponding to the task identifier of the task by using the correspondence between the task identifier and the storage container; The register information in the storage container is restored to the register.

7. The device according to claim 5 or 6, It is characterized in that The register information includes data register information, instruction register information and stack pointer register information.

8. The device according to claim 5 or 6, It is characterized in that The time-consuming and non-deterministic external calls include accessing a database and / or cross-system calls; The time-consuming non-deterministic internal calls include disk reading and writing.

9. A thread processing device, It is characterized in that include: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, the thread processing method according to any one of claims 1 to 4 is implemented.

10. A computer storage medium, It is characterized in that The computer storage medium stores computer program instructions, and when the computer program instructions are executed by the processor, the thread processing method according to any one of claims 1 to 4 is implemented.