Interrupt Handling Method, Device, Equipment, and Storage Medium Applied to a Microkernel
By obtaining and comparing process identifiers related to interrupt events in the microkernel, and directly switching and executing interrupt service programs, the problem of excessive interrupt response time in the prior art is solved, and more efficient interrupt processing is achieved.
Patent Information
- Application Number
- CN202010795937.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-10
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2040-08-10
AI Technical Summary
When existing microkernels perform interrupt processing, they need to call the kernel scheduling algorithm to select the scheduled process, resulting in too long interrupt response time.
Compare by obtaining the process identifier of the first process that registers the interrupt event and the second process that currently occupies the central processor. If it is inconsistent, switch directly to the first process and execute the interrupt service program; if it is consistent, call the interrupt service program directly and execute.
This avoids the complex scheduling selection process of the kernel scheduling algorithm, significantly saves interrupt response time, improves interrupt response efficiency and microkernel performance.
Smart Images

Figure CN114064227B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technologies, and in particular, to an interrupt processing method, apparatus, electronic device, and computer storage medium applied to a microkernel. Background Art
[0002] A microkernel is a reduced version of a kernel that provides core functions of a computer operating system. A microkernel typically includes two states: a kernel mode and a user mode. The kernel mode mainly implements basic functions related to the microkernel, such as process management, thread management, memory management, and inter-process communication. Other services, including device drivers and interrupt service routines, are implemented in the user mode.
[0003] Interrupt processing refers to the process in which, when certain unexpected situations occur during the operation of a computer and need to be intervened, the operating system will actively stop the running process or thread and execute the corresponding interrupt service routine. However, the inventors found during the implementation of the present invention that when the microkernel in the prior art performs interrupt processing, it is necessary to call the kernel scheduling algorithm to select the process to be scheduled, and then perform process switching and execute the interrupt service routine, resulting in the defect of too long interrupt response time. Summary of the Invention
[0004] To solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides an interrupt processing method, apparatus, microkernel operating system, electronic device, and computer storage medium applied to a microkernel.
[0005] An embodiment of the present disclosure provides an interrupt processing method applied to a microkernel, including:
[0006] When an interrupt event occurs, obtain the process identifier of the first process that registers the interrupt event;
[0007] Obtain the process identifier of the second process that currently occupies the central processing unit;
[0008] When it is determined that the process identifiers of the first process and the second process are inconsistent, switch to the first process and execute the interrupt service routine corresponding to the interrupt event; or, when it is determined that the process identifiers of the first process and the second process are consistent, and the first process and the second process are the same process, call the interrupt service routine and execute it.
[0009] In some embodiments, when it is determined that the process identifiers of the first process and the second process are inconsistent, the method further includes:
[0010] Record the process identifier of the second process that currently occupies the central processing unit;
[0011] After executing the interrupt service program corresponding to the interrupt event, process switching is performed according to the recorded process identifier of the second process to switch back to the second process.
[0012] In some embodiments, obtaining the process identifier of the second process currently occupying the central processing unit includes:
[0013] Reading a first variable that records the occupancy information of the central processing unit from the memory module to obtain the process identifier of the second process currently occupying the central processing unit.
[0014] In some embodiments, when it is determined that the process identifiers of the first process and the second process are the same, and the first thread registering the interrupt event is for the same process, the method further includes:
[0015] Obtaining the thread tag of the second thread of the same process currently occupying the central processing unit;
[0016] Recording the thread identifier of the second thread;
[0017] After executing the interrupt service program, directly switch back to the second thread according to the recorded thread identifier of the second thread.
[0018] In some embodiments, obtaining the thread tag of the second thread of the same process currently occupying the central processing unit includes:
[0019] Reading a second variable that records the occupancy information of the central processing unit from the memory module to obtain the thread tag of the second thread of the same process currently occupying the central processing unit.
[0020] An embodiment of the present disclosure also discloses an interrupt processing device applied to a microkernel, including:
[0021] A first identifier obtaining module, configured to obtain the process identifier of the first process registering the interrupt event when an interrupt event occurs;
[0022] A second identifier obtaining module, configured to obtain the process identifier of the second process currently occupying the central processing unit;
[0023] A comparison module, configured to determine whether the process identifiers of the first process and the second process are the same;
[0024] A first program execution module, configured to switch to the first process and execute the interrupt service program corresponding to the interrupt event when it is determined that the process identifiers of the first process and the second process are different; or, when it is determined that the process identifiers of the first process and the second process are the same, and the first process and the second process are the same process, call the interrupt service program and execute it.
[0025] In some embodiments, when it is determined that the process identifier of the first process is inconsistent with the process identifier of the second process, the apparatus further includes:
[0026] A first recording module, configured to record the process identifier of the second process currently occupying the central processing unit;
[0027] A process switching module, configured to perform process switching according to the recorded process identifier of the second process after executing the interrupt service program corresponding to the interrupt event, so as to switch back to the second process.
[0028] In some embodiments, the second identifier obtaining module is specifically configured to read a first variable recording the occupancy information of the central processing unit from the memory module, so as to obtain the process identifier of the second process currently occupying the central processing unit.
[0029] In some embodiments, when it is determined that the process identifier of the first process is consistent with the process identifier of the second process, and the first thread registering the interrupt event is the same process, the apparatus further includes:
[0030] A third identifier obtaining module, configured to obtain the thread tag of the second thread of the same process currently occupying the central processing unit;
[0031] A second recording module, configured to record the thread identifier of the second thread;
[0032] A thread switching module, configured to directly switch back to the second thread according to the recorded thread identifier of the second thread after executing the interrupt service program.
[0033] In some embodiments, the third identifier obtaining module is specifically configured to read a second variable recording the occupancy information of the central processing unit from the memory module, so as to obtain the thread tag of the second thread of the same process currently occupying the central processing unit.
[0034] The embodiments of the present disclosure further provide a microkernel operating system, including the interrupt processing apparatus in any of the above embodiments.
[0035] The embodiments of the present disclosure further provide an electronic device, where the electronic device includes: a processor; a memory for storing executable instructions of the processor; the processor is configured to read the executable instructions from the memory and execute the instructions to implement the interrupt processing method applied to the microkernel provided by the embodiments of the present disclosure.
[0036] The embodiments of the present disclosure further provide a computer-readable storage medium, where the storage medium stores a computer program, and the computer program is used to execute the interrupt processing method applied to the microkernel provided by the embodiments of the present disclosure.
[0037] In the technical solution provided by the embodiments of the present disclosure, during interrupt processing, the process identifier of the first process that registers the interrupt event and the process identifier of the second process that occupies the central processing unit are compared. When it is determined that the two process identifiers are inconsistent, the first process is directly switched to according to the process identifier of the first process, and the interrupt service program corresponding to the interrupt event is executed; when it is determined that the two process identifiers are consistent, and the first process and the second process are the same process, the interrupt service program is called and executed. By no longer executing the kernel scheduling algorithm during interrupt processing, the above technical solution of the embodiments of the present disclosure can save a large amount of time, improve the interrupt response efficiency, and improve the performance of the microkernel. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In combination with the accompanying drawings and with reference to the following specific embodiments, the above and other features, advantages, and aspects of the embodiments of the present disclosure will become more apparent. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic, and the original components and elements are not necessarily drawn to scale.
[0039] Figure 1 is a flowchart of an interrupt processing method applied to a microkernel in the prior art;
[0040] Figure 2 is Figure 1 a time progress diagram of the interrupt processing method applied to the microkernel shown in
[0041] Figure 3 is a flowchart of an interrupt processing method applied to a microkernel provided by an embodiment of the present disclosure;
[0042] Figure 4 is Figure 3 a time progress diagram of the interrupt processing method applied to the microkernel shown in
[0043] Figure 5 is a flowchart of another interrupt processing method applied to a microkernel provided by an embodiment of the present disclosure;
[0044] Figure 6 is Figure 5 a time progress diagram of the interrupt processing method applied to the microkernel shown in
[0045] Figure 7 is a flowchart of an interrupt processing method of a microkernel in the prior art;
[0046] Figure 8 is Figure 7 a time progress diagram of the interrupt processing method applied to the microkernel shown in
[0047] Figure 9Schematic flowchart of yet another interrupt handling method applied to a microkernel provided by an embodiment of the present disclosure;
[0048] Figure 10 For Figure 9 Schematic time progress diagram of the interrupt handling method applied to the microkernel shown;
[0049] Figure 11 Schematic flowchart of another interrupt handling method applied to a microkernel provided by an embodiment of the present disclosure;
[0050] Figure 12 For Figure 11 Schematic time progress diagram of the interrupt handling method applied to the microkernel shown;
[0051] Figure 13 Schematic structural diagram of an interrupt handling device applied to a microkernel provided by an embodiment of the present disclosure;
[0052] Figure 14 Schematic structural diagram of another interrupt handling device applied to a microkernel provided by an embodiment of the present disclosure;
[0053] Figure 15 Schematic structural diagram of yet another interrupt handling device applied to a microkernel provided by an embodiment of the present disclosure;
[0054] Figure 16 Schematic structural diagram of the microkernel operating system provided by an embodiment of the present disclosure;
[0055] Figure 17 Schematic structural diagram of an electronic device provided by an embodiment of the present disclosure. Detailed implementation manners
[0056] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although some embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Instead, these embodiments are provided to more thoroughly and completely understand the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not used to limit the protection scope of the present disclosure.
[0057] It should be understood that the steps recited in the method embodiments of the present disclosure can be executed in a different order and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this regard.
[0058] As used herein, the term "including" and its variations are open-ended, i.e., "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0059] It should be noted that the concepts such as "first", "second", etc. mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0060] It should be noted that the modifications of "one" and "multiple" mentioned in this disclosure are illustrative rather than restrictive. Those skilled in the art should understand that, unless otherwise clearly specified in the context, it should be understood as "one or more".
[0061] In the embodiments of this disclosure, it mainly relates to a technical solution for optimizing the interrupt response in a microkernel, which is applied to products with a microkernel. Specifically, the design concept of the microkernel is mainly to set the basic functions related to the kernel, such as process management, thread management, memory management, and inter-process communication, etc. in the kernel state, and others such as driver programs and interrupt service programs are implemented in the user state. The above design solution makes the microkernel usually need to perform several switches between the user state and the kernel state when performing interrupt processing; in addition, in traditional microkernels, it is usually stipulated that the kernel scheduling algorithm is used to implement the switch between different processes or different threads. Therefore, when the microkernel performs interrupt processing, it is also inevitable to call the kernel scheduling algorithm to select the process or thread to be scheduled. The above kernel scheduling algorithm usually needs to consider all schedulable processes or threads, and make a trade-off in terms of throughput, average response time, fairness, additional overhead caused by scheduling, etc. to determine the finally selected process or thread to be scheduled, and then perform the corresponding process switch or thread switch.
[0062] The above-mentioned switches between the user state and the kernel state, the kernel scheduling algorithm, process switch or thread switch all require corresponding processing time, resulting in the common defects of long interrupt response time and low efficiency in the microkernel of the prior art. In the embodiments of this disclosure, it is mainly aimed at the above defects, and reduces the time required for interrupt response and improves the interrupt response efficiency by avoiding or minimizing at least one of the unnecessary switches between the user state and the kernel state, the kernel scheduling algorithm, process switch or thread switch.
[0063] When performing interrupt handling within a microkernel, there are generally two cases. The first case is that the process where the interrupt service routine is located is different from the process currently occupying the central processing unit. The second case is that the process where the interrupt service routine is located is the same as the process currently occupying the central processing unit, but the specific threads are different. For the above two cases, the process of interrupt handling is also different. The embodiments of the present disclosure optimize both of the above cases, achieving the technical effects of reducing the time required for interrupt response, improving the interrupt response efficiency, and enhancing the performance of the microkernel system.
[0064] For the first case above, first, the interrupt handling solution of the microkernel in the prior art is described. Figure 1 It is a schematic flowchart of an interrupt handling method applied to a microkernel in the prior art, and the interrupt handling solution in the prior art can be understood by referring to the Figure 1 shown flowchart. Additionally, Figure 2 is Figure 1 a schematic time progress diagram of the interrupt handling method shown. As shown in Figure 1 and Figure 2 shown, the processing method includes the following steps:
[0065] Step 101: An interrupt event occurs during the operation of Process A, and this interrupt event is registered by Process B.
[0066] Step 102: The interrupt handler of the kernel wakes up Process B.
[0067] Step 103: Through the kernel scheduling algorithm for scheduling selection, select the process to be scheduled.
[0068] The specific scheduling selection process needs to obtain all runnable processes and threads, and based on scheduling policies, such as considering parameters in several aspects including throughput, average response time, fairness, and additional overhead caused by scheduling, perform process scheduling selection to select the next process to be scheduled, such as the above-mentioned Process B, and then perform a process switch to switch to Process B. The scheduling selection process of the kernel scheduling algorithm in this step is complex and time-consuming. Additionally, this step corresponds to the time period from T1 to T2, during which the above functions are implemented in the kernel mode.
[0069] Step 104: In Process B, execute the above-mentioned interrupt service routine, that is, corresponding to the time period from T2 to T3, during which the above interrupt service routine is executed in the user mode.
[0070] Step 105: After the interrupt service routine is executed, the kernel scheduling algorithm continues to perform scheduling selection to select the process to be scheduled.
[0071] The specific scheduling selection process needs to obtain all runnable processes and, based on scheduling policies, such as considering parameters in several aspects including throughput, average response time, fairness, and additional overhead caused by scheduling, select a process for the next scheduling. For example, the above-mentioned Process A is selected, and then a process switch is performed to switch back to Process A to continue running. The scheduling selection process of the kernel scheduling algorithm in this step takes a relatively long time. In addition, this step corresponds to the above-mentioned time period from T3 to T4, during which the above functions are implemented in the kernel mode.
[0072] In view of the above Figure 1 and Figure 2 interrupt handling scheme shown, the embodiments of the present disclosure provide a technical solution with faster interrupt response, which can be implemented as described in the following embodiments. Figure 3 It is a schematic flowchart of an interrupt handling method applied to a microkernel provided by an embodiment of the present disclosure. As Figure 3 shown, it includes the following steps:
[0073] Step 301: When an interrupt event occurs, obtain the process identifier of the first process that registers the interrupt event;
[0074] Specifically, in a microkernel system, an interrupt event may be caused by software, hardware, or other abnormal conditions. The above interrupt event generates an interrupt signal, which is sent to a processing device with interrupt control functions in the kernel. The processing device can find the process identifier of the first process that registers the interrupt event based on the interrupt signal. The first process is the process where the interrupt service program corresponding to the interrupt event runs.
[0075] Step 302: Obtain the process identifier of the second process that currently occupies the central processing unit;
[0076] Specifically, in this step, the occupancy information of the central processing unit can be read from the memory module. The above information can be recorded in a variable of an internal module. Different variables are used to record the process identifier or thread identifier that occupies the central processing unit. For example, the process identifier of the second process that currently occupies the central processing unit is recorded through the first variable. In this step, the process identifier of the second process that currently occupies the central processing unit can be obtained by reading the first variable in the memory module.
[0077] Step 303: When it is determined that the process identifiers of the first process and the second process are inconsistent, switch to the first process and execute the interrupt service program corresponding to the interrupt event.
[0078] Specifically, in Figure 1In the illustrated embodiment, the kernel scheduling algorithm is used to implement scheduling selection during interrupt processing, which is different from process switching based on scheduling selection. In the embodiments of the present disclosure, the kernel scheduling algorithm is not executed. Instead, based on obtaining the process identifier of the first process registering the interrupt event in step 301 and the process identifier of the second process currently occupying the central processing unit obtained in step 302, by performing a simple comparison, that is, determining whether the above two process identifiers are the same. If they are not the same, it means that process switching is required, and the process can be directly switched to the first process and the interrupt service program corresponding to the interrupt event can be executed. Through the above "two obtaining operations respectively obtain the process identifier of the first process and the process identifier of the second process", and "one comparison operation determines whether to perform process switching", compared with the prior art where the kernel scheduling algorithm is called during interrupt processing, and the kernel scheduling algorithm needs to consider parameters in several aspects such as all schedulable processes or threads, throughput, average response time, fairness, and additional overhead caused by scheduling for process scheduling selection. In the technical solution provided by the embodiments of the present disclosure, the amount of calculation and the number of operations are greatly reduced, which can save a large amount of time, achieve the technical effect of reducing the time required for interrupt response, improve the interrupt response efficiency, and improve the performance of the microkernel system.
[0079] Figure 4 For Figure 3 the time progress schematic diagram of the interrupt processing method applied to the microkernel as shown, such as Figure 4 shown, in the embodiments of the present disclosure, if the process currently occupying the central processing unit is process A, and the interrupt service program runs in process B. Then when an interrupt event occurs, the interrupt handler of the kernel first wakes up process B, and after the above simple comparison process, it can quickly enter the process switching process, switch to process B, and then execute the interrupt service program. Relative to Figure 2 the time progress schematic diagram shown, it reduces the time for executing the kernel scheduling algorithm once, thus implementing a technical solution for fast interrupt response.
[0080] In the above Figure 3 illustrated embodiment, only the process from receiving the interrupt event to executing the interrupt service program is described; in the process of switching back to the second process after executing the interrupt service program, compared with the above Figure 1 illustrated embodiment where the kernel scheduling algorithm is still called for scheduling selection, corresponding simplification processing is also performed in the embodiments of the present disclosure.
[0081] Figure 5 The flow schematic diagram of another interrupt processing method applied to the microkernel provided by the embodiments of the present disclosure is shown as Figure 5 shown. In addition to including the above steps 301 to 303, it further includes steps 304 and 305.
[0082] Among them, step 304 includes recording the process identifier of the second process currently occupying the central processing unit. The specific execution time of this step 304 can be recording immediately after obtaining the process identifier of the second process in step 302, or recording after determining that the process identifiers of the first process and the second process are inconsistent in step 303. This is not limited in the embodiments of the present disclosure.
[0083] Further, step 305 is to perform process switching according to the recorded process identifier of the second process after executing the interrupt service program corresponding to the interrupt event, so as to switch back to the second process.
[0084] Specifically, by recording the process identifier of the second process currently occupying the central processing unit in step 304 above, when process switching is required, process switching can be directly performed according to the process identifier of the second process. Compared with Figure 1 In the embodiment shown, after executing the interrupt service program, the kernel scheduling algorithm is still called, and the complex process scheduling selection is performed by this kernel scheduling algorithm. In the embodiments of the present disclosure, the kernel scheduling algorithm is no longer executed, but process switching is directly performed according to the recorded process identifier of the second process, and switched back to the second process, which can significantly shorten the defect of long interrupt response time caused by executing the kernel scheduling algorithm, save a large amount of time, improve the interrupt response efficiency, and improve the performance of the microkernel system.
[0085] Figure 6 For Figure 5 The time progress schematic diagram of the interrupt processing method applied to the microkernel shown, as Figure 6 shown, after executing the interrupt service program, and after executing the interrupt service program, according to the recorded process identifier of process A, quickly perform process switching and switch back to process A. Compared with Figure 2 The time progress schematic diagram shown, a total of two times of the time for executing the kernel scheduling algorithm is reduced, thus realizing a technical solution with fast interrupt response.
[0086] For the second case above, first, the interrupt processing solution of the microkernel in the prior art is described. Figure 7 The flowchart of an interrupt processing method for a microkernel in the prior art can be referred to understand the interrupt processing solution in the prior art as shown in Figure 7 shown. In addition, Figure 8 For Figure 7 The time progress schematic diagram of the interrupt processing method applied to the microkernel shown. As Figure 7 and Figure 8 shown, this processing method includes the following steps:
[0087] Step 601: An interrupt event occurs during the running of Thread A in Process A, and this interrupt event is registered by Thread B in Process A;
[0088] Step 602: The interrupt handler of the kernel wakes up Thread B;
[0089] Step 603: Through the kernel scheduling algorithm for scheduling selection, select the thread to be scheduled. The specific scheduling selection process needs to obtain all runnable processes and threads, and based on the scheduling policy, such as considering parameters in several aspects including throughput, average response time, fairness, and additional overhead caused by scheduling, select the next thread to be scheduled, such as the above-mentioned Thread B, and then perform a thread switch to switch to Thread B. The scheduling selection process of the kernel scheduling algorithm in this step takes a relatively long time. In addition, this step corresponds to the above-mentioned time period T1 - T2, and the above functions are implemented in the kernel mode during this time period;
[0090] Step 604: Execute the interrupt service program in Thread B, that is, corresponding to the above time period T2 - T3, and the above interrupt service program is executed in the user mode during this time period;
[0091] After the interrupt service program is executed, the kernel scheduling algorithm continues to perform scheduling selection to select the thread to be scheduled. The specific scheduling selection process needs to obtain all runnable processes and threads, and based on the scheduling policy, such as considering parameters in several aspects including throughput, average response time, fairness, and additional overhead caused by scheduling, select the next thread to be scheduled, such as Thread A in the above-mentioned Process A, and then perform a thread switch to switch back to Thread A to continue running. The scheduling selection process of the kernel scheduling algorithm in this step takes a relatively long time. In addition, this step corresponds to the above-mentioned time period T3 - T4, and the above functions are implemented in the kernel mode during this time period.
[0092] For the above Figure 7 and Figure 8 shown interrupt handling scheme, the embodiments of the present disclosure provide a technical scheme with a more rapid interrupt response, which can be implemented as described in the following embodiments. Figure 9 This is a flowchart of another interrupt handling method applied to a microkernel provided by the embodiments of the present disclosure. As Figure 9 shown, it includes the following steps:
[0093] Step 801: When an interrupt event occurs, obtain the process identifier of the first process that registers the interrupt event;
[0094] Specifically, in a microkernel system, an interrupt event may be caused by software, hardware, or other exceptional circumstances. The above interrupt event generates an interrupt signal, which is sent to a processing device with interrupt control functions in the kernel. The processing device can find the process identifier of the first process that registered the interrupt event based on the interrupt signal. The first process is the process where the interrupt service routine corresponding to the interrupt event runs.
[0095] Step 802: Obtain the process identifier of the second process currently occupying the central processing unit;
[0096] Specifically, in this step, the occupancy information of the central processing unit can be read from the memory module. The above information can be recorded in a variable of the memory module. The process identifier or thread identifier of the process occupying the central processing unit is recorded through different variables. For example, the process identifier of the second process currently occupying the central processing unit is recorded through the first variable. In this step, the process identifier of the second process currently occupying the central processing unit can be obtained by reading the first variable in the memory module.
[0097] Step 803: When it is determined that the process identifiers of the first process and the second process are the same, that is, the first process and the second process are the same process, then call the interrupt service routine and execute it.
[0098] Specifically, different from Figure 7 the embodiment shown, where the kernel scheduling algorithm is used to implement scheduling selection and thread switching during interrupt processing. In the embodiment of the present disclosure, the kernel scheduling algorithm is not executed. Instead, based on obtaining the process identifier of the first process that registered the interrupt event in step 801 and the process identifier of the second process currently occupying the central processing unit in step 802, a simple comparison is performed in this step, that is, to determine whether the above two process identifiers are the same. When they are the same, it means that the process running the interrupt service routine and the process currently occupying the central processing unit are the same, but only the specific threads are different. At this time, the steps of process switching and thread switching can be omitted, and the interrupt service routine corresponding to the interrupt event is called and executed, avoiding the time consumed by executing the kernel scheduling algorithm and thread switching. Compared with the prior art, when the kernel scheduling algorithm is called during interrupt processing, it is necessary to consider all schedulable processes or threads, and fully consider parameters such as throughput, average response time, fairness, and additional overhead caused by scheduling to perform thread scheduling selection. Its computational complexity and the number of operations are greatly reduced. In addition, thread switching is no longer performed, saving a large amount of time, achieving the technical effect of reducing the time required for interrupt response and improving the interrupt response efficiency, and effectively improving the performance of the microkernel system.
[0099] Figure 10 For Figure 9 the time progress schematic diagram of the interrupt processing method applied to the microkernel shown, asFigure 10 As shown, in the embodiments of the present disclosure, if the thread currently occupying the central processing unit is thread A in process A, and the interrupt service program runs as thread B in process A. Then, when an interrupt event occurs, the interrupt handler of the microkernel wakes up thread B in process A, and after comparison in step 803 above, it is confirmed that the process currently occupying the central processing unit is the same as the process registering the interrupt service program, then the interrupt server program can be quickly called, and by comparing with Figure 8 As can be seen from the progress schematic diagram shown, in Figure 10 the technical solution shown, the time for one execution of the kernel scheduling algorithm and thread switching can be omitted, significantly saving the time-consuming in the interrupt handling process, thus implementing a technical solution for fast interrupt response.
[0100] In the above Figure 9 shown embodiments, only the process from receiving the interrupt event to executing the interrupt service program is described. In the process of switching back to the original thread after executing the interrupt service program, compared with the above Figure 8 shown embodiments where the kernel scheduling algorithm is still called for scheduling selection and thread switching, corresponding optimization processing has also been carried out in the embodiments of the present disclosure.
[0101] Figure 11 FIG. is a schematic flow diagram of another interrupt handling method applied to a microkernel provided by the embodiments of the present disclosure. As Figure 11 shown, in addition to including the above steps 801 to 803, it further includes steps 804, 805, and 806.
[0102] Specifically, it has been determined that the process identifier of the first process is the same as that of the second process, and the two are the same process. Then, the one registering the interrupt event can be a thread of the same process, such as the first thread.
[0103] At this time, the embodiments of the present disclosure may further include step 804. In this step 804, the thread mark of the second thread of the same process currently occupying the central processing unit can be obtained. This second thread is different from the above first thread. The execution time of this step 804 can be the synchronous execution when obtaining the process identifier of the second process in step 802, or after comparing the process identifiers of the first process and the second process and determining them to be the same in step 803, then obtaining the thread identifier of the above second thread. Based on obtaining the thread identifier of the second thread, further, the thread mark of the second thread can be recorded in step 805, so that when thread switching is required, it can directly switch back to the second thread according to the thread identifier of the second thread, that is, in step 806, after executing the interrupt service program, it directly switches back to the second thread according to the recorded thread identifier of the second thread.
[0104] Specifically, in the above step 804, obtaining the thread identifier of the second thread of the same process that currently occupies the central processing unit may specifically be to read from the memory module a second variable that records the occupancy information of the central processing unit, so as to obtain the thread identifier of the second thread of the same process that currently occupies the central processing unit.
[0105] Compared with the Figure 7 shown embodiment, after the interrupt service program is executed, the kernel scheduling algorithm is still called, and the kernel scheduling algorithm performs complex scheduling selections to select the corresponding thread and perform thread switching. In the embodiment of the present disclosure, the kernel scheduling algorithm and the thread switching process are no longer executed, but directly switch back to the second thread according to the recorded thread identifier of the second thread, which can significantly shorten the defect of long interrupt response time caused by executing the kernel scheduling algorithm and the thread switching steps, save a large amount of time, improve the technical effect of interrupt response efficiency, and improve the performance of the microkernel system.
[0106] Figure 12 For Figure 11 the time progress schematic diagram of the interrupt processing method applied to the microkernel shown, as Figure 12 shown, in the embodiment of the present disclosure, after quickly calling the interrupt server program and executing the above interrupt service program, directly switch back to thread A according to the recorded thread identifier of thread A. By comparing with the Figure 8 shown progress schematic diagram, it can be found that in the Figure 12 shown technical solution, the time for executing the kernel scheduling algorithm and thread switching twice is omitted in total, and it is not necessary to perform multiple switches between the user mode and the kernel mode during the interrupt processing process, which can significantly save the time consumed during the interrupt processing process, thereby implementing a technical solution for fast interrupt response.
[0107] The embodiment of the present disclosure further provides an interrupt processing device applied to a microkernel. Figure 13 For the structural schematic diagram of an interrupt processing device applied to a microkernel provided by the embodiment of the present disclosure, as Figure 13 shown, the device includes a first identifier obtaining module 11, a second identifier obtaining module 12, a comparison module 13, and a first program execution module 14.
[0108] Specifically, the above-mentioned interrupt handling device can be applied to a microkernel, and can solve the defect that when the existing microkernel performs interrupt handling, it needs to execute operations such as switching between the user mode and the kernel mode, executing the kernel scheduling algorithm, and executing the process switching step or the thread switching step, which takes a long processing time and results in a long interrupt response time. The above-mentioned interrupt handling device can, in view of the above-mentioned defect, reduce the time required for interrupt response and improve the interrupt response efficiency from at least one aspect of avoiding or minimizing unnecessary switching between the user mode and the kernel mode, the kernel scheduling algorithm, process switching, or thread switching.
[0109] To achieve the above effects, in the embodiments of the present disclosure, the first identifier acquisition module 11 is used to acquire the process identifier of the first process that registers the interrupt event when an interrupt event occurs. Specifically, in a microkernel system, an interrupt event may be caused by software, hardware, or other abnormal conditions. The above-mentioned interrupt event generates an interrupt signal, which is sent to the interrupt handling device with interrupt control function in the kernel, specifically, it may be the first identifier acquisition module 11. The first identifier acquisition module 11 searches for the process identifier of the first process that registers the interrupt event based on the interrupt signal. The first process is the process where the interrupt service program corresponding to the interrupt event runs.
[0110] The second identifier acquisition module 12 is used to acquire the process identifier of the second process that currently occupies the central processing unit. Specifically, the second identifier acquisition module 12 may read the occupancy information of the central processing unit from the memory module. The above information may be recorded in a variable of an internal module. The process identifier or thread identifier of the process occupying the central processing unit is recorded through different variables. For example, the process identifier of the second process that currently occupies the central processing unit is recorded through the first variable, then this module may acquire the process identifier of the second process that currently occupies the central processing unit by reading the first variable in the memory module.
[0111] The comparison module 13 is used to determine whether the process identifier of the first process is the same as the process identifier of the second process. According to whether the comparison result is the same or different, it can correspond to two different situations during interrupt handling. The first situation is that the process where the interrupt service program is located is different from the process that currently occupies the central processing unit. The second situation is that the process where the interrupt service program is located is the same as the process that currently occupies the central processing unit, but the specific threads are different. For the above two situations, the technical solutions provided in the embodiments of the present disclosure are optimized, and the technical effects of reducing the time required for interrupt response and improving the interrupt response efficiency are achieved, thereby improving the performance of the microkernel system.
[0112] Specifically, for the above two situations, the manner in which the first program execution module 14 executes the interrupt service program will be different, which will be introduced and described separately below:
[0113] For the first case, that is, when it is determined that the process identifiers of the first process and the second process are inconsistent, process switching is performed to switch to the first process, and then the interrupt service program corresponding to the interrupt event is executed, which is different from the prior art.
[0114] The technical solution in the prior art for dealing with the first case can be referred to Figure 1 and Figure 2 As shown, in the technical solutions shown in Figure 1 and Figure 2 After receiving an interrupt event, it is necessary to execute the kernel scheduling algorithm for scheduling selection to select the process to be scheduled. The specific scheduling selection process needs to obtain all runnable processes and threads, and based on scheduling policies, such as considering parameters in several aspects such as throughput, average response time, fairness, and additional overhead caused by scheduling, to perform process scheduling selection and select the next process to be scheduled. The scheduling selection process of the kernel scheduling algorithm in the above prior art is complex and time-consuming, which is the main factor affecting the interrupt response speed.
[0115] The technical solution of the embodiment of the present disclosure, when dealing with the above first case, after the comparison by the above comparison module 13, when the process identifiers of the first process and the second process are inconsistent, process switching can be directly performed to switch to the second process and execute the interrupt service program, without the need to execute the kernel scheduling algorithm, greatly reducing its computational amount and the number of operations, saving a large amount of time, achieving the technical effect of reducing the time required for interrupt response, improving the interrupt response efficiency, and improving the performance of the microkernel system.
[0116] The schematic diagram of the time progress during specific interrupt processing can be as shown in Figure 4 As shown, compared with the schematic diagram of the time progress shown in Figure 2 it reduces the time for executing the kernel scheduling algorithm once, thus implementing a technical solution for fast interrupt response.
[0117] As shown in Figure 14 In the first case, the interrupt processing device may further include a first recording module 15 and a process switching module 16. The first recording module 15 is used to record the process identifier of the second process currently occupying the central processing unit; the process switching module 16 is used to perform process switching according to the recorded process identifier of the second process after executing the interrupt service program corresponding to the interrupt event to switch back to the second process.
[0118] Specifically, the first recording module 15 is configured to record the process identifier of the second process that currently occupies the central processing unit. The first recording module 15 may record the process identifier of the second process immediately after the second obtaining module 12 obtains the process identifier of the second process, or may record it after the comparison module 13 determines that the process identifier of the first process is inconsistent with the process identifier of the second process. There is no limitation in the embodiments of the present disclosure.
[0119] Further, the process switching module 16 is configured to perform process switching according to the recorded process identifier of the second process after executing the interrupt service program corresponding to the interrupt event, so as to switch back to the second process.
[0120] Specifically, by recording the process identifier of the second process that currently occupies the central processing unit in the first recording module 15, when process switching is required, the process can be directly switched according to the process identifier of the second process. Compared with the embodiments shown in Figure 1 and Figure 2 In the embodiments shown, after the interrupt service program is executed, the kernel scheduling algorithm is still called, and the kernel scheduling algorithm performs complex process scheduling selection. In the embodiments of the present disclosure, the kernel scheduling algorithm is no longer executed, but the process is directly switched back to the second process according to the recorded process identifier of the second process, reducing the time of executing the kernel scheduling algorithm twice in total, significantly shortening the defect of long interrupt response time caused by executing the kernel scheduling algorithm, saving a large amount of time, improving the technical effect of interrupt response efficiency, and improving the performance of the microkernel system.
[0121] For the first situation above, the time progress diagram of the interrupt processing method executed by the interrupt processing device can be as shown in Figure 6 According to the comparison with the time progress diagram in the prior art shown in Figure 2 It can be seen that it reduces the time of executing the kernel scheduling algorithm twice, realizing a technical solution for fast interrupt response.
[0122] For the second situation, when it is determined that the process identifier of the first process is the same as the process identifier of the second process, the first process and the second process are the same process, and the interrupt service program is directly called and executed, which is different from the prior art.
[0123] The technical solution in the prior art for dealing with the second situation can be referred to Figure 7 and Figure 8 As shown, in the technical solutions shown in Figure 7 and Figure 8 In the technical solutions shown,
[0124] Through the kernel scheduling algorithm for scheduling selection, the thread to be scheduled is selected. The specific scheduling selection process needs to obtain all runnable processes and threads, and based on scheduling policies, such as considering parameters in several aspects including throughput, average response time, fairness, additional overhead caused by scheduling, etc., to perform thread scheduling selection, and select the thread to be scheduled next, such as thread B above. Then, thread switching is performed to switch to thread B, and then the interrupt service program is called. In the technical solution provided in the embodiments of the present disclosure, when the above comparison module obtains that the two process identifiers are the same, it means that the process running the interrupt service program and the process currently occupying the central processing unit are the same, but only the specific threads are different. At this time, the steps of process switching and thread switching are not performed, and the interrupt service program corresponding to the interrupt event is directly called and executed. Specifically, reference can be made to Figure 10 The time progress schematic diagram of the interrupt handling method shown, which can omit the time consumed by executing the kernel scheduling algorithm and thread switching once. Compared with the prior art when calling the kernel scheduling algorithm during interrupt handling, all schedulable processes or threads need to be considered, and scheduling selection is performed based on references such as priorities. Its computational complexity and the number of operations are greatly reduced. In addition, thread switching is no longer performed, saving a large amount of time, achieving the technical effect of reducing the time required for interrupt response and improving the interrupt response efficiency, and can effectively improve the performance of the microkernel.
[0125] As Figure 15 Shown, for the interrupt handling device in the second case, it may further include a third identifier acquisition module 17, a second recording module 18, and a thread switching module 19. The third identifier acquisition module 17 is used to acquire the thread mark of the second thread of the same process currently occupying the central processing unit; the second recording module 18 is used to record the thread identifier of the second thread; the thread switching module 19 is used to directly switch back to the second thread according to the recorded thread identifier of the second thread after the interrupt service program is executed.
[0126] Specifically, if the comparison module 13 has determined that the process identifier of the first process and the process identifier of the second process are the same, and the two are the same process, then the one registering the interrupt event can be a thread of the same process, such as the first thread.
[0127] At this time, the above-mentioned third identifier obtaining module 17 is used to obtain the thread identifier of the second thread of the same process that currently occupies the central processing unit. The second thread is different from the above-mentioned first thread. The third identifier obtaining module 17 can be executed synchronously when the second identifier obtaining module 12 obtains the process identifier of the second process, or after the comparison module 13 has compared the process identifiers of the first process and the second process and found them to be the same, then obtain the thread identifier of the above-mentioned second thread. On the basis of obtaining the thread identifier of the second thread, the second recording module 18 can further record the thread identifier of the second thread, so that when thread switching is required, it can directly switch back to the second thread according to the thread identifier of the second thread, that is, the thread switching module 19 is used to directly switch back to the second thread according to the recorded thread identifier of the second thread after the interrupt service program is executed.
[0128] Specifically, the above-mentioned third identifier obtaining module 17 can specifically be used to read from the memory module the second variable that records the occupancy information of the central processing unit, so as to obtain the thread identifier of the second thread of the same process that currently occupies the central processing unit.
[0129] Compared with the Figure 8 shown in the embodiment, after the interrupt service program is executed, the kernel scheduling algorithm is still called, and the kernel scheduling algorithm performs complex scheduling selections to select the corresponding thread and perform thread switching. The interrupt processing device of the present disclosure embodiment no longer executes the kernel scheduling algorithm and the thread switching process, but directly switches back to the second thread according to the recorded thread identifier of the second thread, which can significantly shorten the defect of long interrupt response time caused by executing the kernel scheduling algorithm and the thread switching steps, save a large amount of time, improve the technical effect of interrupt response efficiency, and improve the performance of the microkernel system.
[0130] For the above second case, the time progress diagram of the interrupt processing method executed by the interrupt processing device can be as Figure 12 shown. According to the comparison with the Figure 8 time progress diagram in the prior art shown, it can be seen that not only the time for executing the kernel scheduling algorithm and thread switching twice is omitted, but also there is no need to perform multiple switches between the user mode and the kernel mode during the interrupt processing process, which can significantly save the time consumed during the interrupt processing process, thereby realizing a technical solution for fast interrupt response.
[0131] The present disclosure embodiment also provides a microkernel operating system. Figure 16 For the structure diagram of the microkernel operating system provided by the present disclosure embodiment, as Figure 16As shown, the microkernel operating system includes the interrupt processing device 21 in any of the above embodiments. Specifically, in the microkernel operating system, there may generally also be a memory management device 22 for implementing memory management, a thread management device 23 for implementing thread management, a process management device 24 for implementing process management, and a communication device 25 for implementing inter-process communication. The interrupt processing device 21 provided in the embodiments of the present disclosure can cooperate with one or more of the above devices to implement the interrupt processing method provided in any of the above embodiments. The microkernel operating system provided in the embodiments of the present disclosure can reduce the time required for interrupt response and improve the interrupt response efficiency by avoiding or minimizing at least one of unnecessary switching between the user mode and the kernel mode, the kernel scheduling algorithm, process switching, or thread switching during interrupt processing.
[0132] Figure 17 It is a schematic structural diagram of an electronic device provided by an embodiment of the present disclosure. Specifically, the following shows a schematic structural diagram of an electronic device 500 suitable for implementing the present disclosure. The electronic device 500 in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Tablet Computers), PMPs (Portable Multimedia Players), vehicle terminals (such as vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. The shown electronic device is only an example and should not impose any limitation on the functions and scope of use of the embodiments of the present disclosure.
[0133] As shown in the figure, the electronic device 500 may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 502 or the program loaded from the storage device 508 into the random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other through a bus 504. The input / output (I / O) interface 505 is also connected to the bus 504.
[0134] Typically, the following devices can be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 can allow the electronic device 500 to communicate with other devices wirelessly or wiredly to exchange data. Although the electronic device 500 with various devices is shown, it should be understood that it is not required to implement or have all the shown devices. Instead, more or fewer devices can be implemented or had.
[0135] Specifically, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program codes for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication device 509, or installed from the storage device 508, or installed from the ROM 502. When the computer program is executed by the processing device 501, the above functions defined in the video playback method of the embodiment of the present disclosure are executed.
[0136] It should be noted that the computer-readable medium described above in this disclosure can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of a computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this disclosure, a computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in conjunction with an instruction execution system, apparatus, or device. And in this disclosure, a computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, and this computer-readable signal medium can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on a computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0137] In some embodiments, the client and the server can communicate using any currently known or future-developed network protocol such as HTTP (HyperText Transfer Protocol), and can be interconnected with digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include local area networks ("LANs"), wide area networks ("WANs"), the Internet (e.g., the Internet), and end-to-end networks (e.g., ad hoc end-to-end networks), as well as any currently known or future-developed networks.
[0138] The above computer-readable medium can be included in the above electronic device; or it can exist separately without being assembled into the electronic device.
[0139] The above computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to: when an interrupt event occurs, obtain the process identifier of the first process that registered the interrupt event; obtain the process identifier of the second process that currently occupies the central processing unit; when it is determined that the process identifier of the first process is inconsistent with the process identifier of the second process, switch to the first process and execute the interrupt service program corresponding to the interrupt event; or, when it is determined that the process identifier of the first process is consistent with the process identifier of the second process, and the first process and the second process are the same process, directly call the interrupt service program and execute it.
[0140] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or combinations thereof. The programming languages include, but are not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may execute entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0141] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code that contains one or more executable instructions for implementing the specified logical function. It should also be noted that, in some alternative implementations, the functions marked in the blocks may occur in a different order than marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, may be implemented by a dedicated hardware-based system for performing the specified functions or operations, or may be implemented by a combination of dedicated hardware and computer instructions.
[0142] The units described in the embodiments of the present disclosure may be implemented in software or in hardware. In some cases, the name of the unit does not constitute a limitation on the unit itself.
[0143] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that can be used include: Field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), Systems on Chip (SOCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0144] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media would include electrical connections based on one or more wires, portable computer disks, hard disks, Random Access Memory (RAM), Read Only Memory (ROM), Erasable Programmable Read Only Memory (EPROM or flash memory), optical fibers, portable compact disk read only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0145] According to one or more embodiments of the present disclosure, the present disclosure provides an electronic device, including:
[0146] A processor;
[0147] A memory for storing executable instructions of the processor;
[0148] The processor is configured to read the executable instructions from the memory and execute the instructions to implement any one of the interrupt processing methods provided by the present disclosure.
[0149] According to one or more embodiments of the present disclosure, the present disclosure provides a computer-readable storage medium storing a computer program for executing any one of the interrupt processing methods provided by the present disclosure.
[0150] The above description is only a preferred embodiment of the present disclosure and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosure concept. For example, technical solutions formed by mutually replacing the above features with (but not limited to) technical features having similar functions disclosed in the present disclosure.
[0151] In addition, although the operations are depicted in a particular order, this should not be construed as requiring that the operations be performed in the particular order shown or in sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, although several specific implementation details are included in the foregoing description, these should not be construed as limitations on the scope of the present disclosure. Certain features that are described in the context of separate embodiments may also be implemented in combination in a single embodiment. Conversely, the various features that are described in the context of a single embodiment may also be implemented separately or in any suitable sub-combination in multiple embodiments.
[0152] Although the subject matter has been described in language specific to structural features and / or methodological acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.
Claims
1. An interrupt handling method applied to a microkernel, characterized in that, it includes: When an interrupt event occurs, obtain the process identifier of the first process that registered the interrupt event; Obtain the process identifier of the second process that currently occupies the central processing unit; When it is determined that the process identifier of the first process and the process identifier of the second process are inconsistent, switch the second process to the first process and execute the interrupt service program corresponding to the interrupt event; or, when it is determined that the process identifier of the first process and the process identifier of the second process are consistent, the first process and the second process are the same process, then call the interrupt service program and execute it; Wherein, when it is determined that the process identifier of the first process and the process identifier of the second process are consistent, the first process and the second process are the same process, and the first thread of the same process registers the interrupt event, the method further includes: Obtain the thread identifier of the second thread of the same process that currently occupies the central processing unit; Record the thread identifier of the second thread; After executing the interrupt service program, directly switch back to the second thread according to the recorded thread identifier of the second thread.
2. The method according to claim 1, characterized in that, when it is determined that the process identifier of the first process and the process identifier of the second process are inconsistent, the method further includes: Record the process identifier of the second process that currently occupies the central processing unit; After executing the interrupt service program corresponding to the interrupt event, perform process switching according to the recorded process identifier of the second process to switch back to the second process.
3. The method according to claim 2, characterized in that, the obtaining the process identifier of the second process that currently occupies the central processing unit includes: Read a first variable that records the occupancy information of the central processing unit from the memory module to obtain the process identifier of the second process that currently occupies the central processing unit.
4. The method according to claim 1, characterized in that, the obtaining the thread mark of the second thread of the same process that currently occupies the central processing unit includes: Read a second variable that records the occupancy information of the central processing unit from the memory module to obtain the thread mark of the second thread of the same process that currently occupies the central processing unit.
5. An interrupt handling device applied to a microkernel, characterized in that, it includes: A first identifier obtaining module, configured to obtain the process identifier of the first process that registered the interrupt event when an interrupt event occurs; A second identifier obtaining module, configured to obtain the process identifier of the second process that currently occupies the central processing unit; A comparison module, configured to determine whether the process identifier of the first process and the process identifier of the second process are consistent; The first program execution module is configured to, when determining that the process identifier of the first process is inconsistent with the process identifier of the second process, switch the second process to the first process and execute the interrupt service program corresponding to the interrupt event; or, when determining that the process identifier of the first process is consistent with the process identifier of the second process, the first process and the second process are the same process, then call the interrupt service program and execute it; Wherein, when determining that the process identifier of the first process is consistent with the process identifier of the second process, the first process and the second process are the same process, and the first thread of the same process registers the interrupt event. The apparatus further includes: A third identifier acquisition module, configured to acquire the thread identifier of the second thread of the same process that currently occupies the central processing unit; A second recording module, configured to record the thread identifier of the second thread; A thread switching module, configured to directly switch back to the second thread according to the recorded thread identifier of the second thread after executing the interrupt service program.
6. The apparatus according to claim 5, wherein, when determining that the process identifier of the first process is inconsistent with the process identifier of the second process, the apparatus further includes: A first recording module, configured to record the process identifier of the second process that currently occupies the central processing unit; A process switching module, configured to perform process switching according to the recorded process identifier of the second process after executing the interrupt service program corresponding to the interrupt event, so as to switch back to the second process.
7. The apparatus according to claim 6, wherein, the second identifier acquisition module is specifically configured to read a first variable that records the occupancy information of the central processing unit from the memory module, so as to acquire the process identifier of the second process that currently occupies the central processing unit.
8. The apparatus according to claim 7, wherein, the third identifier acquisition module is specifically configured to read a second variable that records the occupancy information of the central processing unit from the memory module, so as to acquire the thread identifier of the second thread of the same process that currently occupies the central processing unit.
9. A microkernel operating system, wherein, it includes the interrupt processing apparatus according to any one of claims 5-8.
10. An electronic device, wherein, the electronic device includes: a processor; a memory for storing executable instructions of the processor; the processor is configured to read the executable instructions from the memory and execute the instructions to implement the interrupt processing method of the microkernel according to any one of claims 1-4 above.
11. A computer-readable storage medium, wherein, the storage medium stores a computer program, and the computer program is used to execute the interrupt processing method of the microkernel according to any one of claims 1-4 above.
Citation Information
Patent Citations
Process interruption processing method and device
CN103440169A
Interrupt response method, apparatus and base station
CN107003899A