Concurrent thread processing method, device, electronic device and storage medium

By pushing the pending concurrent thread into the waiting queue of the time-limited lock and processing it within the time-limited time, the problem of slow thread processing caused by the lack of exception thread management in the prior art is solved, and the concurrent processing performance of the system is improved.

CN113760369BActive Publication Date: 2024-11-26BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011047673.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-29
Publication Date
2024-11-26
Estimated Expiration
2040-09-29

AI Technical Summary

Technical Problem

The lack of management tools for exception threads in the prior art leads to slow thread processing and affects the concurrent processing performance of the entire system.

Method used

By pressing the pending concurrent threads into the waiting queue of the time-limited lock, the lock state is determined using the preset time-limited lock allocation model, and the lock thread is processed within the time-limited time, constraining the processor time of each thread, achieving fast processing and efficient processing and use.

Benefits of technology

It shortens the processor's waiting time when concurrent thread exceptions, improves the system's concurrent processing performance, and avoids the cost pressure of multi-core CPUs or multi-channel CPUs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113760369B_ABST
    Figure CN113760369B_ABST
Patent Text Reader

Abstract

The present application provides a concurrent thread processing method, device, electronic device and storage medium, which first pushes the received concurrent threads to be processed into the waiting queue of the time-limited lock, then uses the preset time-limited lock allocation model to determine the lock holding state of each concurrent thread to be processed in the waiting queue, and then processes the locked thread within the time limit of the time-limited lock. By constraining the time each thread occupies the processor through the time-limited lock, the waiting time of the processor when the concurrent thread is abnormal is shortened, and the technical problem that the prior art lacks management tools and methods for abnormal threads, resulting in slow thread processing and thus affecting the concurrent processing performance of the entire system is solved, and the technical effect of improving the concurrent processing performance of the system is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] JAVA voice software tool development kit JDK is widely used in the construction of JAVA applications on mobile devices and embedded devices. JDK, as the core of the entire JAVA development, includes the JAVA runtime environment and JAVA tools.

[0003] Currently, there is no dedicated computing resource allocation tool in the JAVA environment of JDK for situations where a large number of concurrent threads need to be processed in a short period of time. This results in a large amount of idle waiting time for the processor when an abnormal situation occurs in a thread, resulting in slow processing of concurrent threads and low utilization of computing resources.

[0004] That is, the prior art lacks management tools and methods for abnormal threads, which leads to slow thread processing and thus affects the concurrent processing performance of the entire system. Summary of the invention

[0005] The present application provides a concurrent thread processing method, device, electronic device and storage medium to solve the technical problem that the prior art lacks management tools and methods for abnormal threads, resulting in slow thread processing and thus affecting the concurrent processing performance of the entire system, so as to improve the concurrent processing performance of the system.

[0006] In a first aspect, the present application provides a concurrent thread processing method, comprising:

[0007] Pushing the received concurrent threads to be processed into a waiting queue of a time-limited lock, where the time-limited lock is used to manage the triggering logic of the concurrent threads to be processed;

[0008] Determine the lock status of each pending concurrent thread in the waiting queue by using a preset time-limited lock allocation model, wherein the lock status is used to characterize the thread processing time priority;

[0009] The lock holding thread is processed within the time limit of the time-limited lock, and the lock holding thread is a thread whose lock holding state is a target state.

[0010] Optionally, the thread processing time priority and the time limit satisfy a preset corresponding relationship.

[0011] In a possible design, pressing the received concurrent threads to be processed into a waiting queue of a time-limited lock includes:

[0012] Sorting the pending concurrent threads according to a preset sorting algorithm to determine a concurrent thread sequence;

[0013] The waiting queue is the concurrent thread sequence.

[0014] Optionally, the determining the lock status of each pending concurrent thread in the waiting queue by using a preset time-limited lock allocation model includes:

[0015] According to the arrangement order of each of the pending concurrent threads in the waiting queue, the lock holding state of the top N pending concurrent threads is modified to the target state each time;

[0016] The N is less than or equal to the number of concurrent threads to be processed in the waiting queue.

[0017] Optionally, N is equal to 1.

[0018] In a possible design, the target state includes a locked state, and the locked state is used to indicate a thread that needs to be processed immediately.

[0019] In a possible design, the processing of the lock-holding thread within the time limit of the time-limited lock includes:

[0020] Using the inspection thread of the time-limited lock to monitor the processing time of the lock holding thread;

[0021] If the processing time is less than the time limit, the lock holding thread is reassigned using the preset time-limited lock allocation model.

