CN117573355A - Task processing method, device, electronic equipment and storage medium - Google Patents

Task processing method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117573355A
CN117573355A CN202311580192.3A CN202311580192A CN117573355A CN 117573355 A CN117573355 A CN 117573355A CN 202311580192 A CN202311580192 A CN 202311580192A CN 117573355 A CN117573355 A CN 117573355A
Authority
CN
China
Prior art keywords
task
work
processing
target work
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311580192.3A
Other languages
Chinese (zh)
Inventor
黄再漾
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Oppo Mobile Telecommunications Corp Ltd filed Critical Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority to CN202311580192.3A priority Critical patent/CN117573355A/en
Publication of CN117573355A publication Critical patent/CN117573355A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5011Pool
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5018Thread allocation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application discloses a task processing method, a task processing device, electronic equipment and a storage medium, and relates to the technical field of electronic equipment. The method comprises the following steps: and responding to the processing request aiming at the target work task, adding the target work task into the work queue, recording the timestamp when the target work task is added into the work queue as a first timestamp, recording the timestamp when the target work task is taken out from the work queue by the first worker thread as a second timestamp, determining the waiting time of the target work task in the work queue based on the first timestamp and the second timestamp, and generating first abnormal information if the waiting time exceeds a waiting time threshold value. According to the method and the device for processing the task, the waiting time of the task is calculated through the enqueue time stamp and the dequeue time stamp of the task, and the abnormal information is generated under the condition that the waiting time is too long, so that analysis and positioning efficiency of the overtime problem can be improved, and maintainability of a system is improved.

Description

