Method, system, apparatus and program product for multi-process management for system on chip
Patent Information
- Application Number
- CN202510486624.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-17
- Publication Date
- 2026-10-23
AI Technical Summary
这种进程管理架构下,一旦这四个进程中任意一个关闭用时太长或出现其它异常,都会影响到后续的其它进程的关闭,甚至导致SoC的关机过程瘫痪,甚至出现死机
Smart Images

Figure CN122963752A_ABST
Abstract
Description
Technical Field
[0001] This application relates to vehicle-related technologies, and more specifically, to the management of multiple processes in a system-on-a-chip. Background Technology
[0002] In the field of System-on-Chip (SoC) process management, Execution, State, and Health Management (ESME) is a mechanism for comprehensively and efficiently managing the execution process, current state, and health status of processes within the SoC. Under the current architecture, and while adhering to dependencies, the shutdown sequence is the reverse of the power-on sequence and cannot be changed. For example, during power-on, processes are started in the order of first, second, third, and fourth; during power-off, processes are shut down in the reverse order of power-on, from fourth, third, second, and first. In this process management architecture, if any of these four processes takes too long to shut down or encounters other anomalies, it will affect the shutdown of subsequent processes, potentially paralyzing the SoC's shutdown process or even causing a system crash. Therefore, it is necessary to improve the process management of SoCs. Summary of the Invention
[0003] According to one aspect of this application, a multi-process management method for a system-on-a-chip is provided, the method comprising: checking a plurality of processes involved in a first request; pushing processes among the plurality of processes that meet enqueue conditions into a first queue, wherein the process with the highest priority in the first queue is set at the head of the first queue; allocating a thread to the process at the head of the queue to execute the task of the first request and removing the process at the head of the queue from the first queue; wherein the priority of the plurality of processes for the first request is preset.
[0004] Optionally or additionally, the multi-process management method for a system-on-a-chip may further include: when allocating a thread to a process located at the head of the queue, if there are still idle threads in the thread pool, allocating the idle threads to processes after the head of the first queue and removing the process allocated the idle threads from the first queue.
[0005] Optionally or additionally, the process management method for an on-chip system, which pushes processes that meet the enqueueing conditions from among the plurality of processes into a first queue, further includes comparing the priority of the pushed process with the priority of the process at the head of the queue, and setting the pushed process to the head of the queue if the priority of the pushed process is higher. Alternatively, pushing processes that meet the enqueueing conditions from among the plurality of processes into the first queue may include comparing the priority of the pushed process with the priority of existing processes in the first queue, and setting the position of the pushed process in the first queue according to the comparison result.
[0006] Optionally or additionally, in the process management method for a system-on-a-chip, the priority of the plurality of processes for the first request is pre-set according to any one or more of the following: determining the priority according to the dependency relationship of each process; determining the priority according to the time taken by each process to execute the task of the first request.
[0007] Optionally or additionally, in the process management method for a system-on-a-chip, the first request is a request to shut down the system-on-a-chip, wherein determining the priority according to the dependencies of each process includes setting the priority of processes that depend on other processes to be higher than the priority of those other processes; determining the priority according to the time taken for each process to execute the task of the first request includes setting the priority of processes that take longer to execute the task of the first request to be higher; and for each process, the enqueue condition is that all other processes that depend on that process have been shut down. The system-on-a-chip may be a system-on-a-chip installed in a vehicle.
[0008] Optionally or additionally, in the process management method for a system-on-a-chip, the first request is a request to start the system-on-a-chip, wherein determining the priority according to the dependencies of each process includes setting the priority of processes that depend on other processes to be lower than the priorities of those other processes; determining the priority according to the time taken for each process to execute the task of the first request includes setting the priority of processes that take longer to execute the task of the first request to be higher; and for each process, the queuing condition is that all other processes that the process depends on have been started. The system-on-a-chip may be a system-on-a-chip installed in a vehicle.
[0009] Optionally or additionally, the process management method for a system-on-a-chip checks multiple processes involved in the first request, including: traversing the multiple processes and determining whether the process meets the enqueueing condition based on the counter value of each process.
[0010] Optionally or additionally, the process management method for a system-on-a-chip may specifically include checking processes by: traversing the processes and determining whether the process has completed a dependency relationship based on the counter value of each process, wherein the counter value of each process is incremented or decremented by 1 when the process completes a dependency relationship.
[0011] According to another aspect of this application, a multi-process management system for a system-on-a-chip is also provided, comprising a priority setting module and a process manager. The priority setting module can be used to set priorities for processes. The process manager can be used, in response to the first request, to check the multiple processes involved; push the processes among the multiple processes that meet the enqueueing conditions into a first queue, wherein the process with the highest priority in the first queue is set at the head of the first queue; allocate a thread to the process at the head of the queue to execute the task of the first request; and remove the process at the head of the queue from the first queue.
[0012] Optionally or additionally, in the provided multi-process management system, the process manager is further configured to: when allocating a thread to the process at the head of the queue, if there are still idle threads in the thread pool, allocate the idle thread to the process after the head of the first queue and squeeze the process allocated the idle thread out of the first queue.
[0013] Optionally or additionally, in the provided multi-process management system, the process manager is further configured to, upon receiving a pushed process, compare the priority of the pushed process with the priority of the process at the head of the first queue; if the comparison result shows that the priority of the pushed process is higher, set it to the head of the first queue.
[0014] Optionally or additionally, in the provided multi-process management system, the process manager is further configured to: compare the priority of the pushed process with the priority of the existing processes in the first queue, and set the position of the pushed process in the first queue according to the comparison result.
[0015] Optionally or additionally, in the provided multi-process management system, the priority setting module is used to set priorities according to any one or more of the following: determining the priority according to the dependency relationship of each process; determining the priority according to the time taken by each process to execute the task of the first request.
[0016] Optionally or additionally, in the provided multi-process management system, the first request is a request to shut down the on-chip system, and the priority setting module is used to set the priority of processes according to the following: setting the priority of processes that depend on other processes to be higher than the priority of the other processes; setting the priority of processes that take longer to execute the task of the first request to be higher; and for each process, the enqueue condition is that all other processes that depend on that process have been shut down.
[0017] Optionally or additionally, in the provided multi-process management system, the first request is a request to start the on-chip system, and the priority setting module is used to set the priority of processes according to the following: setting the priority of processes that depend on other processes to be lower than the priority of the other processes, setting the priority of processes that take longer to execute the task of the first request to be higher; and for each process, the enqueue condition is that all other processes that the process depends on have been started.
[0018] According to another aspect of this application, a system-on-a-chip is also provided. The system-on-a-chip includes a memory and a processor. The memory stores instructions, and the processor executes the program instructions and, in the process of executing the instructions, implements any example of the methods described above.
[0019] According to another aspect of this application, an apparatus is also provided, which includes at least the on-chip system described herein. As an example, the apparatus may be an in-vehicle controller, which includes any of the following controllers: a vehicle controller of the vehicle; a domain controller of the vehicle.
[0020] According to this application, a program product is also provided, the program product including program instructions that, when executed, can implement any one of the methods described above. Attached Figure Description
[0021] This application will be more fully understood by referring to the following detailed description of specific embodiments in conjunction with the accompanying drawings, wherein the same reference numerals in the drawings refer to the same elements, wherein:
[0022] Figure 1 The structure of a system-on-a-chip (SoC) according to one embodiment is illustrated;
[0023] Figure 2 It is a schematic diagram of the operating group of an example vehicle's on-chip system and some of its processes;
[0024] Figure 3 This is a flowchart of a multi-process management method for a system-on-a-chip according to an example of this application;
[0025] Figure 4This illustrates the process management procedure based on some examples;
[0026] Figure 5 This illustration shows the status of processes in the management queue after the shutdown task of process B0 has been completed by the first thread T1 and the shutdown tasks of processes A0 and C0 have been completed by the second thread T2 in a specific example.
[0027] Figure 6 The structure of a multi-process management system for a system-on-a-chip according to some embodiments of this application is illustrated;
[0028] Figure 7 This is a flowchart of a multi-process management method for a system-on-a-chip according to some specific embodiments of this application;
[0029] Figure 8 Based on an example of processes A, B, C, D, and E, the dependencies when the first request of the on-chip system is a boot request;
[0030] Figure 9 According to the embodiments of this application Figure 8 The diagram illustrates the time taken for the on-chip system to execute its power-on request.
[0031] Figure 10 This is a schematic diagram of the device according to the example of this application. Detailed Implementation
[0032] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the implementation methods of this application will be clearly and completely described below with reference to the accompanying drawings. It should be noted that the described implementation methods are only a part of the implementation methods of the technical solutions of this application, and not all of them. All other implementation methods obtained by those skilled in the art based on the implementation methods described in this application document without creative effort are covered by the protection scope of this application.
[0033] In the examples of this application, "after" includes the situation of "at" or "when". For example, "after receiving the first request" includes the situation when the first request is received, specifically, the operation or action begins from the moment the first request is received.
[0034] Figure 1The diagram illustrates the structure of a System-on-Chip (SoC) 1 according to one embodiment. SoC 1 can be designed for use in any computing device or integrated into a multi-chip architecture within a computing device. The computing devices mentioned herein include in-vehicle controllers or in-vehicle processors, mobile electronic devices such as mobile phones, computers, servers, etc. For an in-vehicle controller, it can be a vehicle controller or a domain controller. Domain controllers include, for example, powertrain domain controllers, chassis domain controllers, intelligent infotainment (cockpit) domain controllers, autonomous driving domain controllers, etc. SoC 1 can be coupled to other SoCs (not shown), and each SoC can be electrically coupled to a local storage device, such as a volatile local storage device. SoC 1 includes on-chip components, which may vary depending on actual needs; the components shown herein are illustrative and not limiting. SoC 1 may include interconnected components, such as one or more processors, interfaces for connecting to other SoCs, and memory for controlling devices such as volatile storage devices; wherein the one or more processors include, for example, a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processor (DSP), etc.
[0035] For example, Figure 1 The illustrated SoC 1 may include a storage controller 16 for connecting and controlling local storage devices, an interface 14 for connecting other SoCs, and processors 12 and 13. The processors (12, 13), interface 14, and storage controller 16 of the SoC 1 are connected via a bus. It should be understood that the SoC 1 supports an operating system. For example, when used in a computing device, the SoC 1 supports the operating system or middleware used by that device. For instance, when the SoC 1 is applied in a vehicle as an in-vehicle component, it may support the vehicle's middleware or operating system.
[0036] The programs running on a system-on-a-chip (SoC) can be divided into different running groups, each containing one or more processes. The criteria for dividing running groups can vary depending on the application scenario of the SoC. For example, when the SoC is applied to a vehicle, based on the functional requirements of autonomous driving and advanced driver assistance systems (ADAS), the relevant programs are divided into different running groups. For instance, the programs on a vehicle used for autonomous driving or ADAS can be divided into a basic running group, a sensor running group, a driving running group, and a parking running group. The basic running group contains the most fundamental programs that ensure the operation of autonomous driving or ADAS, such as system initialization and low-level communication protocols; the sensor running group may include programs for sensor data acquisition and processing; the driving running group controls operations related to vehicle driving; and the parking running group controls operations related to vehicle parking. Processes within each running group may or may not have dependencies on each other or some processes.
[0037] Figure 2This is a schematic diagram illustrating an exemplary operating group and some processes of a system-on-a-chip (SoC) installed in a vehicle. In this example, under normal conditions (labeled 3 in the diagram), the programs running on the SoC include a basic operating group 30, a sensor operating group 31, a driving operating group 32, and a parking operating group 33. The basic operating group 30 includes processes A0 and A1, the sensor operating group 31 includes process B0, the driving operating group 32 includes process C0, and the parking operating group 33 includes processes D1 and D0.
[0038] In these processes, process B0 depends on process A1, and process C0 depends on process D0. That is, process B0 can only be running if process A1 is running, and process B0 can only be running if process D0 is running. It should be understood that in the relationship between processes A1 and B0, process A1 is the dependent process, and in the relationship between processes C0 and D0, process D0 is the dependent process.
[0039] exist Figure 2 In this application, dashed lines represent dependencies between processes. In the example where the first request is a startup request, as will be illustrated below, a process depending on another process means that the first process starts only if the other process has already started; in the example where the first request is a shutdown request, a process depending on another process means that the other process can only shut down after the first process has shut down. For example, process B0 depending on process A1 means that process B0 starts only if process A1 has already started, and process A1 can only shut down after process B0 has shut down; process C0 depending on process D0 means that process C0 starts only if process D0 has already started, and process D0 can only shut down after process C0 has shut down. It should be noted that... Figure 2 This is merely a simple illustration of dependencies between processes, not a limitation.
[0040] In actual operation, the dependencies between processes are more complex. For example, process A1 is depended on by multiple (e.g., dozens) processes.
[0041] Figure 3 This is a flowchart illustrating a multi-process management method for an on-chip system according to an example of this application. This method can be executed by the on-chip system, for example... Figure 1 The illustrated system-on-a-chip (SoC) can further be a SoC located within a vehicle controller, thereby allowing the method to be executed on the vehicle controller, such as any one or more vehicle controllers or vehicle domain controllers. In other examples, the method can be executed by a device including a system-on-a-chip processor or a device including the processor. Devices including processors include computers, personal computers, portable electronic devices, etc.
[0042] The following describes the actions performed by the controller in the vehicle. Figure 3 The method shown is illustrated as an example. Furthermore, the controller is, for example, a vehicle's domain controller.
[0043] like Figure 3 As shown, in step S600, in response to the first request, multiple processes involved in the first request are checked. Upon receiving the first request, multiple processes that need to execute the task requested by the first request are checked. In this example, the processes can be checked continuously until all processes that should execute the task requested by the first request have completed their tasks. In some specific examples in this paper, the first request is a shutdown request, such as a request to shut down the on-chip system executing this method. In this example, the processes that need to be shut down when shutting down the on-chip system are all processes involved in the first request. In other examples, the first request is a startup request or power-on request, such as a request to start the on-chip system. In this example, the processes that need to be started when starting the on-chip system are all processes involved in the first request.
[0044] In step S602, the processes that meet the queuing conditions among the plurality of processes are pushed into the first queue, wherein the process with the highest priority in the first queue is set at the head of the first queue.
[0045] According to some embodiments of this application, a process is pushed into the first queue only if it meets the enqueueing conditions. Whether a process meets the enqueueing conditions depends on the completion of its dependencies, which varies depending on the first request. For example, under a shutdown request, a process is enqueued if all other processes that depend on it have been shut down; under a start request, a process is enqueued if all other processes that it depends on have been started. For example, under a shutdown request, dependent process A1 (see...) Figure 2 All processes (such as) have been shut down. Figure 2 When process B0 in the queue closes, process A1 is considered to have completed its dependencies and met the enqueueing conditions, and can be pushed into the first queue. Upon a startup request, process B0, in the context of its dependent processes (such as...), is considered to have completed its dependencies and met the enqueueing conditions, and can be pushed into the first queue. Figure 2 When process A1) has started, process B0 is considered to have completed its dependencies and met the enqueue conditions, and can be pushed into the first queue.
[0046] According to embodiments of this application, the priority of a process can be determined based on one or more of the following factors: determining the priority of a process based on the dependencies between each process; determining the priority of a process based on the time taken for each process to execute the first requested task. Specifically, if a process has dependencies on other processes, its priority for the first request can be determined based on the dependencies between that process and other processes. Optionally or additionally, its priority can also be determined based on the duration taken for a process to execute the first requested task; for example, for a shutdown request, the longer the time taken to execute the shutdown task, the higher the priority is set.
[0047] For example, when the first request is a shutdown request, for processes with dependencies, their priorities are set in such a way that the dependent process shuts down later than the processes that depend on it; that is, the priority of the dependent process is lower than the priority of the processes that depend on it. For example, Figure 2 The process B0 shown depends on process A1. For shutdown requests, the priority can be configured so that process B0 is shut down before process A1. That is, under shutdown requests, the priority of process B0 is higher than that of process A1. Figure 2 The process C0 is dependent on process D0, so the priority of process C0 can be set higher than that of process D0 so that process C0 can be shut down before process D0.
[0048] Furthermore, for processes with no dependencies, priority can be configured based on the duration of the task requested by their first request. When the first request is a shutdown request, processes that take longer to shut down can have higher priority. For example, Figure 2 If the shutdown time of process B0 is longer than that of process C0, then the priority of process B0 can be set to be higher than that of process C0. As an example, the duration of the task requested by the first process request can be determined based on historical data. For instance, by analyzing historical data on how each process completed its shutdown operation during a shutdown request, it can be determined which process took longer and which took shorter.
[0049] Furthermore, when configuring priorities, both dependencies and the duration of the task requested in the first request can be considered. For example, if processes e and f depend on the same process d, according to the example of this application, when setting the priorities of processes e and f under a shutdown request, their relationship with process d can be considered, and the priorities of processes e and f can be set to the same level but higher than the priority of process d; or further, while setting their priorities to be higher than that of process d, the priorities of processes e and d can be set according to their respective shutdown durations. In a further example, the degree of process dependency can also be considered when configuring the priorities of processes e and f.
[0050] According to some examples in this application, the priorities of some processes can also be set to be the same as needed. For example, processes that take the same amount of time to execute the first request can be configured to have the same priority.
[0051] Generally, prioritizing almost all processes involved in fulfilling the first request can be accomplished based on dependencies and the duration of the task executing the first request. If, after prioritizing the task executing the first request based on dependencies and execution duration, there are still processes whose priorities cannot be set accordingly, their priorities can be set to a lower priority than the already set priority; or their priorities can be set to the same; or priorities can be set in other ways.
[0052] In this example, processes that do not meet the enqueueing criteria do not enter the first queue. As an example, but not a restriction, it is possible to determine whether a process has completed its dependencies and thus meets the enqueueing criteria by observing the counter value of each process. Using process A1 in the above example, assuming that, except for... Figure 2 If process B0 depends on process A1, and there are multiple other processes (e.g., x, not shown) that depend on process A1, then the count value of process A1 is x+1. Under a shutdown request, each time one of the processes that depend on process A1 completes its shutdown request task, the count value is decremented by 1. When the count value reaches 0, it is confirmed that process A1 has completed its dependency relationship under the shutdown request, thus satisfying the enqueue condition.
[0053] According to the example in this application, the highest-priority process in the first queue is placed at the head of the first queue. Upon receiving a newly pushed process, the first queue compares its priority with the priority of the process already at the head of the queue. If the newly pushed process has a higher priority, it is placed at the head of the queue. Comparing the priority of the newly pushed process only with the priority of the process already at the head of the queue ensures that the high-priority process is placed at the head of the first queue with minimal runtime overhead. Alternatively, upon receiving a newly pushed process, the first queue can compare its priority with the priorities of existing processes in the first queue and set the position of the newly pushed process in the first queue according to the comparison result. By way of example, and not limitation, in the example of this application, `std::push_heap` and `std::pop_heap` can be used to compare the priorities of elements (processes with priorities) in the queue.
[0054] In step S604, a thread is allocated to the process at the head of the first queue to execute the task requested by the first queue, and the process at the head of the queue is pushed out of the first queue.
[0055] When an idle thread exists in the thread pool, it is allocated to the process at the head of the first queue. According to the example in this application, when multiple idle threads exist in the thread pool, after allocating an idle thread to the process at the head of the queue, the remaining idle threads can be allocated to processes after the head of the first queue, and the allocated threads are then pushed out of the first queue.
[0056] Figure 4The illustration shows a process management procedure according to some specific examples of this application. In this example, a process is combined with... Figure 2 In the example described, the first request of the process is, for example, a shutdown request. In this example, the on-chip system is, for example, Figure 1 Example System-on-Chip 1.
[0057] Please refer to the following at the same time Figure 1 , Figure 2 and Figure 3 .right Figure 2 The processes A0, A1, B0, C0, D0, and D1 in the table are assigned priorities under shutdown requests based on their dependencies and their respective shutdown durations. Table 1 illustrates the priorities of processes A0, A1, B0, C0, D0, and D1 under shutdown requests. The shutdown duration for each process can be obtained in advance through experiments or based on empirical data.
[0058] Table 1
[0059] process A0 A1 B0 C0 D0 D1 Priority 2 4 4 3 1 1
[0060] In real-world applications, process dependencies are more complex than... Figure 2 The illustration is complex. Figure 2 This is merely a simplified illustration for the purpose of describing this application; for example, process A0 in... Figure 2 There are no dependencies listed in the table, but in real-world applications, there may be processes that depend on process A0, or process A0 may depend on other processes not shown. Therefore, by way of example and not limitation, in the following description, each process is assumed to have dependencies when checking processes. For processes that do not actually have dependencies, when a process is checked, it is assumed that its dependencies have been fulfilled.
[0061] like Figure 4 As shown, after receiving a power-off request, the on-chip system checks... Figure 2Each process in the system is checked to determine if it has fulfilled its enqueueing criteria by verifying that its dependencies have been completed. As an example, the on-chip system's process manager can check the processes in the reverse order of their boot sequence. In this example, process A0, with a priority of 2 and completed dependencies, is pushed into the shutdown queue Q. Process A0 is now at the head of the queue (Q_top), as shown in step 41. Then, process B0, with a priority of 4 and completed dependencies, is pushed into queue Q, as shown in step 42. Process B0 has a higher priority than process A0, so it is placed at the head of queue Q. Process C0, with a priority of 3 and completed dependencies, is pushed into queue Q, as shown in step 43. Process C0 has a lower priority than process B0 at the head of queue Q, so no reordering is performed on the processes in the queue. Process D1, with a priority of 1 and completed dependencies, is pushed into queue Q, as shown in step 44. Process D1 also has a lower priority than process B0 at the head of queue Q, so no reordering is performed on the processes in the queue. It should be noted that in this example, only the priority of the process pushed into the queue is compared with the priority of the process at the head of the queue. However, in alternative embodiments, the priority of the process pushed into the queue can also be compared with the priorities of the existing processes in the queue. In this case, if the pushed process has the highest priority, it is placed at the head of the queue, and the positions of the remaining processes in the queue can be either left unsorted or sorted. For example, in step 43, if the priority of process C0 is not the highest compared to the existing processes B0 and A0 in the queue, it can be placed after the existing process A0; or, process B0 can be placed after process C0 and before A0 according to priority order.
[0062] It should be noted that, for ease of viewing, Figure 4 The number marked under each process is the priority of that process, corresponding to Table 1.
[0063] When there are idle threads in the thread pool, the idle threads are allocated to processes in the queue and the processes are removed from the queue. According to the method in this application, when there are, for example, two idle threads in the thread pool, in addition to allocating idle threads to the process at the head of the queue, idle threads can also be allocated to processes after the head of the queue. For example, when there are idle threads in the thread pool (such as the first thread T1), they are allocated to process B0 at the head of the queue and process B0 is removed from the queue Q so that process B0 can execute the first request (in this example, a shutdown request) task in that thread; when there are still idle threads in the thread pool (such as the second thread T2), the idle thread is allocated to the process after B0 and the process allocated the idle thread is removed so that the second thread T2 can execute the first request task. In this way, during the shutdown of process B0, the shutdown tasks of one or more of the remaining processes can be executed simultaneously by other threads. This speeds up process shutdown, and even if an exception occurs during the shutdown of process B0, it does not affect the shutdown tasks of the remaining processes being performed by other threads.
[0064] In the example of this application, in process management (e.g., execution, status, and health management ESME), each process is configured with a counter. When a process's counter becomes 0, the process is considered to have completed its dependencies and can enter the first queue. For example, under a shutdown request, checking whether the counter value is 0 can determine whether the process has completed its dependencies.
[0065] When only a single idle thread exists for an extended period of time. Figure 4 In the example, processes B0, A0, C0, and D1 may execute sequentially. (See reference...) Figure 4As shown in step 45, process B0 has acquired a thread and is therefore removed from queue Q. Subsequently, process A1, on which process B0 depends, fulfills its dependency and meets the enqueueing conditions, and is pushed into queue Q, as shown in step 46. When process A1 enters queue Q, its priority is compared with the priority of process C0 at the head of queue Q, or with the priority of existing processes. If process A1 has the highest priority, it is pushed to the head of queue Q. Process A1 has a priority of 4, which is higher than the priority of process C0, or higher than the priorities of processes A0 and D1 when compared with existing processes. Therefore, process A1 is placed at the head of queue Q, as shown in step 47. In this example, when process A1 acquires a thread to perform a shutdown task, process A1 is removed from queue Q, as shown in step 48. Subsequently, as shown in step 49, process C0 is also assigned a thread and removed from queue Q. At this point, process D0, which process C0 depends on, completes its dependency relationship and is pushed into queue Q. Because its priority is not the highest in the queue, process D0 is located at the end of the queue elements according to its entry order, as shown in step 50. Subsequently, processes A0, D1, and D0 complete their shutdown tasks in sequence, as shown in steps 51, 52, and 53, respectively.
[0066] In other cases, the thread pool may have two or more idle threads appearing simultaneously or quickly. Following the example of this application, the processes in queue Q may be assigned to idle threads simultaneously or sequentially, resulting in the simultaneous or parallel execution of the first requested task. For instance, if process B0 at the head of queue Q is executed by the first thread T1, and the shutdown of the remaining three, two, or one processes in queue Q can be handled by another idle thread, such as the second thread T2, then starting from step 45, it is possible that process B0 and the subsequent three, two, or one processes will all finish execution and be pushed out of queue Q. In this case, multiple processes can be pushed into queue Q.
[0067] Figure 5 This illustrates that process B0, assigned to the first thread T1, is removed from the queue to perform a shutdown task. Simultaneously, the idle second thread T2 from the thread pool is assigned to processes A0 and C0, which are also removed from the queue to perform shutdown tasks, as shown in step 55. Processes B0, A0, and C0 are removed from queue Q. Processes A1 and D0 complete their dependencies and are pushed into queue Q, as shown in step 56. Process A1 has the highest priority and is placed at the head of queue Q, as shown in step 57. An idle thread is requested from the thread pool for process A1 to perform its shutdown task. Similarly, idle threads can be requested from the thread pool for processes D1 and D0 to perform their shutdown tasks.
[0068] Figure 6This is a schematic illustration of a multi-process management system 2 for a system-on-a-chip according to some embodiments of this application. The process management system 2 includes a priority setting module 20 and a process manager 22. The priority setting module 20 can set priorities for processes. For example, priorities can be set at least based on inter-process dependencies. In a further example, priorities can be determined according to the time taken for a process to execute a first requested task. The process manager 22 can manage processes and, in response to a first request, check the multiple processes involved in the first request. Specifically, it traverses the multiple processes involved, checks whether the dependencies of each process are completed, determines whether the process meets the enqueueing conditions, and performs corresponding processing accordingly. Specifically, after receiving a first request, the process manager 22 checks the inter-process dependencies; pushes processes that have completed all dependencies into a first queue and sets the highest-priority process in the first queue at the head of the first queue so that it can be popped out when assigned a thread to execute the first requested task. The process manager 22 also pushes processes that have completed dependencies but have not yet entered the queue into the first queue. The priority setting module 20 can set different priorities for processes depending on the first request. According to the example of this application, the priority setting module 20 pre-configures priorities for processes for different requests, so that tasks can be processed directly according to priorities when they are executed.
[0069] The above text, combined with the appendix Figures 2 to 5 The described multi-process management method for on-chip systems can be derived from... Figure 6 The illustrated implementation of a multi-process management system for an on-chip system. Priority setting module 20 sets priorities for each process in response to the first request. Process manager 22 checks whether a process meets the enqueueing conditions, pushes the processes that meet the conditions into the first queue, and sets the highest-priority process to the head of the queue. When the process at the head of the queue is assigned an idle thread, it is removed from the queue. In some examples, when multiple idle threads exist, and threads are assigned to the process at the head of the queue and subsequent processes, all processes assigned threads are removed from the queue so that they can be executed by the idle threads respectively. For example, process manager 22 executes steps S600, S602, and S604.
[0070] Figure 7 This is a flowchart of a process management method for a system-on-a-chip according to some embodiments of this application. The system-on-a-chip may execute this method at power-on, at power-off, or under other circumstances; that is, the first request may be a power-on request to execute a startup task, a power-off request to execute a shutdown task, or a request to execute other tasks. Reference will also be made below. Figure 2 and Figure 7 illustrate.
[0071] In step S700, in response to the first request, process manager 22 checks each process related to the task requested by the first request. Process manager 22 checks each process related to the task requested by the first request to confirm whether its dependencies have been fulfilled.
[0072] According to an embodiment of this application, each process is configured with a first counter and a second counter representing dependencies. The initial value of the first counter represents all first-type dependencies of the process, and the initial value of the second counter represents all second-type dependencies of the process. First-type dependencies refer to the relationships in which the process is depended upon by other processes, such as process A1 in the above example (see...). Figure 2 Since process A1 is dependent on process B0, the initial value of the first type of dependency counter for process A1 is 1. Second type of dependency refers to the relationship where a process depends on other processes. Process A1 in... Figure 2 The process B0, which does not depend on other processes, has its second counter initialized to 0. In contrast, process B0's first counter is initialized to 0 while its second counter is initialized to 1.
[0073] For example, process manager 22 can determine whether a process has completed its dependency based on the count value of each process. It should be noted that when two counters are set for each process, the count of the first request determines which counter is used to judge the completion of the dependency. For example, if the first request is a shutdown request, the dependent process should only close after the process that depends on it closes; therefore, process manager 22 determines whether the process has completed its dependency based on the count value of the first counter. If the first request is a power-on request, the dependent process should precede the process that depends on it; therefore, process manager 22 determines whether the process has completed its dependency based on the count value of the second counter.
[0074] Still using process A1 as an example, assuming that besides Figure 2 If process B0 depends on process A1, and there are multiple other processes (e.g., x, not shown) that depend on process A1, then the first counter for process A1 will have a count of x + 1. When the first request is a shutdown request, each time one of the processes that depend on process A1 completes the task requested in the first request, the count of the first counter will be decremented by 1, until the count reaches 0, at which point it is confirmed that process A1 has completed the first type of dependency. Furthermore, if process A1 depends on multiple other processes (e.g., y),... Figure 3 If (not shown in the diagram), then the count value of the second counter for process A1 is y. When the first request is a boot request, whenever one of the y processes that process A1 depends on finishes its boot task, the count value of the second counter is decremented by 1, until the count value is 0, at which point it is confirmed that process A1 has completed the second type of dependency relationship.
[0075] In some alternative embodiments, the first type of dependency and the second type of dependency use the same counter, with the initial value of the counter differing depending on the type of the first request. For example, when the first request is a shutdown request, the initial value of the counter represents the value of the first type of dependency; when the second request is a power-on request, the initial value of the counter is configured to represent the value of the second type of dependency. For example, suppose process A1 depends on multiple (e.g., y) other processes (… Figure 2 (Not shown in the image), then when the first request is a boot request, the initial value of the counter is y. Each time one of the y processes that process A1 depends on completes its boot task, the counter value is decremented by 1, until the count value is 0, indicating that process A1 has completed the second type of dependency. For example, suppose that besides... Figure 2 If process B0 depends on process A1, and there are multiple other processes (e.g., x) that depend on process A1, then when the first request is a shutdown request, the counter value is x+1. Whenever one of the multiple processes that depend on process A1 finishes executing the task of the first request, the counter value is decremented by 1, until the count value is 0, at which point it is confirmed that process A1 has completed the first type of dependency relationship.
[0076] In an alternative example, the counter can be initialized to 0 and then incremented by 1 based on the completion of dependencies until the counter's count matches the number of dependencies for that process. For example, suppose that besides Figure 2 If process B0 depends on process A1, and there are multiple other processes (e.g., x) that depend on process A1 (not shown), then when the first request is a shutdown request, the total number of process dependencies is x+1, and the initial value of the counter is 0. Whenever one of the processes that depend on process A1 completes the task requested in the first request, the count of the first counter is incremented by 1, until the count reaches x+1, confirming that process A1 has completed the first type of dependency.
[0077] In step S702, processes that have completed all dependencies are pushed into the first queue. Specifically, when process manager 22 confirms that a process has completed the dependencies under the first request based on the count value, it pushes the process into the first queue. After a process completes its dependencies, if there is an empty space in the first queue Q, process manager 22 pushes the process into the first queue Q, for example... Figure 4 The examples include steps 42, 43, 44, and 46.
[0078] In step S704, the priority of the process pushed into the first queue is compared with the priority of the process at the head of the first queue. If the priority of the pushed process is higher, the process is moved to the head of the first queue, and the process originally at the head of the queue is moved to the back. Specifically, the process manager 22, based on the priority set by the priority setting module 20 for each process in the first request, sets the process with the highest priority to the head of the first queue so that it can be pushed out first. For example... Figure 4 Steps 42 and 47 are shown in the diagram. The priority settings have been described above and will not be repeated here.
[0079] Furthermore, according to the examples in this application, after setting the highest-priority process pushed in to the head of the first queue, the existing processes in the first queue are sequentially shifted to the next order. For example, Figure 4 In Figure 47, after process A1 is placed at the head of queue Q, processes C0, A0, and D1, which were already in queue Q, are moved sequentially to the next position. This sequential movement means that C0, A0, and D1 are moved to the next position as a whole while maintaining their original order. Alternatively, the processes already in queue Q can be sorted according to priority. Or, they can be sorted each time a new process is received.
[0080] In step S706, when there are idle threads in the thread pool, a thread is allocated to a process in the first queue, and the process to which a thread is allocated is removed from the first queue. If the thread pool has only one idle thread, the idle thread is allocated to the process at the head of the first queue so that the process can execute the first requested task. If there are multiple idle threads in the thread pool, one of the idle threads is allocated to the process at the head of the queue, and threads are allocated from the remaining idle threads to the processes following the head of the queue so that the processes or these processes can execute the first requested task. For example, if there are two idle processes in the current thread pool, the process manager 22 allocates one idle thread to the process at the head of the first queue and the other to the process immediately following the head of the queue, and removes both processes to which threads are allocated from the first queue.
[0081] It should be understood that once a slot becomes available in the first queue, for example, if some processes are pushed out of the queue, the process manager 22 will push processes that have completed their dependencies and are relevant to the first request into the first queue. In this example, the process of checking the process status continues until all processes relevant to the first request have entered the first queue.
[0082] According to the examples in this application, when executing the first requested task, the order of processes in the first queue can be configured according to priority, rather than necessarily following a pre-existing order. This allows the highest-priority processes (e.g., tasks that take a relatively long time to execute the first requested task and / or tasks that should be executed earlier due to dependencies on the first request) to be preferentially assigned threads to execute the first requested task, minimizing the impact of such processes experiencing issues executing the first requested task. Furthermore, when multiple idle threads are available, some embodiments of this application can simultaneously assign threads to multiple processes so that they can execute the first requested task concurrently, saving time for the entire first request to complete.
[0083] For example, Figure 8 The diagram shows processes A, B, C, D, and E. During the on-chip system's boot process, process A depends on processes B and D, process E depends on process D, and processes B and C each depend on process D. In the boot request, the startup order is: process D starts first, then processes B, C, and E, and finally process A. Assume process E starts very slowly, for example, in 30 seconds, and the startup times for processes A, B, C, and D are each 5 seconds. Then, if they are started sequentially, the total boot time would be 50 seconds.
[0084] If the example according to this application is executed, the priority of process E will be set relatively high because it has been running the longest. Specifically, the priority of process E is lower than that of process D, but higher than that of processes B, C, and A. At this point, depending on the idle threads in the thread pool, the following may occur: Figure 9 The situation is as shown. As... Figure 9 As shown, in the first 5 seconds, only thread T1 is idle, so process D obtains thread T1 to execute the startup task. After 5 seconds, threads T1 and T2 are idle. At this time, the highest priority E is assigned to thread T1, while thread 2 is assigned to processes B, C, and A, which are located after process E. Thread T1 takes 30 seconds to execute the startup task of E, while processes B, C, and A execute their startup tasks in sequence on thread T2, almost in parallel with the startup task of thread T1, taking 15 seconds. Thus, the entire startup time is 35 seconds, which is 15 seconds faster than the 50 seconds startup time without executing the embodiment of this application.
[0085] Most of the embodiments and examples above are described in conjunction with shutdown requests. If the first request is a power-on request, the priority set by the priority setting module 20 is different from the priority set for shutdown requests. For power-on requests, processes that depend on other processes have a lower priority than those other processes. For example, Figure 2As shown, process B0 depends on process A1. For boot requests, process B0 will have a lower priority than process A1 to ensure that process A1 starts first. For processes without dependencies, the process that takes longer to execute its first requested task has a higher priority.
[0086] When the first request is for other requests, the priority can be set according to actual needs, and this application will not list them all.
[0087] Figure 10 This is a schematic diagram of the structure of an example on-chip system according to this application. For example... Figure 10 As shown, the system-on-a-chip includes a memory 1100 and a processor 1102. The memory 1100 stores instructions, and the processor 1102 executes these instructions to implement one of the embodiments described above.
[0088] This application also provides an apparatus, the apparatus comprising, as described above. Figure 10 The system-on-a-chip shown is an example. This device can be installed in a vehicle, specifically as an on-board controller, such as a vehicle controller, or a vehicle domain controller.
[0089] This application also provides a program product including stored instructions that, when executed, enable a process management method for a system-on-a-chip as described in the embodiments above.
[0090] The technical features in the various embodiments of this application can be combined with each other to form new implementation methods without departing from the spirit of this application and without conflicting with each other. Although specific embodiments of this application have been shown and described in detail to illustrate the principles of this application, it should be understood that this application can be implemented in other ways without departing from such principles.
Claims
1. A multi-process management method for a system-on-a-chip, characterized in that, The method includes: Inspect the multiple processes involved in the first request; The processes that meet the enqueueing conditions among the plurality of processes are pushed into the first queue, wherein the process with the highest priority in the first queue is set at the head of the first queue; Assign a thread to the process at the head of the queue to execute the task requested by the first process and remove the process at the head of the queue from the first queue; The priority of the plurality of processes for the first request is preset.
2. The method according to claim 1, characterized in that, The method further includes: When allocating a thread to the process at the head of the queue, if there are still idle threads in the thread pool, the idle thread is allocated to the process after the head of the first queue and the process allocated the idle thread is squeezed out of the first queue.
3. The method according to claim 1, characterized in that, Pushing processes that meet the enqueueing criteria into the first queue from among the plurality of processes also includes: The priority of the pushed process is compared with the priority of the process at the head of the queue, and if the priority of the pushed process is higher, the pushed process is set to the head of the queue.
4. The method according to claim 1, characterized in that, Pushing processes that meet the enqueueing criteria into the first queue from among the plurality of processes also includes: The priority of the pushed process is compared with the priority of the existing processes in the first queue, and the position of the pushed process in the first queue is set according to the comparison result.
5. The method according to claim 1, characterized in that, The priority of the multiple processes for the first request is pre-set according to any one or more of the following: The priority is determined according to the dependencies of each process; Priority is determined based on the time each process takes to execute the task requested in the first request.
6. The method according to claim 5, characterized in that, The first request is to shut down the on-chip system, wherein determining the priority according to the dependencies of each process includes setting the priority of processes that depend on other processes to be higher than the priority of those other processes; determining the priority according to the time each process takes to execute the task of the first request includes setting the priority of processes that take longer to execute the task of the first request to be higher; and For each process, the enqueue condition depends on the fact that all other processes of that process have been shut down.
7. The method according to claim 5, characterized in that, The first request is a request to start the on-chip system, wherein determining the priority according to the dependencies of each process includes setting the priority of processes that depend on other processes to be lower than the priority of those other processes; determining the priority according to the time each process takes to execute the task of the first request includes setting the priority of processes that take longer to execute the task of the first request to be higher; and For each process, the enqueue condition is that all other processes that the process depends on have been started.
8. The method according to any one of claims 1 to 7, characterized in that, Examine the multiple processes involved in the first request, including: The process iterates through the multiple processes and determines whether a process meets the enqueueing condition based on the counter value of each process.
9. A system-on-a-chip, characterized in that, The on-chip system includes: Memory, used to store program instructions; A processor for executing the program instructions and, in the process of executing the program instructions, implementing the method according to any one of claims 1 to 8.
10. An apparatus, characterized in that, The device includes at least the system-on-a-chip as claimed in claim 9.
11. The apparatus according to claim 10, characterized in that, The device is a vehicle-mounted controller, which includes any one of the following controllers: The vehicle's overall controller; The vehicle's domain controller.
12. A program product, characterized in that, The program product includes program instructions that, when executed, can implement the method according to any one of claims 1 to 8.