[0022] In one possible design, the method further includes:

[0023] If the processing time reaches the time limit, the concurrent thread corresponding to the lock holding thread is pushed into the exception queue of the time-limited lock;

[0024] If the inspection thread detects that the abnormal concurrent thread in the abnormal queue meets the preset condition, the abnormal concurrent thread is designated as the lock holding thread when the lock holding thread is re-designated next time.

[0025] Optionally, the method further includes:

[0026] When the inspection thread monitors that the processing time of the abnormal concurrent thread as the lock holding thread reaches the time limit, the abnormal concurrent thread is pushed back into the waiting queue to wait again for the preset time-limited lock allocation model to designate it as the lock holding thread.

[0027] In a possible design, the reassigning the lock holding thread includes:

[0028] The lock state of the concurrent thread at a preset position in the waiting queue or the exception queue is set as a target state.

[0029] Optionally, before the monitoring of the processing time of the lock holding thread by the inspection thread of the time-limited lock, the method further includes:

[0030] Check whether the inspection thread exists, and if not, create the inspection thread.

[0031] In a possible design, monitoring the processing time of the lock holding thread by using the inspection thread of the time-limited lock includes:

[0032] When starting to process the locked thread, determining the time limit end time according to the current time and the time limit;

[0033] Setting the time limit end time to the inspection thread;

[0034] The inspection thread monitors whether the current time has reached the time limit end time.

[0035] In a second aspect, the present application provides a concurrent thread processing device, comprising:

[0036] A receiving module, used for receiving concurrent threads to be processed;

[0037] A time-limited lock module, used to manage the triggering logic of the concurrent threads to be processed;

[0038] A processing module, used for pressing the concurrent threads to be processed into the waiting queue submodule of the time-limited lock module;

[0039] The processing module is further used to determine the lock status of each concurrent thread to be processed in the waiting queue submodule by using a preset time-limited lock allocation model, wherein the lock status is used to characterize the thread processing time priority;

[0040] The processing module is further used to process the lock holding thread within the time limit set by the time limit lock module, and the lock holding thread is a thread whose lock holding state is the target state.

[0041] In a possible design, the thread processing time priority and the time limit satisfy a preset corresponding relationship.

[0042] Optionally, the processing module is used to push the concurrent threads to be processed into the waiting queue submodule of the time-limited lock module, including:

[0043] The processing module is used to sort the concurrent threads to be processed according to a preset sorting algorithm to determine a concurrent thread sequence; the waiting queue is the concurrent thread sequence.

[0044] Optionally, the processing module is further used to determine the lock holding state of each concurrent thread to be processed in the waiting queue submodule by using a preset time-limited lock allocation model, including:

[0045] The processing module is also used to modify the locking state of the top N concurrent threads to be processed to the target state each time according to the arrangement order of each concurrent thread to be processed in the waiting queue; N is less than or equal to the number of concurrent threads to be processed in the waiting queue.

[0046] Optionally, N is equal to 1.

[0047] Further optionally, the target state includes a locked state, and the locked state is used to indicate a thread that needs to be processed immediately.

[0048] In a possible design, the processing module is further used to process the lock holding thread within the time limit set by the time limit lock module, including:

[0049] The processing module is further used to monitor the processing time of the lock holding thread by using the inspection thread submodule of the time-limited lock module;

[0050] The processing module is further configured to re-assign the lock holding thread using the preset time-limited lock allocation model if the processing time is less than the time limit.

[0051] In a possible design, the processing module is further used to push the concurrent thread corresponding to the lock holding thread into the exception queue submodule of the time-limited lock module if the processing time reaches the time limit;

[0052] The processing module is also used to designate the abnormal concurrent thread as the lock holding thread when the lock holding thread is re-designated next time if the inspection thread submodule monitors that the abnormal concurrent thread in the abnormal queue submodule meets the preset condition.

[0053] In one possible design, the processing module is also used to push the abnormal concurrent thread back into the waiting queue sub-module to wait again for the preset time-limited lock allocation model to designate it as the lock-holding thread when the patrol thread sub-module monitors that the processing time of the abnormal concurrent thread as the lock-holding thread reaches the time limit.

[0054] In a possible design, the processing module is further used to re-assign the lock holding thread, including:

[0055] The processing module is further used to set the lock state of the concurrent thread at a preset position in the waiting queue submodule or the abnormal queue submodule to a target state.

[0056] Optionally, before the processing module is further configured to monitor the processing time of the lock holding thread by using the inspection thread submodule of the time-limited lock, the processing module further includes:

[0057] Check whether the inspection thread exists, and if not, create the inspection thread.

[0058] In a possible design, the processing module is further used to monitor the processing time of the lock holding thread by using the inspection thread of the time-limited lock, including:

[0059] The processing module is further configured to determine a time limit end time according to the current time and the time limit time while starting to process the locked thread;

[0060] The processing module is further used to set the time limit end time to the inspection thread submodule;

[0061] The inspection thread submodule is used to monitor whether the current time has reached the time limit end time.

[0062] In a third aspect, the present application provides an electronic device, including:

[0063] A memory for storing program instructions;

[0064] The processor is used to call and execute the program instructions in the memory to execute any possible concurrent thread processing method provided by the first aspect.

[0065] In a fourth aspect, the present application provides a storage medium, wherein the readable storage medium stores a computer program, and the computer program is used to execute any possible concurrent thread processing method provided in the first aspect.

[0066] The present application provides a concurrent thread processing method, device, electronic device and storage medium, which first pushes the received concurrent threads to be processed into the waiting queue of the time-limited lock, then uses the preset time-limited lock allocation model to determine the lock holding state of each concurrent thread to be processed in the waiting queue, and then processes the locked thread within the time limit of the time-limited lock. By constraining the time each thread occupies the processor through the time-limited lock, the waiting time of the processor when the concurrent thread is abnormal is shortened, and the technical problem that the prior art lacks management tools and methods for abnormal threads, resulting in slow thread processing and thus affecting the concurrent processing performance of the entire system is solved, and the technical effect of improving the concurrent processing performance of the system is achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0067] In order to more clearly illustrate the technical solutions in the present application or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0068] Figure 1a-1b A schematic diagram of a scenario of processing concurrent thread congestion using the prior art provided in this application;

[0069] Figure 2 A schematic diagram of the principle of a concurrent thread processing method provided in an embodiment of the present application;

[0070] Figure 3 A flowchart of a concurrent thread processing method provided in an embodiment of the present application;

[0071] Figure 4 A flowchart of another concurrent thread processing method provided by this application;

[0072] Figure 5 A schematic diagram of the structure of a concurrent thread processing device provided by the present application;

[0073] Figure 6 A schematic diagram of the structure of an electronic device provided in this application. DETAILED DESCRIPTION

[0074] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work, including but not limited to the combination of multiple embodiments, belong to the scope of protection of this application.

[0075] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein, for example. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0076] In existing computer thread processing solutions, when faced with a large number of threads waiting to be processed in a short period of time, the general approach is to increase the processing capacity of the central processing unit (CPU) per unit time to speed up the processing of threads, or to take multi-core measures to increase multiple CPUs for parallel processing to increase the concurrent processing capability of the system.

[0077] However, the computing power of the CPU cannot be increased infinitely, and the processing solutions of multi-core CPUs are also facing cost pressure. In a large number of actual tests and surveys, it is found that in most cases, the computing power of the CPU is sufficient, but facing a large number of concurrent threads, it affects the concurrent processing capability of the system.

[0078] In order to improve the processing capability of the system when facing a large number of concurrent threads that surge in a short period of time, the present application proposes a concurrent thread processing method, which is described below in conjunction with the accompanying drawings.

[0079] Figure 1a-1b The following is a schematic diagram of a scenario in which the prior art provided by this application handles concurrent thread congestion. Figure 1a As shown, the resource allocation module 103 allocates the order of multiple concurrent threads 101 entering the central processing unit CPU 102. In the prior art, the resource allocation module 103 waits until the CPU 102 finishes processing the current thread before allocating the next thread for processing. However, when an exception occurs in the current thread processed by the CPU 102, the CPU 102 can only wait, which prolongs the processing time of a single thread and does not bring the computing power of the CPU 102 into full play, creating the illusion that the computing power of the CPU 102 is insufficient. Figure 1bAs shown, in the prior art, when thread congestion is generally found, the measures taken are to increase the parallel thread processing capability of CPU 102, such as multi-core solution, or multi-channel parallel processing thread, or to re-queue by self-destruction of the current thread to regenerate a new thread, so as to avoid the computing channel of CPU 102 being occupied. However, such processing methods may fall into an endless loop of infinitely increasing the processing capability of CPU 102, or the current thread is constantly destroyed and regenerated, resulting in the target task corresponding to the thread not being processed in time, thus affecting the user experience.

[0080] Without solving the above problem, the present application embodiment provides a concurrent thread processing method, the principle of which is as follows Figure 2 The specific steps are as shown in Figure 3 shown.

[0081] Figure 2 A schematic diagram of the principle of a concurrent thread processing method provided in an embodiment of the present application is shown as follows: Figure 2 As shown, the resource allocation module 103 pushes the concurrent thread 101 into the waiting queue 210 to form waiting threads 211-215, and adds a time-limited lock to the waiting thread 211 in the waiting queue. The CPU 102 processes the waiting thread 211 with the time-limited lock within the time limit 220. When the processing time exceeds the time limit 220, the time-limited lock of the waiting thread 211 will be released and then allocated to other waiting threads in the waiting queue 210, such as the waiting thread 212. The CPU 102 processes the new lock-holding thread, i.e., the waiting thread 212, within the time limit 220 again, and the unprocessed waiting thread 211 returns to the waiting queue to wait for reallocation to the time-limited lock. Only the waiting thread holding the time-limited lock will be processed by the CPU 102.

[0082] By introducing a time-limited lock, it is ensured that CPU102 can exert its computing power to the maximum extent, so that the thread progress of the waiting threads in the waiting queue can be quickly advanced, and the effect of simulating parallel processing channels with intensive serial short-term high CPU utilization is achieved. In this way, the computing power of CPU102 can be fully utilized, while the manufacturing cost of multi-core CPU or multi-channel CPU is reduced, and the parallel processing capability of the system is improved.

[0083] Figure 3 A flowchart of a concurrent thread processing method provided in an embodiment of the present application is shown as follows: Figure 3 As shown, the specific steps of the concurrent thread processing method include:

[0084] S301: Push the received concurrent threads to be processed into the waiting queue of the time-limited lock.

[0085] In this step, the time-limited lock is used to manage the trigger logic of the concurrent threads to be processed. Since in this embodiment, the CPU only processes the concurrent threads holding the time-limited lock, if the concurrent threads need to hold the lock, they must first enter the waiting queue and wait for allocation.

[0086] Specifically, when a pending concurrent thread is received, it is detected whether there are vacancies in the waiting queue of the time-limited lock. If so, the pending concurrent threads having the same number as the number of vacancies are pushed into the waiting queue according to a preset rule.

[0087] It should be noted that the preset rules include: the time when the concurrent threads to be processed are received, the importance weight index of the concurrent threads to be processed, and the like.

[0088] S302: Determine the lock holding status of each concurrent thread to be processed in the waiting queue by using a preset time-limited lock allocation model.

[0089] In this step, the lock holding state is used to characterize the thread processing time priority.

[0090] Specifically, when it is detected that the waiting queue is not empty and the central processor has no thread currently being processed, the lock holding state of at least one concurrent thread to be processed in the waiting queue is set to the target state.

[0091] In a possible implementation, the target state is a locked state, which indicates that the concurrent thread to be processed is the object holding the time-limited lock. The central processing unit only processes the thread holding the time-limited lock.

[0092] In another possible implementation, when it is detected that the waiting queue is not empty and the central processing unit is not currently processing a thread, all pending concurrent threads in the waiting queue are first sorted according to a preset order (such as the order of time received or the importance index of the target task corresponding to the thread), and then a time-limited lock is assigned to the first or first N (N is greater than or equal to 1) pending concurrent threads, that is, the lock state of the pending concurrent threads is set to a locked state.

[0093] It should be noted that the number of time-limited locks is related to the processing power of the CPU, and its number is limited and less than the total number of concurrent threads to be processed. This embodiment does not limit the number of time-limited locks, and technical personnel in this field can determine the number of time-limited locks according to actual conditions.

[0094] It should also be noted that this step is a step that is executed repeatedly in a loop. As long as the CPU is not processing a thread, or the time-limited lock of the currently processed thread is released due to the expiration of the time limit, or the currently processed thread has been processed within the time limit, the lock state will be reallocated.

[0095] For example, Figure 2 As shown, the different filling patterns of the pending threads 211-215 represent different priorities, and the locking state can be set for different concurrent threads according to the attribute characteristics of each concurrent thread, such as the importance weight of the target task, the thread generation time, the target task type, etc. And the preset time-limited lock allocation model directly enters the locked state and then allocates after the CPU processes the locked thread to specify the next locked thread, or the locking order of the next few locked threads. Because some threads have certain associations or must be executed in order, several pending concurrent threads can be assigned a locking order as a locking order set.