Task processing method, device, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of electronic devices, and in particular, to a task processing method, an apparatus, an electronic device, and a storage medium.
Background
With the development of science and technology, electronic devices are increasingly widely used, and have more and more functions, and become one of the necessities in daily life. At present, an electronic device can be used for processing tasks, but a problem of overtime of task processing is easy to occur, and positioning of the problem of overtime of task processing becomes a difficult point, so that the maintainability of a system is poor.
Disclosure of Invention
In view of the above problems, the present application proposes a task processing method, apparatus, electronic device, and storage medium, so as to solve the above problems.
In a first aspect, an embodiment of the present application provides a task processing method, where the method includes: responding to a processing request aiming at a target work task, adding the target work task into a work queue, and recording a time stamp when the target work task is added into the work queue as a first time stamp; if the first worker thread takes out the target work task from the work queue, recording a time stamp taken out of the work queue by the target work task as a second time stamp; determining a waiting time length of the target work task in the work queue based on the first timestamp and the second timestamp; and if the waiting time exceeds a waiting time threshold, generating first abnormal information.
In a second aspect, an embodiment of the present application provides a task processing device, including: the first time stamp recording module is used for responding to a processing request aiming at a target work task, adding the target work task into a work queue, and recording a time stamp when the target work task is added into the work queue as a first time stamp; the second time stamp recording module is used for recording the time stamp of the target work task taken out of the work queue as a second time stamp if the first worker thread takes out the target work task from the work queue; the waiting time length determining module is used for determining the waiting time length of the target work task in the work queue based on the first timestamp and the second timestamp; the first abnormal information generation module is used for generating first abnormal information if the waiting time exceeds a waiting time threshold.
In a third aspect, embodiments of the present application provide an electronic device comprising a memory coupled to a processor and a processor, the memory storing instructions that when executed by the processor perform the above-described method.
In a fourth aspect, embodiments of the present application provide a computer readable storage medium having program code stored therein, the program code being callable by a processor to perform the above method.
According to the task processing method, the device, the electronic equipment and the storage medium, a target work task is added into a work queue in response to a processing request for the target work task, a timestamp when the target work task is added into the work queue is recorded as a first timestamp, if a first worker thread takes out the target work task from the work queue, the timestamp taken out of the work queue by the target work task is recorded as a second timestamp, the waiting time of the target work task in the work queue is determined based on the first timestamp and the second timestamp, if the waiting time exceeds a waiting time threshold, first abnormal information is generated, so that the waiting time of the task is calculated through the enqueuing timestamp and the dequeuing timestamp of the task, and abnormal information is generated under the condition that the waiting time is too long, analysis and positioning efficiency of a timeout problem can be improved, and maintainability of a system is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the description of the embodiments will be briefly introduced below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart illustrating a task processing method according to an embodiment of the present application;
FIG. 2 is a flow chart illustrating a task processing method according to an embodiment of the present application;
FIG. 3 is a flow chart illustrating a task processing method according to an embodiment of the present application;
FIG. 4 shows a block diagram of a task processing device according to an embodiment of the present application;
FIG. 5 shows a block diagram of an electronic device for performing a task processing method according to an embodiment of the present application;
fig. 6 shows a storage unit for storing or carrying program codes for implementing the task processing method according to the embodiment of the present application.
Detailed Description
In order to enable those skilled in the art to better understand the present application, the following description will make clear and complete descriptions of the technical solutions in the embodiments of the present application with reference to the accompanying drawings in the embodiments of the present application.
The general relationship among the 5 main bodies of the work task, the work queue, the worker thread pool and the suspended work queue PWQ is as follows: a PWQ is created for each CPU in the work queue, and the PWQ is connected with the work queue and the target thread pool which correspond well, and the thread pool and the CPU are bound.
The corresponding structure of the work queue is work queue_struct, and all work tasks are hung in the work queue. The system defaults to creating some shared work queues, and the kernel also provides the relevant structure for the developer to create its own work queues.
A work task corresponds to a work_struct or delayed_work structure, representing a task; wherein, the work tasks are all scheduled in a delayed manner: scheduling a work task by default, delaying when the worker thread is scheduled to be executed; it is also possible to use a specific deferred work task, specifying how long later a work task is scheduled for execution by the worker thread, the deferred work queue internal implementation depending on a timer.
A worker thread is a kernel thread that is used to perform all of the work tasks in a work queue. Worker threads typically have two manifestations: single Thread (ST): in the system scope, only one worker thread serves the work queue. Multiwired (MT): on a multi-CPU system, one worker thread is on each CPU to service a work queue. The creation of worker threads is essentially free of developer care, and the worker threads are created from the creation of the work queue in a straight line. Only care needs to be taken whether ST or MT is required.
A pool of worker threads is a collection of worker threads, the number of which may be dynamically varied. To implement a pool of worker threads, for each worker thread, the Linux kernel encapsulates a fabric worker for worker thread management. It is defined in workqueue_internal.h, and the name of the header file can also be seen to be used inside the kernel, and the developer does not need to use this structure.
When the driver module plugs a task into the task queue through the associated interface API, the worker thread wakes up and begins processing the task in the queue.
It can be appreciated that the work queue mechanism in Linux is an implementation of the lower half of the interrupt, and is also a common task asynchronous processing means because it supports processing multiple small tasks with one thread, which is beneficial to reducing resource overhead. Often developers will process high real-time (subtle or milliseconds) traffic in the upper half of the interrupt and put some traffic with lower real-time requirements into the work queue for processing (hundreds of milliseconds or more).
Although the work queue is used for some services with low real-time requirements in the actual use scene, the services are not represented and can be delayed for a indefinite period; once a job task is processed too slowly, which can affect the response time of a particular service, it can be serious to cause some services to become stuck completely for a period of time, resulting in the user not having access to the relevant service functions for the intended time.
The following is a specific example:
if usb is plugged, the usb line is plugged and pulled out physically to generate an interrupt, but in the interrupt processing function, only the information such as a hardware state flag is needed to be processed simply, then the link of the software layer is disconnected, the heavy transaction related to the software is packaged into a work task to be processed by a work queue, and the work task is expected to be processed and notified to the user interaction interface application within 500 milliseconds, so that the user can sense the change of the usb link state in expected time. However, as the workload is used for realizing the characteristics of multi-task concurrency, delayed asynchronous execution and the like; execution of tasks runs completely in the process context, allowing rescheduling and sleeping, so that a work with a changed connection state of usb processing cannot necessarily be guaranteed to be processed to completion within 500 milliseconds; users may complain about the usb state update delay. Factors that influence the completion of the usb work that can be performed within 500 milliseconds may be:
1. the system load is heavier, and the worker thread is blocked by other tasks with higher priority as a common process, so that the CPU time slices cannot be obtained in time.
2. The logical problem of the other work tasks themselves of the first enqueue causes the worker thread to block while processing the other work tasks, where the time of blocking is not controllable.
Therefore, at least the following technical problems exist at present:
1. the time from job enqueuing to worker thread dequeuing a job from the queue is not guaranteed.
2. The task processing function is a specific business logic, and the business logic itself has internal resource dependence, so that the processing time of a specific task is uncontrollable, and can be blocked for a certain time, even if a specific business program exists in the BUG, the BUG can be blocked forever.
3. Lack of enqueue and dequeue time management for work tasks, lack of work task processing time monitoring and processing timeout processing.
In order to solve the problems, the inventor discovers through long-term research and puts forward the task processing method, the device, the electronic equipment and the storage medium, and calculates the waiting time of the task through the enqueuing time stamp and the dequeue time stamp of the task, and generates abnormal information under the condition that the waiting time is too long, so that the analysis and positioning efficiency of the overtime problem can be improved, and the maintainability of the system is improved. The specific task processing method is described in detail in the following embodiments.
The following will describe terms that may be used for the task processing methods provided in the embodiments of the present application.
Electronic equipment: such as smart phones and tablet computers;
and (3) a kernel: if the Android system is operated on the basis of a Linux kernel;
work queue: a work task (work) is a task entity, and a developer can plug the work task which needs to be executed after delay into a work queue (work queue) to be delivered;
work tasks: is also generally one way to implement bottom half; the kernel subsystem or the driver can give the deferrable task to the kworker thread through a work queue to schedule and execute; the workqueue runs completely within the process context, allowing it to be rescheduled and asleep. Known as concurrency management work queues (concurrency managed workqueue);
worker thread: a worker thread (worker) is an entity for processing execution of a work task, and continuously takes out the task in the work queue for processing as long as the work queue is not empty yet;
and (3) a timer: the kernel timer is a mechanism used by the kernel to control the scheduling of executing a function at a future point in time (based on the jitter), and when the timing time of the kernel timer arrives, the kernel timer enters a function designated by a user and is equivalent to soft interrupt;
interrupt upper half: the upper interrupt handler receives an interrupt and immediately starts execution, but only works with strict time limit;
Interrupt lower half: corresponding to the upper half, asynchronous processing does not need strict time-limited work;
asynchronous execution: synchronous operation refers to that when a program executes a task, the program must wait for the task to complete before the program can continue to execute the next task. In the synchronous operation, the program waits until a certain operation is completed before executing the next operation. Such modes of operation often cause blocking and the program may take a long time to continue to run. Asynchronous operation refers to a program that, when executing a task, may simultaneously execute other tasks. The program returns immediately in asynchronous operation and performs tasks in the background;
scheduling: in an operating system, generally referred to as a process scheduler, the general principle is that, according to the required distributed CPU computing capacity, a CPU resource management program that provides maximum fairness for each process in the system according to a certain policy and can also consider the real-time performance of a specific service;
BUG: usually referred to as a program error;
time slice: a time slice (timer), also called "quantum" or "processor slice", is a period of CPU time allocated by the time-sharing operating system to each running process on a microscopic scale (in the preempting kernel: the time from the start of running of the process until preempted);
Timestamp: typically a sequence of characters, uniquely identifying a time at a moment.
Referring to fig. 1, fig. 1 is a flow chart illustrating a task processing method according to an embodiment of the present application. The method is used for calculating the waiting time of the task through the enqueue time stamp and the dequeue time stamp of the task and generating the abnormal information under the condition that the waiting time is too long, so that the analysis and positioning efficiency of the overtime problem can be improved, and the maintainability of the system is improved. In a specific embodiment, the task processing method is applied to the task processing device 200 shown in fig. 4 and the electronic apparatus 100 (fig. 5) configured with the task processing device 200. The specific flow of the present embodiment will be described below by taking an electronic device as an example, and it will be understood that the electronic device applied in the present embodiment may include a smart phone, a tablet computer, a wearable electronic device, and the like, which is not limited herein. The following details about the flow shown in fig. 1, the task processing method specifically may include the following steps:
step S110: and responding to the processing request aiming at the target work task, adding the target work task into a work queue, and recording the time stamp when the target work task is added into the work queue as a first time stamp.
In this embodiment, it may be detected whether a processing request for a target work task is received. If it is determined that the processing request for the target work task is received, the target work task may be added to the work queue in response to the processing request for the target work task, and a timestamp of the work task added to the work queue may be recorded as the first timestamp. Wherein the work queue may include one or more work tasks therein.
In some implementations, it may be determined whether the electronic device generates a new work task, and if it is determined that the new work task is generated, the new work task is determined to be a target work task and a processing request for the target work task is generated. Alternatively, if it is determined that the operating system of the electronic device is updated (e.g., new functionality, fix bugs, improve performance, etc.), then it may be determined to generate new work tasks; if the electronic equipment is determined to have the installation of a new application program, a new work task can be determined to be generated; if the electronic equipment is determined to have the reception of mails and messages, the generation of a new work task can be determined; if the user corresponding to the electronic equipment is determined to have the change of the user behavior, a new work task can be determined to be generated; if it is determined that the electronic device has a USB plug, a new task may be determined to be generated, which is not limited herein.
As an implementation manner, the electronic device may register a callback function in advance through a kernel mechanism, and subsequently, may generate a processing request for the target work task by triggering a callback.
In some implementations, the electronic device may include a driver module, and adding the target work task to the work queue may include: the target work task is added to the work queue by the driver module. Alternatively, the target work task may be added to the work queue by the driver module through an associated API. Wherein, when adding the target work task into the work queue, a unique identifier can be allocated to the target work task for subsequent execution and tracking of the target work task.
In some implementations, a work queue that is adapted to a target work task may be found in response to a processing request for the target work task and the target work task may be added to the work queue that is adapted thereto. The work queue may be an array, a linked list or a queue, etc. of data structures, which are used to store detailed information and execution status of the target work task.
As one implementation, finding a work queue that is adapted to the target work task may include: randomly selecting one work queue to be selected from a plurality of work queues to be selected as a work queue matched with a target work task; determining the emergency degree of a target work task, and selecting one work queue to be selected from a plurality of work queues to be selected according to the emergency degree as a work queue matched with the target work task; the task type of the target task is determined, and one to-be-selected work queue is selected as a work queue adapted to the target task from a plurality of to-be-selected work queues according to the task type, and the like, which is not limited herein.
Taking a work queue to be selected from a plurality of work queues to be selected as a work queue matched with a target work task according to the emergency degree as an example, if the emergency degree indicates that the target work task needs to be processed and completed as soon as possible, one work queue to be selected with the least work task is selected from the plurality of work queues to be selected as the work queue matched with the target work task; if the emergency degree characterizes that the target work task does not need to be processed and completed as soon as possible, one work queue to be selected can be randomly selected from a plurality of work queues to be selected as a work queue matched with the target work task.
Taking a task type as an example, selecting one to-be-selected work queue from a plurality of to-be-selected work queues according to the task type, and if the task type meets a preset task type, selecting one to-be-selected work queue with the least work task from the plurality of to-be-selected work queues as a work queue matched with the target work task; if the task type does not meet the preset task type, one to-be-selected work queue can be randomly selected from a plurality of to-be-selected work queues to be used as the work queue adapted to the target work task.
In some embodiments, the timestamp of the target work task's addition to the work queue may be recorded by way of an added field. As shown in table 1 below, a job task corresponds to a struct work_struct, and a field may be correspondingly added to record a time stamp (enqueue time) when a target job task joins the job queue as the first time stamp.
TABLE 1
Step S120: and if the first worker thread fetches the target work task from the work queue, recording the time stamp fetched by the target work task from the work queue as a second time stamp.
Optionally, the work queue corresponds to a first worker thread, i.e., a work task is fetched from the work queue by the first worker thread and the fetched work task is processed until the work queue is empty.
In this embodiment, in the case of adding a target work task to the work queue, the first worker thread may wait to fetch the target work task from the work queue for processing. Based on the above, in the process of waiting for the first worker thread to take out the target work task from the work queue for processing, whether the first worker thread takes out the target work task from the work queue or not can be detected, and if the first worker thread is determined to take out the target work task from the work queue, a timestamp of the target work task taken out from the work queue can be recorded as a second timestamp; if it is determined that the first worker thread does not fetch the target work task from the work queue, the method may continue to detect whether the first worker thread fetches the target work task from the work queue until it is determined that the first worker thread fetches the target work task from the work queue, and record a timestamp of the fetching of the target work task from the work queue as the second timestamp.
In some implementations, it may be determined whether the first worker thread is to fetch the target work task from the work queue by detecting whether an identifier of the target work task is in the work queue; determining whether the first worker thread takes out the target work task from the work queue by detecting the task state of the target work task; whether the first worker thread is to fetch the target work task from the work queue, etc., may be determined by a lock mechanism, and is not limited in this regard.
In some embodiments, the timestamp of the target work task's retrieval from the work queue may be recorded by way of adding a field. As shown in table 1, the task corresponds to a struct work_struct, and a time stamp (dequeue time) of the target task taken out from the work queue may be correspondingly added as the second time stamp.
In some embodiments, in the case of adding a target work task to the work queue, it may be determined whether a new worker thread needs to be awakened, if so, a first worker thread in the pool of worker threads may be awakened, and in the case of the first worker thread being awakened, the work task may be removed from the work queue by the first worker thread for processing, e.g., the target work task may be removed from the work queue by the first worker thread for processing.
Step S130: and determining the waiting time length of the target work task in the work queue based on the first timestamp and the second timestamp.
In this embodiment, in the case of obtaining the first timestamp and the second timestamp, the waiting time period of the target work task in the task queue may be determined based on the first timestamp and the second timestamp.
In some embodiments, in the case of obtaining the first timestamp and the second timestamp, the first timestamp and the second timestamp may be compared to determine a waiting time of the target work task in the work queue. Alternatively, in the case of obtaining the first timestamp and the second timestamp, the first timestamp difference may be obtained by subtracting the first timestamp from the second timestamp, and determining the first timestamp difference as the waiting time of the target task in the work queue.
Step S140: and if the waiting time exceeds a waiting time threshold, generating first abnormal information.
In some embodiments, the electronic device may set and store a waiting time period threshold, where the waiting time period threshold is used as a basis for determining a waiting time period of the target task in the work queue. Therefore, in the present embodiment, in the case where the waiting time period is determined, the waiting time period may be compared with the waiting time period threshold to determine whether the waiting time period exceeds the waiting time period threshold. If the waiting time length is determined to be greater than the waiting time length threshold, determining that the waiting time length exceeds the waiting time length threshold; if the waiting time period is less than or equal to the waiting time period threshold value, it can be determined that the waiting time period does not exceed the waiting time period threshold value.
If the waiting time length exceeds the waiting time length threshold, it can be determined that the waiting time length of the target work task in the work queue is too long, it can be determined that the waiting of the target work task is abnormal, and first abnormal information can be generated; if the waiting time is determined not to exceed the waiting time threshold, the waiting time of the target work task in the work queue is determined to be moderate, the waiting of the target work task is determined to be abnormal, and abnormal information is not generated.
In some embodiments, in the case of generating the first abnormality information, the first abnormality information may be saved. Alternatively, the first anomaly information may be persisted, for example, the first anomaly information may be saved in a file read-write manner; or the first abnormal information is stored in a read-write mode of the block device. Subsequently, the first exception information may be uploaded to a server for exception handling or repair. Based on this, the cause of the target job task waiting timeout can be determined: such as determining whether a wait timeout due to the service code BUG, determining whether a wait timeout due to hardware performance, etc., are not limited herein.
As an implementation manner, the waiting time period threshold may be set in advance according to an empirical value, and the waiting time period thresholds corresponding to the plurality of work tasks in the work queue may be equal or unequal, which is not limited herein.
As still another implementation manner, a task type corresponding to the target work task may be determined, and based on the task type, a waiting time length threshold corresponding to the target work task is determined, that is, an adaptive waiting time length threshold may be set for the target work task according to the task type of the target work task, so that the rationality of the set waiting time length threshold may be improved, and the probability of timeout erroneous judgment may be reduced.
In some implementations, a plurality of work tasks are included in the work queue, which may include the target work task. If a plurality of work tasks in the work queue are all taken out from the work queue, the waiting time of each of the plurality of work tasks in the work queue can be determined, the average waiting time corresponding to the plurality of work tasks is determined based on the waiting time of each of the plurality of work tasks in the work queue, and the processing energy efficiency of the first processing core where the work queue is located for the plurality of work tasks is determined based on the average waiting time. If the average waiting time length is less than or equal to the first time length threshold value, the processing energy efficiency of the first processing core for a plurality of work tasks can be determined to be higher; if the average waiting time is greater than the first time threshold, it may be determined that the processing energy efficiency of the first processing core for the plurality of work tasks is low.
According to the task processing method provided by the embodiment of the application, the target work task is added into the work queue in response to the processing request aiming at the target work task, the timestamp when the target work task is added into the work queue is recorded as the first timestamp, if the first worker thread takes out the target work task from the work queue, the timestamp taken out by the target work task from the work queue is recorded as the second timestamp, the waiting time of the target work task in the work queue is determined based on the first timestamp and the second timestamp, if the waiting time exceeds the waiting time threshold, the first abnormal information is generated, so that the waiting time of the task is calculated through the enqueuing timestamp and the dequeuing timestamp of the task, and abnormal information is generated under the condition that the waiting time is overlong, the analysis positioning efficiency of the overtime problem can be improved, and the maintainability of the system is improved.
Referring to fig. 2, fig. 2 is a flow chart illustrating a task processing method according to an embodiment of the present application. The following details about the flow shown in fig. 2, the task processing method specifically may include the following steps:
step S210: and responding to the processing request aiming at the target work task, adding the target work task into a work queue, and recording the time stamp when the target work task is added into the work queue as a first time stamp.
Step S220: and if the first worker thread fetches the target work task from the work queue, recording the time stamp fetched by the target work task from the work queue as a second time stamp.
Step S230: and determining the waiting time length of the target work task in the work queue based on the first timestamp and the second timestamp.
Step S240: and if the waiting time exceeds a waiting time threshold, generating first abnormal information.
The specific description of step S210 to step S240 refer to step S110 to step S140, and are not described herein.
Step S250: and if the first worker thread finishes processing the target work task, recording the time stamp of the processed target work task as a third time stamp.
In this embodiment, the first worker thread may begin processing the target work task if it is to be fetched from the work queue. Based on the above, in the process of processing the target work task by the first worker thread, whether the first worker thread processes the target work task or not can be detected, and if the first worker thread is determined to process the target work task, a timestamp that the target work task is processed can be recorded as a third timestamp; if it is determined that the first worker thread has not processed the target work task, the method may continue to detect whether the first worker thread has processed the target work task until it is determined that the first worker thread has processed the target work task, and record a timestamp that the target work task has been processed as a third timestamp.
In some implementations, it may be determined whether the first worker thread has processed the target work task by detecting whether the identifier of the target work task has been deleted; determining whether the first worker thread has processed the target work task by detecting the task state of the target work task; whether the first worker thread has processed the target work task or not may be determined by detecting a return value of the first worker thread when processing the task, and the like, which is not limited herein.
In some embodiments, the timestamp that the target job task is processed may be recorded by adding a field. As shown in table 1, the task corresponds to one struct work_struct, and a time stamp (processing end time) when the target task is processed can be added as the third time stamp.
Step S260: based on the second timestamp and the third timestamp, a processing duration of the target work task in the first worker thread is determined.
In this embodiment, in the case where the second timestamp and the third timestamp are obtained, the processing duration of the target work task in the first worker thread may be determined based on the second timestamp and the third timestamp.
In some embodiments, where the second timestamp and the third timestamp are obtained, the second timestamp and the third timestamp may be compared to determine a processing duration of the target work task in the first worker thread. Alternatively, in the case of obtaining the second timestamp and the third timestamp, the second timestamp may be subtracted from the third timestamp to obtain a second timestamp difference, and the second timestamp difference may be determined as a processing duration of the target work task in the first worker thread.
Step S270: and if the processing duration exceeds the processing duration threshold, generating second abnormal information.
In some embodiments, the electronic device may set and store a processing duration threshold that is used as a basis for determining a processing duration of the target work task in the first worker thread. Therefore, in the present embodiment, in the case of determining the processing time period, the processing time period may be compared with the processing time period threshold value to determine whether the processing time period exceeds the processing time period threshold value. If the processing time length is determined to be greater than the processing time length threshold, determining that the waiting time length exceeds the processing time length threshold; if the processing duration is determined to be less than or equal to the processing duration threshold, it may be determined that the processing duration does not exceed the processing duration threshold.
If the processing time length exceeds the processing time length threshold, the processing time length of the target work task in the first worker thread can be determined to be too long, the processing of the target work task can be determined to be abnormal, and second abnormal information can be generated; if the processing time length is not determined to exceed the processing time length threshold, the processing time length of the target work task in the first worker thread can be determined to be moderate, the processing of the target work task can be determined to be abnormal, and abnormal information can be generated.
In some embodiments, in the case of generating the second abnormality information, the second abnormality information may be saved. Alternatively, the second abnormal information may be persisted, for example, the second normal information may be saved in a file read-write manner; or the second abnormal information is stored in a read-write mode of the block device. Subsequently, the second exception information may be uploaded to a server for exception handling or repair. Based on this, the cause of the target job task processing timeout can be determined: such as determining whether the processing is timed out due to the service code BUG, determining whether the processing is timed out due to hardware performance, etc., are not limited herein.
As an implementation manner, the processing duration threshold may be set in advance according to an empirical value, and the processing duration thresholds corresponding to the plurality of work tasks in the work queue may be equal or unequal, which is not limited herein.
As still another implementation manner, a task type corresponding to the target work task may be determined, and based on the task type, a processing time threshold corresponding to the target work task may be determined, that is, an adapted processing time threshold may be set for the target work task according to the task type of the target work task, so as to improve the rationality of the set processing time threshold and reduce the probability of timeout erroneous judgment.
In some implementations, a plurality of work tasks are included in the work queue, which may include the target work task. If the plurality of work tasks in the work queue are processed and completed, the processing time length of each of the plurality of work tasks in the first worker thread can be determined, the average processing time length corresponding to the plurality of work tasks is determined based on the processing time length of each of the plurality of work tasks in the first worker thread, and the processing energy efficiency of the first processing core where the first worker thread is located for the plurality of work tasks is determined based on the average processing time length. If the average processing time length is less than or equal to the second time length threshold value, the processing energy efficiency of the first processing core for a plurality of work tasks can be determined to be higher; if the average processing time length is greater than the second time length threshold, it may be determined that the processing energy efficiency of the first processing core for the plurality of work tasks is low.
In the task processing method provided in an embodiment of the present application, compared with the task processing method shown in fig. 1, in this embodiment, when the first worker thread finishes processing the target task, a timestamp of the target task after being processed is recorded as a third timestamp, based on the second timestamp and the third timestamp, a processing duration of the target task in the first worker thread is determined, if the processing duration exceeds a processing duration threshold, second exception information is generated, so that the processing duration of the task is calculated through the task dequeue timestamp and the processing timestamp, and exception information is generated when the processing duration is too long, so that analysis positioning efficiency of a timeout problem can be improved, and maintainability of a system is improved.
Referring to fig. 3, fig. 3 is a flow chart illustrating a task processing method according to an embodiment of the present application. The following details about the flow shown in fig. 3, the task processing method specifically may include the following steps:
step S310: and responding to the processing request aiming at the target work task, adding the target work task into a work queue, and recording the time stamp when the target work task is added into the work queue as a first time stamp.
Step S320: and if the first worker thread fetches the target work task from the work queue, recording the time stamp fetched by the target work task from the work queue as a second time stamp.
Step S330: and determining the waiting time length of the target work task in the work queue based on the first timestamp and the second timestamp.
Step S340: and if the waiting time exceeds a waiting time threshold, generating first abnormal information.
The specific description of step S310 to step S340 refer to step S110 to step S140, and are not described herein.
Step S350: and if the first worker thread takes the target work task out of the work queue, starting a timer, wherein the timer is set with a specified duration.
In this embodiment, in the case of adding a target work task to the work queue, the first worker thread may wait to fetch the target work task from the work queue for processing. Based on the above, in the process of waiting for the first worker thread to take out the target work task from the work queue for processing, whether the first worker thread takes out the target work task from the work queue or not can be detected, and if the first worker thread is determined to take out the target work task from the work queue, a timer with a specified duration can be started; if it is determined that the first worker thread does not fetch the target work task from the work queue, the detection of whether the first worker thread fetches the target work task from the work queue may continue until a timer set with a specified duration is started when it is determined that the first worker thread fetches the target work task from the work queue.
As an implementation manner, the specified duration may be set in advance according to an empirical value, and the specified durations corresponding to the plurality of work tasks in the work queue may be equal or unequal, which is not limited herein.
As still another implementation manner, a task type corresponding to the target work task may be determined, and based on the task type, a specified duration corresponding to the target work task may be determined, that is, an adapted specified duration may be set for the target work task according to the task type of the target work task, so that the rationality of the set specified duration may be improved, and the probability of timeout erroneous judgment may be reduced.
As shown in the following table 2, a high-precision timer can be added to a worker thread, the high-precision timer is started when a work task is dequeued, the high-precision timer is canceled when the processing of the work task is completed, the situation that one work task is blocked permanently is prevented, and if the high-precision timer triggers overtime, the current processed work task is blocked for a long time; of course, this time may be specified by the service side (struct work_struct is added with a field for specifying the timeout time (specifying duration), if the time is 0, the default timeout time is used), after a task processing timeout, the related abnormal work task information and the call stack information of the worker thread are printed in the timer processing function.
TABLE 2
Step S360: and if the first worker thread finishes processing the target work task within the appointed time, closing the timer.
In this embodiment, in the event that a timer is started, then a timer is started and it is determined whether the first worker thread has completed the target work task within a specified duration.
If the first worker thread is determined to process the target work task within the specified time length, the first worker thread is characterized to process the target work task within the timeout time length set by the timer, and blocking is not caused, so that the timer can be closed.
Step S370: and if the first worker thread does not process the target work task within the specified duration, generating third abnormal information.
If it is determined that the first worker thread does not process the target work task within the specified duration, the first worker thread is characterized as not processing the target work task within the timeout duration set by the timer, blocking is caused, and third abnormal information can be generated.
In some embodiments, in the case of generating the third abnormality information, the third abnormality information may be saved. Alternatively, the third abnormality information may be persisted, for example, the third abnormality information may be saved in a file read-write manner; or the first storage abnormality information is stored in a read-write manner by the block device. Subsequently, the third exception information may be uploaded to a server for exception handling or repair. Based on this, the cause of the target job task processing blockage can be determined: such as determining whether to block processing due to the service code BUG, determining whether to block processing due to hardware performance, etc., are not limited herein.
In some implementations, generating the third anomaly information may include: the task information of the target work task and the call stack information of the first worker thread are acquired, third abnormal information is generated based on the task information and the call stack information, the generated third abnormal information comprises the task information and the call stack information, and when the abnormal repair is carried out subsequently, the information can be referred to more pertinently, so that the abnormal repair effect is improved.
In some embodiments, if it is determined that the first worker thread has not processed the target work task within the specified duration, determining other work tasks in the target work queue that are arranged after the target work task, determining state information of a first processing core in which the first worker thread is located, and processing the target work task and the other work tasks based on the state information. If the first worker thread does not process the target work task within the specified duration, the target work task in the work queue and other work tasks arranged after the target work task are characterized to be not processed, so that the target work task and other work tasks arranged after the target work task in the target work queue can be acquired for processing.
As an implementation manner, the state information of the first processing core where the first worker thread is located may be checked by a command line, the state information of the first processing core where the first worker thread is located may be checked by a third party software, and the like, which is not limited herein.
As one implementation, processing the target work task and other work tasks based on the status information may include: based on the state information, the target work task and other work tasks are maintained to continue processing on the first processing core, or based on the state information, the target work task and other work tasks are switched to processing on a second processing core different from the first processing core. Optionally, based on the status information, maintaining the target work task and other work tasks to continue processing on the first processing core may include: based on the state information, the target work task and other work tasks are maintained to continue processing on a first worker thread of the first processing core or are switched to processing on a second worker thread of the first processing core different from the first worker thread.
Alternatively, the first processing core may be running a pool of worker threads, which may include a first worker thread, a second worker thread … …, and an nth worker thread. In some implementations, processing the target work task and other work tasks based on the status information may include: based on the state information, the number of worker threads in a non-working state in a worker thread pool corresponding to the first processing core is determined, and based on the number, the target work task and other work tasks are processed. Wherein worker threads in the pool of worker threads are inactive due to being killed by processing work tasks. As an example, assuming 5 worker threads are included in the worker thread pool, it may be determined whether the 5 worker threads are inactive to determine the number of worker threads in the worker thread pool that are inactive.
In some implementations, processing the target work task and other work tasks based on the quantity may include: if the number exceeds the number threshold, migrating the target work task and other work tasks to a work queue of the second processing core for processing; alternatively, if the number does not exceed the number threshold, the target work task and other work tasks are processed by a second worker thread in the pool of worker threads.
As an implementation manner, the electronic device may preset and store a number threshold, where the number threshold is used as a basis for determining the number of worker threads in the inactive state in the worker thread pool corresponding to the first processing core, and therefore, when the number of worker threads in the inactive state in the worker thread pool corresponding to the first processing core is the number, the number may be compared with the number threshold. If the number of the characterization results exceeds the number threshold, the number of the worker threads which are killed in the first processing core can be considered to be too large, and the processing capacity of the first processing core is abnormal, so that the target work task and other work tasks can be migrated to the work queue of the second processing core for processing. If the number of the characterization results does not exceed the number threshold, the number of the worker threads which are killed in the first processing core is less, and the processing capacity of the first processing core is normal, so that the target work task and other work tasks can be processed through the second worker thread in the worker thread pool.
Compared with the task processing method shown in fig. 1, in the task processing method provided by the embodiment of the present application, in the case that the first worker thread takes out the target task from the work queue, a timer is started, where the timer is set with a specified duration, if the first worker thread finishes processing the target task within the specified duration, the timer is closed, and if the first worker thread does not finish processing the target task within the specified duration, third abnormal information is generated, so that permanent blocking of the task can be prevented, and performance of the system is improved.
In summary, the embodiment of the application can calculate the waiting time of the task in the queue, the operation processing time and the abnormal condition of whether the task is seriously blocked or not according to the time stamps of the links, so that the processing efficiency of the work task, the blocking condition of a certain work task on other work tasks of the system and even the condition of whether a certain work task is to be locked or not can be timely detected; the analysis and positioning efficiency of the overtime problem is greatly improved, and the maintainability of the system is improved.
Referring to fig. 4, fig. 4 is a block diagram of a task processing device according to an embodiment of the present application. The task processing device 200 includes, as will be explained below with respect to the block diagram shown in fig. 4: a first timestamp recording module 210, a second timestamp recording module 220, a waiting duration determining module 230, and a first anomaly information generating module 240, wherein:
a first timestamp recording module 210, configured to respond to a processing request for a target task, add the target task to a work queue, and record, as a first timestamp, a timestamp when the target task was added to the work queue.
And the second timestamp recording module 220 is configured to record, if the first worker thread fetches the target task from the work queue, a timestamp of the target task fetched from the work queue as a second timestamp.
A waiting duration determining module 230, configured to determine a waiting duration of the target task in the work queue based on the first timestamp and the second timestamp.
The first anomaly information generation module 240 is configured to generate first anomaly information if the waiting duration exceeds a waiting duration threshold.
Further, the task processing device 200 further includes: a first task type determination module and a waiting duration threshold determination module, wherein:
and the first task type determining module is used for determining the task type corresponding to the target work task.
And the waiting time length threshold determining module is used for determining the waiting time length threshold corresponding to the target work task based on the task type.
Further, the task processing device 200 further includes: the device comprises a third time stamp recording module, a first processing duration determining module and a second abnormal information generating module, wherein:
and the third time stamp recording module is used for recording the time stamp of the processed target work task as a third time stamp if the first worker thread processes the target work task.
And the first processing duration determining module is used for determining the processing duration of the target work task in the first worker thread based on the second timestamp and the third timestamp.
And the second abnormal information generation module is used for generating second abnormal information if the processing time exceeds a processing time threshold.
Further, the task processing device 200 further includes: a second task type determination module and a processing duration threshold determination module, wherein:
and the second task type determining module is used for determining the task type corresponding to the target work task.
And the processing time length threshold determining module is used for determining the processing time length threshold corresponding to the target work task based on the task type.
Further, the task processing device 200 further includes: the device comprises a second processing time length determining module, an average processing time length determining module and a processing energy efficiency determining module, wherein:
and the second processing duration determining module is used for determining the processing duration of each of the plurality of work tasks in the first worker thread if the plurality of work tasks in the work queue are processed and completed, wherein the plurality of work tasks comprise the target work task.
The average processing time length determining module is used for determining average processing time lengths corresponding to the plurality of work tasks based on the processing time lengths of the plurality of work tasks in the first worker thread.
And the processing energy efficiency determining module is used for determining the processing energy efficiency of the first processing core where the first worker thread is located for the plurality of work tasks based on the average processing time length.
Further, the task processing device 200 further includes: a timer starting module, a timer closing module and a third abnormal information generating module, wherein:
and the timer starting module is used for starting a timer if the first worker thread takes out the target work task from the work queue, wherein the timer is set with a designated duration.
And the timer closing module is used for closing the timer if the first worker thread finishes processing the target work task within the specified duration.
And the third abnormal information generation module is used for generating third abnormal information if the first worker thread does not process the target work task within the specified duration.
Further, the third abnormality information generation module includes: an information acquisition sub-module and a third abnormal information generation sub-module, wherein:
the information acquisition sub-module is used for acquiring task information of the target work task and call stack information of the first worker thread.
And the third abnormal information generation sub-module is used for generating the third abnormal information based on the task information and the call stack information.
Further, the task processing device 200 further includes: the system comprises a work task determining module, a state information determining module and a work task processing module, wherein:
and the work task determining module is used for determining other work tasks which are arranged behind the target work task in the target work queue if the first worker thread does not process the target work task within the appointed time length.
And the state information determining module is used for determining the state information of the first processing core where the first worker thread is located.
And the work task processing module is used for processing the target work task and the other work tasks based on the state information.
Further, the work task processing module includes: a quantity determination sub-module and a work task processing sub-module, wherein:
the number determination submodule is used for determining the number of the worker threads in the non-working state in the worker thread pool corresponding to the first processing core based on the state information, wherein the worker thread pool comprises the first worker thread.
And the work task processing sub-module is used for processing the target work task and the other work tasks based on the number.
Further, the work task processing sub-module includes: a first work task processing unit and a second work task processing unit, wherein:
and the first work task processing unit is used for migrating the target work task and the other work tasks to a work queue of the second processing core for processing if the number exceeds a number threshold.
And the second work task processing unit is used for processing the target work task and the other work tasks through a second worker thread in the worker thread pool if the number does not exceed the number threshold.
It will be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working process of the apparatus and modules described above may refer to the corresponding process in the foregoing method embodiment, which is not repeated herein.
In several embodiments provided herein, the coupling of the modules to each other may be electrical, mechanical, or other.
In addition, each functional module in each embodiment of the present application may be integrated into one processing module, or each module may exist alone physically, or two or more modules may be integrated into one module. The integrated modules may be implemented in hardware or in software functional modules.
Referring to fig. 5, a block diagram of an electronic device 100 according to an embodiment of the present application is shown. The electronic device 100 may be a smart phone, a tablet computer, an electronic book, or the like capable of running an application program. The electronic device 100 in this application may include one or more of the following components: a processor 110, a memory 120, and one or more application programs, wherein the one or more application programs may be stored in the memory 120 and configured to be executed by the one or more processors 110, the one or more program(s) configured to perform the method as described in the foregoing method embodiments.
Wherein the processor 110 may include one or more processing cores. The processor 110 utilizes various interfaces and lines to connect various portions of the overall electronic device 100, perform various functions of the electronic device 100, and process data by executing or executing instructions, programs, code sets, or instruction sets stored in the memory 120, and invoking data stored in the memory 120. Alternatively, the processor 110 may be implemented in hardware in at least one of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), programmable logic array (Programmable Logic Array, PLA). The processor 110 may integrate one or a combination of several of a central processing unit (Central Processing Unit, CPU), a graphics processor (Graphics Processing Unit, GPU), and a modem, etc. The CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for being responsible for rendering and drawing the content to be displayed; the modem is used to handle wireless communications. It will be appreciated that the modem may not be integrated into the processor 110 and may be implemented solely by a single communication chip.
The Memory 120 may include a random access Memory (Random Access Memory, RAM) or a Read-Only Memory (Read-Only Memory). Memory 120 may be used to store instructions, programs, code, sets of codes, or sets of instructions. The memory 120 may include a stored program area and a stored data area, wherein the stored program area may store instructions for implementing an operating system, instructions for implementing functions (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the various method embodiments described below, and the like. The storage data area may also store data created by the electronic device 100 in use (e.g., phonebook, audiovisual data, chat log data), and the like.
Referring to fig. 6, a block diagram of a computer readable storage medium according to an embodiment of the present application is shown. The computer readable medium 300 has stored therein program code which can be invoked by a processor to perform the methods described in the method embodiments described above.
The computer readable storage medium 300 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable storage medium 300 comprises a non-volatile computer readable medium (non-transitory computer-readable storage medium). The computer readable storage medium 300 has storage space for program code 310 that performs any of the method steps described above. The program code can be read from or written to one or more computer program products. Program code 310 may be compressed, for example, in a suitable form.
In summary, the task processing method, the device, the electronic equipment and the storage medium provided in the embodiments of the present application, respond to a processing request for a target task, add the target task to a work queue, record a timestamp when the target task is added to the work queue as a first timestamp, if a first worker thread takes out the target task from the work queue, record the timestamp taken out by the target task from the work queue as a second timestamp, determine a waiting time of the target task in the work queue based on the first timestamp and the second timestamp, and if the waiting time exceeds a waiting time threshold, generate first anomaly information, thereby calculating a waiting time of the task through an enqueue timestamp and a dequeue timestamp of the task, and generating anomaly information under a condition that the waiting time is too long, so that analysis positioning efficiency of a timeout problem can be improved, and maintainability of a system is improved.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present application, and are not limiting thereof; although the present application has been described in detail with reference to the foregoing embodiments, one of ordinary skill in the art will appreciate that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not drive the essence of the corresponding technical solutions to depart from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims (13)

1. A method of task processing, the method comprising:
responding to a processing request aiming at a target work task, adding the target work task into a work queue, and recording a time stamp when the target work task is added into the work queue as a first time stamp;
if the first worker thread takes out the target work task from the work queue, recording a time stamp taken out of the work queue by the target work task as a second time stamp;
determining a waiting time length of the target work task in the work queue based on the first timestamp and the second timestamp;
and if the waiting time exceeds a waiting time threshold, generating first abnormal information.
2. The method of claim 1, further comprising, prior to the generating the first anomaly information if the wait period exceeds a wait period threshold:
determining a task type corresponding to the target work task;
and determining the waiting time length threshold corresponding to the target work task based on the task type.
3. The method of claim 1, further comprising, after the first worker thread fetches the target work task from the work queue, recording a timestamp of the fetching of the target work task from the work queue as a second timestamp:
If the first worker thread finishes processing the target work task, recording a timestamp that the target work task is processed as a third timestamp;
determining a processing duration of the target work task in the first worker thread based on the second timestamp and the third timestamp;
and if the processing duration exceeds the processing duration threshold, generating second abnormal information.
4. The method of claim 3, further comprising, prior to the generating the second anomaly information if the processing duration exceeds a processing duration threshold:
determining a task type corresponding to the target work task;
and determining the processing time length threshold corresponding to the target work task based on the task type.
5. A method according to claim 3, characterized in that the method further comprises:
if all the plurality of work tasks in the work queue are processed, determining processing time lengths of the plurality of work tasks in the first worker thread, wherein the plurality of work tasks comprise the target work task;
determining average processing time lengths corresponding to the plurality of work tasks based on the processing time lengths of the plurality of work tasks in the first worker thread;
And determining the processing energy efficiency of the first processing core where the first worker thread is located for the plurality of work tasks based on the average processing time length.
6. The method according to any one of claims 1-5, further comprising:
if the first worker thread takes out the target work task from the work queue, starting a timer, wherein the timer is set with a specified duration;
if the first worker thread finishes processing the target work task within the appointed time length, closing the timer; or alternatively
And if the first worker thread does not process the target work task within the specified duration, generating third abnormal information.
7. The method of claim 6, wherein generating third anomaly information comprises:
acquiring task information of the target work task and call stack information of the first worker thread;
and generating the third abnormal information based on the task information and the call stack information.
8. The method of claim 6, wherein the method further comprises:
if the first worker thread does not process the target work task within the specified duration, determining other work tasks which are arranged behind the target work task in the target work queue;
Determining state information of a first processing core where the first worker thread is located;
and processing the target work task and the other work tasks based on the state information.
9. The method of claim 8, wherein the processing the target work task and the other work tasks based on the status information comprises:
determining the number of worker threads in a non-working state in a worker thread pool corresponding to the first processing core based on the state information, wherein the worker thread pool comprises the first worker thread;
and processing the target work task and the other work tasks based on the number.
10. The method of claim 9, wherein the processing the target work task and the other work tasks based on the number comprises:
if the number exceeds a number threshold, migrating the target work task and the other work tasks to a work queue of a second processing core for processing; or alternatively
If the number does not exceed the number threshold, processing the target work task and the other work tasks by a second worker thread in the pool of worker threads.
11. A task processing device, the device comprising:
the first time stamp recording module is used for responding to a processing request aiming at a target work task, adding the target work task into a work queue, and recording a time stamp when the target work task is added into the work queue as a first time stamp;
the second time stamp recording module is used for recording the time stamp of the target work task taken out of the work queue as a second time stamp if the first worker thread takes out the target work task from the work queue;
the waiting time length determining module is used for determining the waiting time length of the target work task in the work queue based on the first timestamp and the second timestamp;
the first abnormal information generation module is used for generating first abnormal information if the waiting time exceeds a waiting time threshold.
12. An electronic device comprising a memory and a processor, the memory coupled to the processor, the memory storing instructions that when executed by the processor perform the method of any of claims 1-10.
13. A computer readable storage medium, characterized in that the computer readable storage medium has stored therein a program code, which is callable by a processor for executing the method according to any one of claims 1-10.
CN202311580192.3A 2023-11-23 2023-11-23 Task processing method, device, electronic equipment and storage medium Pending CN117573355A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311580192.3A CN117573355A (en) 2023-11-23 2023-11-23 Task processing method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311580192.3A CN117573355A (en) 2023-11-23 2023-11-23 Task processing method, device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117573355A true CN117573355A (en) 2024-02-20

Family

ID=89862161

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311580192.3A Pending CN117573355A (en) 2023-11-23 2023-11-23 Task processing method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117573355A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118113485A (en) * 2024-04-29 2024-05-31 苏州元脑智能科技有限公司 Task execution method and device, storage medium and electronic equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118113485A (en) * 2024-04-29 2024-05-31 苏州元脑智能科技有限公司 Task execution method and device, storage medium and electronic equipment

Similar Documents

Publication Publication Date Title
US20230185607A1 (en) Hardware accelerated dynamic work creation on a graphics processing unit
CN111427751B (en) Method and system for processing business based on asynchronous processing mechanism
CN108595282A (en) A kind of implementation method of high concurrent message queue
CN110795254A (en) Method for processing high-concurrency IO based on PHP
CN111897637B (en) Job scheduling method, device, host and storage medium
CN117573355A (en) Task processing method, device, electronic equipment and storage medium
CN111324432B (en) Processor scheduling method, device, server and storage medium
CN109117280B (en) Electronic device, method for limiting inter-process communication thereof and storage medium
CN110990132A (en) Asynchronous task processing method and device, computer equipment and storage medium
CN111831414A (en) Thread migration method and device, storage medium and electronic equipment
CN112764904A (en) Method for preventing starvation of low priority tasks in multitask-based system
CN115361451B (en) Network communication parallel processing method and system
Liu et al. Towards low-latency I/O services for mixed workloads using ultra-low latency SSDs
CN108958903B (en) Embedded multi-core central processor task scheduling method and device
CN112948096A (en) Batch scheduling method, device and equipment
WO2019047376A1 (en) Interface task calling method and device, electronic device and readable storage medium
CN101349975B (en) Method for implementing interrupt bottom semi-section mechanism in embedded operation system
WO2023193527A1 (en) Thread execution method and apparatus, electronic device, and computer-readable storage medium
CN109426563B (en) Process management method and device
CN115378685A (en) Data processing method, system, electronic device and computer readable storage medium
CN113032154B (en) Scheduling method and device for virtual CPU, electronic equipment and storage medium
CN112114967B (en) GPU resource reservation method based on service priority
CN114661415A (en) Scheduling method and computer system
CN114610467A (en) Multitask timeout management method and system
CN114327806A (en) Data processing method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination