Task scheduling method and device for multi-core processor, equipment, medium and product
By judging the IPC request signal on the multi-core processor and binding tasks to other cores for processing, the task switching problem during peak IPC requests is solved, and the IPC delay is shortened and performance improvement is achieved.
Patent Information
- Application Number
- CN202310504512.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-06
- Publication Date
- 2024-11-08
AI Technical Summary
When IPC request peaks, frequent task switching results in IPC delays on average, and overall IPC performance is low.
By obtaining the request signal that triggers the target task, determine whether it is an IPC request signal, and update the number of IPC blocking times in the same time. If the preset conditions are met, bind the target task to other kernels to reduce switching and execute context saving To shorten IPC delay.
It effectively shortens the average delay of IPC, improves the overall IPC performance, reduces the probability of task switching, and improves the IPC performance of the system.
Smart Images

Figure CN118916123A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a task scheduling method, device, equipment, medium and product for a multi-core processor. Background Art
[0002] In a real-time operating system, processes need to work together to complete a task, which requires certain notifications and data transfers between processes, namely inter-process communication (IPC). While ensuring the relative independence of processes, it also ensures reasonable and effective communication between processes.
[0003] When a real-time operating system running on a multi-core processor reaches a peak of IPC requests, it may frequently block tasks involving IPC requests, greatly increasing the probability of these tasks switching cores. However, after the task switches cores, when IPC requests the task again, the CPU (central processing unit) cannot find the execution context of the task in the current core and needs to read it from the memory, which in turn causes the average IPC time to be extended and the overall IPC performance to be low. Summary of the invention
[0004] Based on this, it is necessary to provide a task scheduling method, device, equipment, medium and product for a multi-core processor that can shorten the average IPC delay and improve the overall IPC performance in response to the above technical problems.
[0005] In a first aspect, the present application provides a task scheduling method for a multi-core processor. The method comprises:
[0006] Get the request signal that causes the target task to enter a blocking state;
[0007] If the request signal is an IPC request signal, obtain the occurrence time of the IPC request signal;
[0008] Determine whether the occurrence time and the timestamp of the target task are in the same time slice;
[0009] If the occurrence time and the timestamp of the target task are in the same time slice, update the IPC blocking times corresponding to the target task;
[0010] If the number of IPC blocking times meets the preset conditions, the target task is bound to other cores;
[0011] Perform context saving on the target task.
[0012] In one embodiment, the method further comprises:
[0013] If the IPC request time and the timestamp of the target task are not in the same time slice, the timestamp of the target task is updated to the IPC request time, and the IPC blocking times of the target task is set to the preset value.
[0014] In one embodiment, the other kernels are determined by:
[0015] Get the utilization of each core;
[0016] According to the utilization of each core, the core with the smallest utilization is determined as the other cores.
[0017] In one embodiment, determining whether the occurrence time and the timestamp of the target task are in the same time slice includes:
[0018] Obtaining a value of a preset position of the occurrence time to obtain a first value; the preset position is determined according to the length of the time slice;
[0019] Obtaining a value of a preset position of a timestamp of a target task to obtain a second value;
[0020] Determine whether the first value is the same as the second value.
[0021] In one embodiment, the method further comprises:
[0022] If the number of IPC blocking times does not meet the preset condition, the step of saving the execution context of the target task is executed.
[0023] In one embodiment, the method further comprises:
[0024] If the request signal is not an IPC request signal, the step of saving the execution context of the target task is executed.
[0025] In a second aspect, the present application also provides a task scheduling device for a multi-core processor. The device comprises:
[0026] A request signal acquisition module, used to acquire a request signal that causes the target task to enter a blocking state;
[0027] An occurrence time acquisition module, used for acquiring the occurrence time of the IPC request signal if the request signal is an IPC request signal;
[0028] The time slice judgment module is used to judge whether the occurrence time and the timestamp of the target task are in the same time slice;
[0029] The record update module is used to update the IPC blocking times corresponding to the target task if the occurrence time and the timestamp of the target task are in the same time slice;
[0030] The kernel binding module is used to bind the target task to other kernels if the number of IPC blocking times meets the preset conditions;
[0031] The context saving module is used to perform context saving on the target.
[0032] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:
[0033] Get the request signal that causes the target task to enter a blocking state;
[0034] If the request signal is an IPC request signal, obtain the occurrence time of the IPC request signal;
[0035] Determine whether the occurrence time and the timestamp of the target task are in the same time slice;
[0036] If the occurrence time and the timestamp of the target task are in the same time slice, update the IPC blocking times corresponding to the target task;
[0037] If the number of IPC blocking times meets the preset conditions, the target task is bound to other cores;
[0038] Perform context saving on the target task.
[0039] In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0040] Get the request signal that causes the target task to enter a blocking state;
[0041] If the request signal is an IPC request signal, obtain the occurrence time of the IPC request signal;
[0042] Determine whether the occurrence time and the timestamp of the target task are in the same time slice;
[0043] If the occurrence time and the timestamp of the target task are in the same time slice, update the IPC blocking times corresponding to the target task;
[0044] If the number of IPC blocking times meets the preset conditions, the target task is bound to other cores;
[0045] Perform context saving on the target task.
[0046] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0047] Get the request signal that causes the target task to enter a blocking state;
[0048] If the request signal is an IPC request signal, obtain the occurrence time of the IPC request signal;
[0049] Determine whether the occurrence time and the timestamp of the target task are in the same time slice;
[0050] If the occurrence time and the timestamp of the target task are in the same time slice, update the IPC blocking times corresponding to the target task;
[0051] If the number of IPC blocking times meets the preset conditions, the target task is bound to other cores;
[0052] Perform context saving on the target task.
[0053] The method, device, equipment, medium and product for scheduling tasks of the multi-core processor mentioned above. The method schedules the target task to other cores for processing only when the number of IPC requests in the time slice meets the preset conditions, thereby reducing the probability of the target task switching cores, shortening the average IPC delay and improving the overall IPC performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 A schematic diagram of a flow chart of a task scheduling method for a multi-core processor in one embodiment;
[0055] Figure 2 A flowchart of a step of determining whether the occurrence time and the timestamp of the target task are in the same time slice in one embodiment;
[0056] Figure 3 is a structural block diagram of a task scheduling device for a multi-core processor in one embodiment;
[0057] Figure 4 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0058] At present, the IPC synchronization mode of the real-time operating system is that when the sending task A sends a message to the message queue, the receiving task B is unblocked, and the sending task A enters a blocked state; the receiving task B receives the message from the message queue and unblocks the sending task A, and the receiving task B enters a blocked state. Before the sending task A is unblocked, the system will read the instructions and data of the task from the cache, and before the sending task A enters the blocking state, the system will store the instructions and data of the task in the cache. Among them, the cache is located in the CPU (central processing unit) and is an important part of the CPU. The speed of the cache is much faster than the memory. When the cache does not have the data needed by the CPU, the CPU will read the data from the memory, put it in the cache, and then read the data from the cache. Compared with the CPU reading data directly from the cache, the speed at which the CPU reads data from the memory is greatly reduced.
[0059] When a real-time operating system runs on a multi-core processor, if the target task in the first core frequently receives IPC requests, resulting in frequent blocking of the target task, the CPU balancing strategy will adjust the target task to another core (exemplarily, the second core) for execution. When the target task is called by an IPC request again, the CPU finds that there are no instructions and data of the target task in the cache of the second core, and can only read the instructions and data of the target task from the memory, put them into the cache, and then read them from the cache. The efficiency of the CPU reading data from the memory is much lower than that of reading data from the cache.
[0060] When the real-time operating system enters the peak of IPC requests, it will frequently block and unblock tasks related to IPC requests or using the same core, causing these tasks to frequently switch cores, thereby extending the average IPC time and lowering the overall IPC performance.
[0061] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0062] In one embodiment, Figure 1 As shown, a task scheduling method for a multi-core processor is provided. This embodiment takes the method applied to a terminal as an example. It can be understood that the method can also be applied to a server. Among them, the terminal can be but is not limited to various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. In this embodiment, the method includes the following steps:
[0063] Step 102: Obtain a request signal that causes the target task to enter a blocking state.
[0064] Among them, the target task can be a process, thread or PE (Portable Executable) file running in a multi-core processor; PE files include but are not limited to the following formats: EXE, DLL, SYS, OCX, COM. Among them, a process is an instance of a running program. It is a running entity, and each process has its own address space. A process can correspond to one task or multiple tasks. A program is like a template. When it runs, it is a process. It can be understood that running multiple copies of a program will generate multiple processes for the corresponding program. A thread is the smallest unit that the operating system can perform calculation scheduling; it is contained in a process and is the actual operating unit in the process.
[0065] Exemplarily, whether the target task is about to enter a blocked state is determined based on the semaphore obtained by the target task; wherein the semaphore is a communication mechanism in a real-time operating system. If the value of the semaphore obtained by the target task from the real-time operating system is less than 0, the target task is about to enter a blocked state. If the value of the semaphore obtained by the target task from the real-time operating system is greater than or equal to 0, the target task will not enter a blocked state. Generally, semaphores control threads, i.e., the minimum scheduling unit; there are three operations on semaphores: initializing a semaphore (non-negative integer) and setting the Count value; the P operation, also called the Wait operation, obtains resources, and the Count is subtracted by 1; the V operation, also called the Signal operation, releases resources, and the Count is increased by 1.
[0066] Exemplarily, whether the target task is about to enter a blocked state can also be determined comprehensively based on the properties of the target task and the parameters of the calling function; wherein the properties of the target task can also be understood as the running state of the target task, which can be described by the value of an int variable in the task_struct structure corresponding to the target task, for example, a value of 1 for the int variable represents that the target task remains in the running state, and a value of 2 represents that the target task enters a blocked state; the request signal of the target task includes a calling function to call the target task, wherein the calling function may include parameters for assigning values to the int variable.
[0067] If the target task is about to enter a blocked state, obtain a request signal that causes the target task to enter a blocked state. The request signal may be a P operation. Exemplarily, the target task is a thread A; a semaphore object is initialized for the kernel where thread A is located, and the corresponding count value is set. The request signal can be understood as a P operation: calling the acquire function to obtain resources, specifically first decrementing the count value by 1. If the count value is less than 0, it means that the kernel has insufficient resources. At this time, thread A will be added to the waiting queue corresponding to this semaphore, and thread A will be blocked, giving up the kernel where it is located. The V operation is also understood as a request signal, which is a request signal that will not block the target task. V operation: calling the release function to release resources, specifically first adding 1 to the count value. If the count value is less than or equal to 0, it means that there are still threads to be awakened in the waiting queue corresponding to the semaphore. At this time, a thread B will be taken out of the waiting queue in a FIFO (First Input First Output) manner and placed in the ready queue corresponding to the semaphore, thereby awakening thread B.
[0068] Step 104, determining whether the request signal is an IPC request signal.
[0069] Among them, in addition to the IPC request signal, other types of request signals may also cause the target task to enter a blocked state, exemplified by an interrupt request signal. It should be noted that not all IPC request signals will cause the target task to enter a blocked state. If the IPC request signal contains a block flag, it will block the currently executing task. Therefore, it is possible to determine whether the request signal causes the target task to be blocked by judging whether the IPC signal contains a block flag. It should be noted that the embodiments of the present application discuss the situation of causing the target task to be blocked. Therefore, the IPC request signal involved in the embodiments of the present application refers to the IPC request signal that will cause the target task to be blocked, unless otherwise specified.
[0070] Step 106: If the request signal is an IPC request signal, obtain the occurrence time of the IPC request signal.
[0071] Exemplarily, the current time is directly obtained by calling the function, that is, the time when the IPC request signal occurs. The time accuracy of a general operating system is nanosecond level.
[0072] Step 108, determining whether the occurrence time and the timestamp of the target task are in the same time slice.
[0073] A timeslice is a microscopic section of CPU time allocated by a time-sharing operating system to each running task. It can also be called time granularity, time cycle or processor slice.
[0074] In the embodiment of the present application, two attributes, a timestamp (Time) and an IPC blocking count (Count), are added to any target task in the task control structure of the real-time operating system. When the target task is blocked by IPC for the first time within a time slice, its timestamp attribute is updated to the occurrence time of the IPC request, and the IPC blocking count attribute is updated to a preset value. The IPC blocking count is subsequently updated according to the number of IPC requests occurring in the same time slice.
[0075] Step 110: If the occurrence time and the target task time are in the same time slice, the IPC blocking times corresponding to the target task are updated.
[0076] Regarding the initial value of the timestamp, for example, it is empty. There are many ways to determine the initial value and update method of the IPC blocking times; for example, the initial value of the IPC blocking times is empty, that is, 0, and the update method is to add 1 or 2; for example, the initial value of the IPC blocking times is a fixed value, such as 20, and the update method is to subtract 1 or 2.
[0077] This timestamp is compared with the occurrence time of the subsequent IPC request that causes the block; if the timestamp and the occurrence time of the subsequent IPC request that causes the block are in the same time slice, the timestamp remains unchanged and the IPC block count is updated; if the occurrence time of the subsequent IPC request that causes the block enters the next time slice or the time slice after that, the timestamp is updated to the occurrence time of the first IPC request that causes the block in the current time slice, and the IPC block count is reset to the preset value. The timestamp and IPC block count attributes are used to record the IPC block count of the target task in a time slice.
[0078] The preset value here can be understood as follows: if the initial value of the IPC blocking times is 0 and the update method is to add 1, then the preset value is 1; if the initial value of the IPC blocking times is 0 and the update method is to add 2, then the preset value is 2; if the initial value of the IPC blocking times is a fixed value and the update method is to decrement 1, then the preset value is the fixed value minus 1; if the initial value of the IPC blocking times is a fixed value and the update method is to decrement 2, then the preset value is the fixed value minus 2; that is, the preset value corresponds to the value corresponding to the initial value after it is updated once. There is no restriction on the initial value of the IPC blocking times in this application.
[0079] Step 112, determining whether the number of IPC blocking times meets a preset condition.
[0080] The preset condition is determined specifically according to the initial value and update method of the aforementioned IPC blocking times. For example, the preset condition is that the IPC request occurs 100 times cumulatively in the current time slice.
[0081] Step 114: If the number of IPC blocking times meets a preset condition, the target task is bound to other cores.
[0082] Exemplarily, the other cores are any cores in the multi-core processor except the core where the target task is located.
[0083] Exemplarily, the preset condition is that when the number of IPC blocking times is greater than or equal to the preset number, the target task is scheduled to be executed on other cores. The target task can be bound to a fixed core for scheduling by setting the Affinity property of the target task. The preset number of times can be determined based on the time the processor is occupied for processing a single IPC request and the core switching time of the target task.
[0084] Step 116, save the execution context of the target task.
[0085] Before the target task enters the blocking state, it needs to save the context so that it can be restored when it runs again. The context can also be called the running scene. From the perspective of the processor, the context is the value of several registers, such as the flag register, general register, segment register, instruction register, etc. Saving the context to the cache is called execution context saving in the computer field.
[0086] Generally, the time that an IPC request occupies the processor is much less than the time that the target task consumes when switching to another core. Therefore, if there are relatively few IPC requests that cause the target task to be blocked within a time slice, then waiting for the above IPC requests to be executed and continuing to execute the target task will result in higher execution efficiency than switching to another core. If there are too many IPC requests that cause blocking within a time slice, then the target task will be switched to another core.
[0087] In this way, the task scheduling method of the multi-core processor above records the number of IPC requests that cause the target task to be blocked within a time slice to decide whether to schedule the target task to other cores for processing, thereby reducing the probability of the target task switching cores, shortening the average IPC delay, and improving the overall IPC performance.
[0088] The number of functions provided by the kernel is reduced in the microkernel, and these functions are obtained by communicating with the server through IPC. Compared with the ordinary macrokernel, the number of IPCs of the microkernel is greatly increased. In the design of the microkernel operating system, the task scheduling method of the multi-core processor provided by the present application is adopted to shorten the average delay of IPC, improve the performance of IPC, and significantly increase the execution efficiency of the microkernel.
[0089] In one embodiment, see Figure 1 The multi-processor task scheduling method also includes step 118, if the IPC request time and the timestamp of the target task are not in the same time slice, the timestamp of the target task is updated to the IPC request time, and the IPC blocking times of the target task are set to a preset value.
[0090] In one embodiment, the other cores are the currently idlest cores in the multi-core processor. Figure 2 As shown, the other cores are determined by the following method: obtaining the utilization of each core; and according to the utilization of each core, determining the core with the smallest utilization as the other core.
[0091] In this embodiment, by determining the core with the lowest utilization rate as the other cores, the target task is bound to the idlest core in the CPU, thereby achieving CPU load balancing.
[0092] In one embodiment, see Figure 2 , step 108 comprises:
[0093] Step 1082, obtaining the value of the preset position of the occurrence time to obtain a first value; the preset position is determined according to the length of the time slice.
[0094] Step 1084, obtaining the value of the preset bit of the timestamp of the target task to obtain a second value.
[0095] Step 1086, determine whether the first value is the same as the second value.
[0096] Generally, the time slice precision is in nanoseconds, and the time precision obtained by the task control module in the CPU is also in nanoseconds. For example, the obtained time is a string of numbers, such as 1289703264, which is broken down into 1 (second) 289 (milliseconds) 703 (microseconds) 264 (nanoseconds). The number 0 is the 10 microsecond bit. Assuming that the time slice is 10 microseconds, it is only necessary to compare whether the occurrence time of the IPC request signal and the value of the 10 microsecond bit of the timestamp are the same.
[0097] In this embodiment, the efficiency of the determination operation is improved by comparing the preset bits.
[0098] In one embodiment, see Figure 1 ,The task scheduling method for a multi-core processor includes: if the number of IPC blocking times does not meet a preset condition, executing the context of the target task.
[0099] Among them, if the number of IPC blocking times does not meet the preset conditions, it means that the target task waits for the current IPC request signal to be executed before continuing to run on the original core, and the waiting time is shorter than the waiting time for core switching. In other words, when the number of IPC blocking times does not meet the preset conditions, allowing the target task to continue to run on the original core can shorten the average IPC delay in the multi-core processor compared to the average IPC delay under the original CPU balancing strategy.
[0100] In one embodiment, see Figure 1 ,The task scheduling method of a multi-core processor includes: if the request signal is not an IPC request signal, saving the execution context of the target task.
[0101] In this embodiment, the counting core switching process is performed only for the blocking caused by the IPC request signal. For the request signal with a higher priority, such as the interrupt request signal, the target task is still on the original core, and the context is directly saved without switching.
[0102] For ease of understanding, an example of the update process of a timestamp (Time) and the number of IPC blocking times (Count) is given below.
[0103] Assumption: The time granularity is 1 minute, and the preset condition is that the number of IPC blocking times reaches 100.
[0104] When an IPC request occurs at 10:08:01, the current time of task A is recorded as 10:08:01, and the number of IPC blocking times is 1, that is, the attributes of task A are: Time = 10:08:01, Count = 1;
[0105] When an IPC request occurs at 10:08:09, it is compared with the minute value 8 of Task A at 10:08:01. They are the same and are considered to be in the same time slice. Time is not updated and the number of IPC blocking times is increased by 1, that is, the attributes of Task A are: Time = 10:08:01, Count = 2.
[0106] When an IPC request occurs at 10:08:18, it is compared with the value 8 of the minute bit of Task A at 10:08:01. They are the same and are considered to be in the same time slice. Time is not updated and the number of IPC blocking times is increased by 1, that is, the attributes of Task A are: Time = 10:08:01, Count = 3;
[0107] When an IPC request occurs at 10:08:57, it is compared with the value 8 of the minute bit of Task A at 10:08:01. They are the same and are considered to be in the same time slice. Time is not updated and the number of IPC blocking times is increased by 1, that is, the attributes of Task A are: Time = 10:08:01, Count = 4;
[0108] When an IPC request occurs at 10:09:03, it is compared with the minute value 8 of Task A at 10:08:01, and they are different. It is determined that a new time slice has arrived, Time is updated, and the number of IPC blocking times is set to 1, that is, the attributes of Task A are: Time = 10:09:03, Count = 1;
[0109] When an IPC request occurs at 10:09:13, it is compared with the minute value 9 of Task A at 10:09:03. They are the same and are considered to be in the same time slice. Time is not updated, the number of IPC blocking times is increased by 1, and Task A records Time = 10:09:03, Count = 2.
[0110] By analogy, if the existence count reaches 100, task A is bound to other cores.
[0111] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0112] Based on the same inventive concept, the embodiment of the present application also provides a task scheduling device for a multi-core processor for implementing the task scheduling method for a multi-core processor involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the embodiment of the task scheduling device for one or more multi-core processors provided below can refer to the limitations of the task scheduling method for a multi-core processor above, and will not be repeated here.
[0113] In one embodiment, Figure 3 As shown, a task scheduling device for a multi-core processor is provided, including: a request signal acquisition module 302, an occurrence time acquisition module 304, a time slice determination module 306, a record update module 308, a kernel binding module 310, and a context storage module 312, wherein:
[0114] A request signal acquisition module 302, used to acquire a request signal that causes the target task to enter a blocking state;
[0115] An occurrence time acquisition module 304 is used to acquire the occurrence time of the IPC request signal if the request signal is an IPC request signal;
[0116] The time slice determination module 306 is used to determine whether the occurrence time and the timestamp of the target task are in the same time slice;
[0117] The record update module 308 is used to update the IPC blocking times corresponding to the target task if the occurrence time and the timestamp of the target task are in the same time slice.
[0118] The kernel binding module 310 is used to bind the target task to other kernels if the number of IPC blocking times meets a preset condition;
[0119] The context saving module 312 is used to save the context of the target execution.
[0120] In one embodiment, the record update module 308 is further used to update the timestamp of the target task to the IPC request time and set the IPC blocking times of the target task to a preset value if the IPC request time and the timestamp of the target task are not in the same time slice.
[0121] In one embodiment, the core binding module 310 is further used to obtain the utilization of each core; and to determine the core with the lowest utilization as the other core according to the utilization of each core.
[0122] In one embodiment, the time slice judgment module 306 is further used to obtain the value of the preset position of the occurrence time to obtain a first value; and to obtain the value of the preset position of the timestamp of the target task to obtain a second value; and to determine whether the first value is the same as the second value; wherein the preset position is determined according to the length of the time slice.
[0123] In one embodiment, the context saving module 312 is further configured to execute the context for the target task if the number of IPC blocking times does not meet a preset condition.
[0124] In one embodiment, the context saving module 312 is further configured to save the context of the target task if the blocking request signal is not an IPC request signal.
[0125] Each module in the task scheduling device of the multi-core processor can be implemented in whole or in part by software, hardware and a combination thereof. Each module can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to each module.
[0126] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a task scheduling method for a multi-core processor is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0127] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0128] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0129] Get the request signal that causes the target task to enter a blocking state;
[0130] If the request signal is an IPC request signal, obtain the occurrence time of the IPC request signal;
[0131] Determine whether the occurrence time and the timestamp of the target task are in the same time slice;
[0132] If the occurrence time and the timestamp of the target task are in the same time slice, update the IPC blocking times corresponding to the target task;
[0133] If the number of IPC blocking times meets the preset conditions, the target task is bound to other cores;
[0134] Perform context saving on the target task.
[0135] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0136] If the IPC request time and the timestamp of the target task are not in the same time slice, the timestamp of the target task is updated to the IPC request time, and the IPC blocking times of the target task is set to the preset value.
[0137] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0138] The utilization of each core is obtained; and according to the utilization of each core, a core with the smallest utilization is determined as the other cores.
[0139] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0140] Obtain the value of the preset position of the occurrence time to obtain a first value; the preset position is determined according to the length of the time slice; obtain the value of the preset position of the timestamp of the target task to obtain a second value; and determine whether the first value is the same as the second value.
[0141] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0142] If the number of IPC blocking times does not meet the preset condition, the step of saving the execution context of the target task is executed.
[0143] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0144] If the request signal is not an IPC request signal, the step of saving the execution context of the target task is executed.
[0145] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0146] Get the request signal that causes the target task to enter a blocking state;
[0147] If the request signal is an IPC request signal, obtain the occurrence time of the IPC request signal;
[0148] Determine whether the occurrence time and the timestamp of the target task are in the same time slice;
[0149] If the occurrence time and the timestamp of the target task are in the same time slice, update the IPC blocking times corresponding to the target task;
[0150] If the number of IPC blocking times meets the preset conditions, the target task is bound to other cores;
[0151] Perform context saving on the target task.
[0152] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0153] If the IPC request time and the timestamp of the target task are not in the same time slice, the timestamp of the target task is updated to the IPC request time, and the IPC blocking times of the target task is set to the preset value.
[0154] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0155] The utilization of each core is obtained; and according to the utilization of each core, a core with the smallest utilization is determined as the other cores.
[0156] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0157] Obtain the value of the preset position of the occurrence time to obtain a first value; the preset position is determined according to the length of the time slice; obtain the value of the preset position of the timestamp of the target task to obtain a second value; determine whether the first value is the same as the second value.
[0158] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0159] If the number of IPC blocking times does not meet the preset condition, the step of saving the execution context of the target task is executed.
[0160] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0161] If the request signal is not an IPC request signal, the step of saving the execution context of the target task is executed.
[0162] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0163] Get the request signal that causes the target task to enter a blocking state;
[0164] If the request signal is an IPC request signal, obtain the occurrence time of the IPC request signal;
[0165] Determine whether the occurrence time and the timestamp of the target task are in the same time slice;
[0166] If the occurrence time and the timestamp of the target task are in the same time slice, update the IPC blocking times corresponding to the target task;
[0167] If the number of IPC blocking times meets the preset conditions, the target task is bound to other cores;
[0168] Perform context saving on the target task.
[0169] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0170] If the IPC request time and the timestamp of the target task are not in the same time slice, the timestamp of the target task is updated to the IPC request time, and the IPC blocking times of the target task is set to the preset value.
[0171] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0172] The utilization of each core is obtained; and according to the utilization of each core, a core with the smallest utilization is determined as the other cores.
[0173] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0174] Obtain the value of the preset position of the occurrence time to obtain a first value; the preset position is determined according to the length of the time slice; obtain the value of the preset position of the timestamp of the target task to obtain a second value; and determine whether the first value is the same as the second value.
[0175] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0176] If the number of IPC blocking times does not meet the preset condition, the step of saving the execution context of the target task is executed.
[0177] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0178] If the request signal is not an IPC request signal, the step of saving the execution context of the target task is executed.
[0179] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0180] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0181] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0182] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A task scheduling method for a multi-core processor, characterized in that: The method comprises: Get the request signal that causes the target task to enter a blocking state; If the request signal is an IPC request signal, obtaining the occurrence time of the IPC request signal; Determine whether the occurrence time and the timestamp of the target task are in the same time slice; If the occurrence time and the timestamp of the target task are in the same time slice, the IPC blocking times corresponding to the target task are updated; If the IPC blocking times meet the preset conditions, the target task is bound to other kernels; A context save is performed on the target task.
2. The method according to claim 1, characterized in that: The method further comprises: If the IPC request time and the timestamp of the target task are not in the same time slice, the timestamp of the target task is updated to the IPC request time, and the number of IPC blocking times of the target task is set to a preset value.
3. The method according to claim 1 or 2, characterized in that: The other kernels are determined by: Get the utilization of each core; According to the utilization rates of the cores, a core with the lowest utilization rate is determined as the other cores.
4. The method according to claim 1 or 2, characterized in that: The determining whether the occurrence time and the timestamp of the target task are in the same time slice includes: Obtaining a value of a preset position of the occurrence time to obtain a first value; the preset position is determined according to the length of the time slice; Obtaining a value of the preset bit of the timestamp of the target task to obtain a second value; Determine whether the first value is the same as the second value.
5. The method according to claim 1 or 2, characterized in that: The method further comprises: If the IPC blocking times do not meet the preset condition, the step of saving the execution context of the target task is executed.
6. The method according to claim 1 or 2, characterized in that: The method comprises: If the request signal is not the IPC request signal, the step of saving the execution context of the target task is performed.
7. A task scheduling device for a multi-core processor, characterized in that: The device comprises: A request signal acquisition module, used to acquire a request signal that causes the target task to enter a blocking state; An occurrence time acquisition module, used for acquiring the occurrence time of the IPC request signal if the request signal is an IPC request signal; A time slice determination module, used to determine whether the occurrence time and the timestamp of the target task are in the same time slice; A record update module, used for updating the IPC blocking times corresponding to the target task if the occurrence time and the timestamp of the target task are in the same time slice; A kernel binding module, used to bind the target task to other kernels if the IPC blocking times meet a preset condition; The context saving module is used to perform context saving on the target.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Cited By
Command processing method and device, chip product, equipment and storage medium
CN120929282A
Command processing method and device, chip product, equipment and storage medium
CN120929282B