[0096] It should also be noted that in a possible design, the thread processing time priority and the time limit meet the preset corresponding relationship. For example: the first-level priority corresponds to a time limit of 2 minutes, and the second-level priority corresponds to a time limit of 30 seconds. In this way, the waiting time of the central processor when an exception occurs in a concurrent thread can be further adjusted more flexibly through the time priority, so that the waiting time can be allocated according to the importance of the target task corresponding to the concurrent thread, so as to improve the user experience of the system.

[0097] S303: Process the lock holding thread within the time limit of the time-limited lock.

[0098] In this step, the lock-holding thread is a thread whose lock-holding state is the target state. The central processing unit only processes the lock-holding thread, and the processing must be completed within the time limit. As long as the processing time reaches the time limit, the time-limited lock held by the current lock-holding thread will be released, that is, the current concurrent thread no longer holds the time-limited lock, and will be suspended regardless of whether it has been processed. The concurrent threads that have not been processed can be pushed back into the waiting queue, such as into the original sorting position, or pushed into the very end of the waiting queue. In a possible design, an exception queue can also be set separately or in a progress grouping queue set according to the process processing progress range. After the next time-limited lock is released, the preset time-limited lock allocation model will give priority to allocating the time-limited lock to the concurrent threads of the exception queue or the progress grouping queue.

[0099] The embodiment of the present application provides a concurrent thread processing method, which first pushes the received concurrent threads to be processed into the waiting queue of the time-limited lock, then uses the preset time-limited lock allocation model to determine the lock holding state of each concurrent thread to be processed in the waiting queue, and then processes the locked thread within the time limit of the time-limited lock. By constraining the time each thread occupies the processor through the time-limited lock, the waiting time of the processor when the concurrent thread is abnormal is shortened, and the technical problem that the prior art lacks management tools and methods for abnormal threads, resulting in slow thread processing and thus affecting the concurrent processing performance of the entire system is solved, and the technical effect of improving the concurrent processing performance of the system is achieved.

[0100] Figure 4 A flowchart of another concurrent thread processing method provided by this application. Figure 4 As shown, the specific steps of the concurrent thread processing method include:

[0101] S401: Push the received concurrent threads to be processed into the waiting queue of the time-limited lock.

[0102] In this step, specifically, it includes:

[0103] Sort the concurrent threads to be processed according to a preset sorting algorithm to determine the concurrent thread sequence;

[0104] The waiting queue is the concurrent thread sequence.

[0105] S402 , according to the arrangement order of each pending concurrent thread in the waiting queue, each time modifying the lock holding state of the top N pending concurrent threads to be processed to the target state.

[0106] In this step, N is less than or equal to the number of concurrent threads to be processed in the waiting queue.

[0107] In a possible implementation, the target state includes: a locked state. The locked state is used to indicate a thread that needs to be processed immediately.

[0108] It should be noted that the target state corresponds to the concurrent thread to be processed holding a time-limited lock or about to hold a time-limited lock, and only the concurrent thread holding the time-limited lock can be processed by the central processor within the next time limit.

[0109] In a possible implementation, N is equal to 1, that is, only the lock holding state of the concurrent thread to be processed ranked first is modified to the target state, that is, only the time-limited lock is allocated to the concurrent thread to be processed ranked first.

[0110] It should also be noted that the pending concurrent thread in the target state is a lock-holding thread.

[0111] S403: Detect whether there is a patrol thread, and if not, create the patrol thread.

[0112] In this embodiment, a patrol thread is used to monitor the time that concurrent threads hold time-limited locks to achieve the time-limited effect of the time-limited locks, thereby minimizing the waiting time of the central processing unit, thereby enabling the computing power of the central processing unit to be more fully utilized.

[0113] It should be noted that if it is detected that a patrol thread exists, there is no need to recreate the patrol thread, and step S404 is directly executed.

[0114] S404: Process the lock-holding thread within the time limit of the time-limited lock, and use the inspection thread of the time-limited lock to monitor the processing time of the lock-holding thread.

[0115] This step specifically includes:

[0116] When starting to process the lock-holding thread, determine the time limit end time according to the current time and the time limit;

[0117] Set the time limit end time to the inspection thread;

[0118] The inspection thread monitors whether the current time has reached the time limit end time.

[0119] S405: If the processing time is less than the time limit, reassign the lock holding thread using a preset time-limited lock allocation model.

[0120] In this step, when the CPU has processed the target task corresponding to the lock-holding thread within the time limit corresponding to the time-limited lock, the thread releases the time-limited lock after execution, and the next processing object needs to be specified for the CPU.

[0121] Reassign the lock holding thread, including:

[0122] Sets the lock holding state of the concurrent thread at a preset position in the waiting queue or exception queue to the target state.

[0123] It should be noted that, in this embodiment, when the processing time of the lock-holding thread reaches the time limit and has not been processed, the concurrent thread corresponding to the lock-holding thread is pressed into the exception queue. Under normal circumstances, the target task corresponding to the lock-holding thread can be completed within the time limit, but if an abnormal situation occurs in the lock-holding thread during the processing, such as the network is stuck and no feedback information is received, or the camera is damaged and cannot receive image data, etc., the lock-holding thread will be stuck in a certain step, which will make the required processing time greater than the time limit. Therefore, in this embodiment, an exception queue is set to specifically place such concurrent threads. In addition, for concurrent threads in the exception queue, they will be allocated first when the time-limited lock is allocated next time, so as to end the processed thread as soon as possible. For systems that require a single thread to be completed as soon as possible, this can improve the concurrent processing capability of the system while ensuring that the priority processing thread can be processed and completed as soon as possible.

[0124] S406: If the processing time reaches the time limit, the concurrent thread corresponding to the lock holding thread is pushed into the exception queue of the time-limited lock.

[0125] S407: The inspection thread monitors whether the abnormal concurrent threads in the abnormal queue meet preset conditions.

[0126] In this step, if the inspection thread detects that the abnormal concurrent thread in the abnormal queue meets the preset condition, the abnormal concurrent thread is designated as the lock holding thread when re-designating the lock holding thread in the next cycle of executing S405.

[0127] S408. When the inspection thread detects that the processing time of the abnormal concurrent thread as the lock holding thread reaches the time limit, the abnormal concurrent thread is pushed back into the waiting queue to wait again for the preset time-limited lock allocation model to designate it as the lock holding thread.

[0128] In this step, when the concurrent thread in the exception queue is assigned to the time-limited lock again and is processed by the central processing unit, an exception occurs again, or the previous exception has not been recovered, which proves that this exception requires a longer recovery time. Therefore, in this embodiment, when the time limit of the time-limited lock is reached again, the abnormal concurrent thread is put back into the waiting queue, such as being put at the end of the waiting queue to wait for the allocation of the time-limited lock. In this way, while taking into account the processing of other threads, sufficient recovery time is left for the abnormal concurrent thread.

[0129] The embodiment of the present application provides a concurrent thread processing method, which first pushes the received concurrent threads to be processed into the waiting queue of the time-limited lock, then uses the preset time-limited lock allocation model to determine the lock holding state of each concurrent thread to be processed in the waiting queue, and then processes the locked thread within the time limit of the time-limited lock. By constraining the time each thread occupies the processor through the time-limited lock, the waiting time of the processor when the concurrent thread is abnormal is shortened, and the technical problem that the prior art lacks management tools and methods for abnormal threads, resulting in slow thread processing and thus affecting the concurrent processing performance of the entire system is solved, and the technical effect of improving the concurrent processing performance of the system is achieved.

[0130] Figure 5 The schematic diagram of the structure of a concurrent thread processing device provided by the present application is as follows. The IoT firmware dynamic detection device 500 can be implemented by software, hardware or a combination of both.

[0131] like Figure 5 As shown, the IoT firmware dynamic detection device 500 includes:

[0132] Receiving module 501, used for receiving concurrent threads to be processed;

[0133] A time-limited lock module 502 is used to manage the triggering logic of the concurrent threads to be processed;

[0134] The processing module 503 is used to push the concurrent threads to be processed into the waiting queue submodule of the time-limited lock module;

[0135] The processing module 503 is further used to determine the lock status of each concurrent thread to be processed in the waiting queue submodule by using a preset time-limited lock allocation model, wherein the lock status is used to represent the thread processing time priority;

[0136] The processing module 503 is further configured to process the lock holding thread within the time limit set by the time limit lock module 502, wherein the lock holding thread is a thread whose lock holding state is the target state.

[0137] In a possible design, the thread processing time priority and the time limit satisfy a preset corresponding relationship.

[0138] Optionally, the processing module 503 is used to push the concurrent threads to be processed into the waiting queue submodule of the time-limited lock module, including:

[0139] The processing module 503 is used to sort the concurrent threads to be processed according to a preset sorting algorithm to determine a concurrent thread sequence; the waiting queue is the concurrent thread sequence.

[0140] Optionally, the processing module 503 is further configured to determine the lock holding status of each concurrent thread to be processed in the waiting queue submodule by using a preset time-limited lock allocation model, including:

[0141] The processing module 503 is also used to modify the locking state of the top N concurrent threads to be processed to the target state each time according to the arrangement order of each concurrent thread to be processed in the waiting queue; N is less than or equal to the number of concurrent threads to be processed in the waiting queue.

[0142] Optionally, N is equal to 1.

[0143] Further optionally, the target state includes a locked state, and the locked state is used to indicate a thread that needs to be processed immediately.

[0144] In a possible design, the processing module 503 is further used to process the lock holding thread within the time limit set by the time limit lock module 502, including:

[0145] The processing module 503 is further used to monitor the processing time of the lock holding thread by using the inspection thread submodule 5021 of the time-limited lock module 502;

[0146] The processing module 503 is further configured to re-assign the lock holding thread using the preset time-limited lock allocation model if the processing time is less than the time limit.

[0147] In a possible design, the processing module 503 is further used to push the concurrent thread corresponding to the lock holding thread into the exception queue submodule 5023 of the time-limited lock module 502 if the processing time reaches the time limit;

[0148] The processing module 503 is further configured to designate the abnormal concurrent thread as the lock holding thread when the lock holding thread is redesignated next time if the inspection thread submodule detects that the abnormal concurrent thread in the abnormal queue submodule meets a preset condition.

[0149] In one possible design, the processing module 503 is also used to push the abnormal concurrent thread back into the waiting queue submodule 5022 when the patrol thread submodule 5021 detects that the processing time of the abnormal concurrent thread as the lock holding thread reaches the time limit, and wait again for the preset time limit lock allocation model to designate it as the lock holding thread.

[0150] In a possible design, the processing module 503 is further used to re-assign the lock holding thread, including:

[0151] The processing module 503 is further configured to set the lock state of the concurrent thread at a preset position in the waiting queue submodule 5022 or the abnormal queue submodule 5023 to a target state.

[0152] Optionally, before the processing module 503 is further configured to monitor the processing time of the lock holding thread by using the inspection thread submodule 5021 of the time-limited lock module 502, the processing module 503 further includes:

[0153] Check whether the inspection thread exists, and if not, create the inspection thread.

[0154] In a possible design, the processing module 503 is further used to monitor the processing time of the lock holding thread by using the inspection thread submodule 5021 of the time-limited lock module 502, including:

[0155] The processing module 503 is further configured to determine a time limit end time according to the current time and the time limit time while starting to process the locked thread;

[0156] The processing module 503 is further used to set the time limit end time to the inspection thread submodule 5021;

[0157] The inspection thread submodule 5021 is used to monitor whether the current time has reached the time limit end time.

[0158] It is worth mentioning that Figure 5The concurrent thread processing device provided in the illustrated embodiment can execute the method provided in any of the above-mentioned method embodiments. Its specific implementation principles, technical features, professional terminology explanations and technical effects are similar and will not be repeated here.

[0159] Figure 6 This is a schematic diagram of the structure of an electronic device provided in this application. Figure 6 As shown, the electronic device 600 may include: at least one processor 601 and a memory 602 . Figure 6 An electronic device is shown using a processor as an example.

[0160] The memory 602 is used to store programs. Specifically, the programs may include program codes, and the program codes include computer operation instructions.

[0161] The memory 602 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0162] The processor 601 is used to execute the computer-executable instructions stored in the memory 602 to implement the methods described in the above method embodiments.

[0163] The processor 601 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application.

[0164] Optionally, the memory 602 may be independent or integrated with the processor 601. When the memory 602 is a device independent of the processor 601, the electronic device 600 may further include:

[0165] The bus 603 is used to connect the processor 601 and the memory 602. The bus can be an industry standard architecture (ISA) bus, a peripheral component interconnect (PCI) bus, or an extended industry standard architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc., but it does not mean that there is only one bus or one type of bus.

[0166] Optionally, in a specific implementation, if the memory 602 and the processor 601 are integrated on a chip, the memory 602 and the processor 601 can communicate through an internal interface.

[0167] The present application also provides a computer-readable storage medium, which may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, and other media that can store program codes. Specifically, the computer-readable storage medium stores program instructions, and the program instructions are used for the methods in the above-mentioned method embodiments.

[0168] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A concurrent thread processing method, characterized in that: include: Pushing the received concurrent threads to be processed into a waiting queue of a time-limited lock, where the time-limited lock is used to manage the triggering logic of the concurrent threads to be processed; Determining the lock state of each pending concurrent thread in the waiting queue by using a preset time-limited lock allocation model includes: modifying the lock state of the pending concurrent threads ranked in the top N positions as a target state each time according to the arrangement order of each pending concurrent thread in the waiting queue; the target state includes a locked state, and the locked state is used to indicate a thread that needs to be processed immediately; The N is less than or equal to the number of concurrent threads to be processed in the waiting queue; wherein the lock state is used to characterize the thread processing time priority; Processing a lock holding thread within the time limit of the time-limited lock, wherein the lock holding thread is a thread whose lock holding state is the target state; processing the lock holding thread within the time limit of the time-limited lock includes: monitoring the processing time of the lock holding thread by using the inspection thread of the time-limited lock; If the processing time reaches the time limit, the concurrent thread corresponding to the lock holding thread is pushed into the exception queue of the time-limited lock; If the inspection thread detects that the abnormal concurrent thread in the abnormal queue meets the preset condition, the abnormal concurrent thread is designated as the lock holding thread when the lock holding thread is re-designated next time.

2. The concurrent thread processing method according to claim 1, characterized in that: The thread processing time priority and the time limit satisfy a preset corresponding relationship.

3. The concurrent thread processing method according to claim 1, characterized in that: The step of pressing the received concurrent threads to be processed into the waiting queue of the time-limited lock includes: Sorting the pending concurrent threads according to a preset sorting algorithm to determine a concurrent thread sequence; The waiting queue is the concurrent thread sequence.

4. The concurrent thread processing method according to claim 1, characterized in that: The N is equal to 1.

5. The concurrent thread processing method according to claim 1, characterized in that: The processing of the lock holding thread within the time limit of the time-limited lock also includes: If the processing time is less than the time limit, the lock holding thread is reassigned using the preset time-limited lock allocation model.

6. The concurrent thread processing method according to claim 1, characterized in that: Also includes: When the inspection thread monitors that the processing time of the abnormal concurrent thread as the lock holding thread reaches the time limit, the abnormal concurrent thread is pushed back into the waiting queue to wait again for the preset time-limited lock allocation model to designate it as the lock holding thread.

7. The concurrent thread processing method according to claim 6, characterized in that: The reassigning of the lock holding thread comprises: The lock state of the concurrent thread at a preset position in the waiting queue or the exception queue is set as a target state.

8. The concurrent thread processing method according to any one of claims 5 to 7, characterized in that: Before the inspection thread of the time-limited lock is used to monitor the processing time of the lock holding thread, the method further includes: Check whether the inspection thread exists, and if not, create the inspection thread.

9. The concurrent thread processing method according to claim 5, characterized in that: The monitoring of the processing time of the lock holding thread by using the inspection thread of the time-limited lock includes: When starting to process the locked thread, determining the time limit end time according to the current time and the time limit; Setting the time limit end time to the inspection thread; The inspection thread monitors whether the current time has reached the time limit end time.

10. A concurrent thread processing device, characterized in that: include: A receiving module, used for receiving concurrent threads to be processed; A time-limited lock module, used to manage the triggering logic of the concurrent threads to be processed; A processing module, used for pressing the concurrent threads to be processed into the waiting queue submodule of the time-limited lock module; The processing module is further used to determine the lock status of each concurrent thread to be processed in the waiting queue submodule by using a preset time-limited lock allocation model, wherein the lock status is used to characterize the thread processing time priority; The processing module is further used to process the lock holding thread within the time limit set by the time limit lock module, and the lock holding thread is a thread whose lock holding state is the target state; The processing module is specifically used to modify the locking state of the top N concurrent threads to be processed to the target state each time according to the arrangement order of each concurrent thread to be processed in the waiting queue; N is less than or equal to the number of concurrent threads to be processed in the waiting queue; the target state includes a locked state, and the locked state is used to indicate a thread that needs to be processed immediately; The processing module is also used to use the patrol thread of the time-limited lock to monitor the processing time of the lock-holding thread; if the processing time reaches the time limit, the concurrent thread corresponding to the lock-holding thread is pushed into the exception queue submodule of the time-limited lock module; if the patrol thread submodule monitors that the abnormal concurrent thread in the exception queue submodule meets the preset conditions, the abnormal concurrent thread is designated as the lock-holding thread when the lock-holding thread is re-designated next time.

11. An electronic device, characterized in that: include: processor; as well as, A memory, configured to store executable instructions of the processor; The processor is configured to execute the concurrent thread processing method according to any one of claims 1 to 9 by executing the executable instructions.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the concurrent thread processing method according to any one of claims 1 to 9 is implemented.

13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the concurrent thread processing method according to any one of claims 1 to 9 is implemented.