Signal processing method for process in embedded real-time operating system
By recording and initializing the signal processing function in the user state in an embedded real-time operating system, the problems of high CPU and memory consumption and coupled with the kernel state during the process signal processing are solved, and more efficient signal processing is achieved and security isolation.
Patent Information
- Application Number
- CN202411208141.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-12-24
- Estimated Expiration
- 2044-08-30
AI Technical Summary
In embedded real-time operating systems, there are problems such as high CPU resource and memory consumption during process signal processing, as well as high coupling between signal processing functions and kernel states.
By recording the signal processing function in the user state and initializing the user system call library before starting, the user state pending signal set global variable address is passed to the process control block structure, and the kernel state pending signal set global variable address is obtained. The trigger signal exists and is recorded in the kernel-state pending signal set for kernel processing. After the processing is completed, the pending signal set is recorded in the user-state pending signal set, reducing process state switching and memory consumption, and reducing the kernel-state signal processing function. Perception.
It reduces the CPU and memory consumption of the process during signal processing, improves the security and isolation of the process, and reduces the coupling between signal processing functions and kernel state.
Smart Images

Figure CN119179522A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of embedded real-time operating systems, and in particular to a signal processing method for a process in an embedded real-time operating system. Background Art
[0002] A process is an independent unit for resource allocation and scheduling in an embedded real-time operating system. It is an independent entity for resource allocation and scheduling in the system and a carrier for application program operation. Each process has its own independent address space, including code segment, data segment, stack, etc., as well as system resources required for runtime (such as file descriptors, signal processors, etc.).
[0003] After the user specifies the signal processing function, if the signal processing function is in kernel state, the program will have too high control authority, which may easily lead to damage to system resources and hardware devices. Therefore, when executing the signal processing function, the process needs to return from kernel state to user space (user state).
[0004] At present, in the prior art, the process signal processing process is as follows: in the first step, the process enters the kernel state for the first time through the interface provided by the kernel, and saves the user's field data to the kernel state thread stack; in the second step, the kernel copies the data of the current kernel state thread stack to the user stack, and modifies the instruction register address to point to the signal processing function, so that the process executes the signal processing function for the selected pending signal when returning to the user state; in the third step, after the signal processing function is executed, the process enters the kernel state for the second time to check whether there are other pending signals that have not been processed; in the fourth step, if all signals have been processed, the kernel stack and the instruction register are restored to point to the running position before the interruption, so that the process returns to the user state to continue execution.
[0005] Based on the process signal processing process in the above-mentioned prior art, there are the following technical defects: First, since the process signal processing process involves at least two returns to the user state and entering the kernel state, its frequent state switching will consume a lot of CPU resources. Second, since the user field data needs to be protected by frequent stack push and pop in the process signal processing, a lot of memory is consumed. Third, since the kernel state needs to perceive the signal processing function, the coupling between the signal processing function and the kernel state is high. Summary of the invention
[0006] 1. Technical issues to be resolved
[0007] In view of the above-mentioned shortcomings and deficiencies of the prior art, the present invention provides a signal processing method for a process in an embedded real-time operating system, which solves the technical problems of high CPU resource and memory consumption and high coupling between signal processing functions and kernel state when the process executes signal processing.
[0008] (II) Technical solution
[0009] In order to achieve the above object, the main technical solutions adopted by the present invention include:
[0010] In a first aspect, an embodiment of the present invention provides a signal processing method for a process in an embedded real-time operating system, comprising:
[0011] The user-state signal processing function is recorded in the user system call library of the embedded real-time operating system, and before starting, the user system call library is initialized, the user-state pending signal set global variable address is passed to the process control block structure, and the kernel-state pending signal set global variable address is obtained;
[0012] If there is a trigger signal for the process, the trigger signal will be recorded in the kernel state pending signal set global variable address. When the user system call library calls the process and it falls into the kernel state, the user field data will be saved in the kernel state thread stack, and the trigger signal will be kernel processed in the kernel state. The obtained pending signal set will be recorded in the user state pending signal set global variable address; and, the user field data in the kernel state thread stack will be restored to return the process to the user state, and signal processing will be performed on the pending signal set in sequence according to the signal processing function.
[0013] Optionally, the signal processing method of a process in an embedded real-time operating system further includes:
[0014] After the pending signal set is processed, the control process returns to the instruction address to continue execution according to the instruction address obtained by restoring the user field data in the kernel state thread stack.
[0015] Optionally, the user-state signal processing function is recorded in a user system call library of the embedded real-time operating system, and before startup, the user system call library is initialized, and the user-state pending signal set global variable address is passed to the process control block structure. Obtaining the kernel-state pending signal set global variable address includes:
[0016] Based on the signal category information of the process in the embedded real-time operating system, a signal processing function of the process is registered, and the signal processing function is recorded in a user system call library;
[0017] Before the main function of the process user is started in the embedded real-time operating system, the user system call library is initialized, the user state pending signal set global variable address is passed to the process control block structure, and the kernel state pending signal set global variable address is obtained.
[0018] Optionally, if there is a trigger signal of the process, recording the trigger signal in the kernel state pending signal set global variable address includes:
[0019] Obtaining an external signal received by the embedded real-time operating system, and determining whether there is a trigger signal of a process in the external signal;
[0020] If there is a trigger signal of the process in the external signal, the trigger signal is recorded in the kernel state pending signal set global variable address;
[0021] If there is no trigger signal of the process in the external signal, the execution state of the process is maintained, and the user field data containing the instruction address stored in the physical register of the embedded real-time operating system is updated in real time.
[0022] Optionally, when the user system call library calling process falls into the kernel state, the user field data is saved in the kernel state thread stack, and the trigger signal is kernel processed in the kernel state, and the obtained pending signal set is recorded in the user state pending signal set global variable address, including:
[0023] When the user system call library calls the process into kernel state, the user's on-site data is saved in the kernel state thread stack;
[0024] Based on the signal shielding set of the process, shield the sub-signals in the trigger signal corresponding to the signal shielding set to obtain an initial pending signal set;
[0025] When the process falls into the kernel state, the initial pending signal set is processed by the kernel, and the pending signal set obtained is recorded in the user state pending signal set global variable address.
[0026] Optionally, when the process falls into the kernel state, after the kernel processes the initial pending signal set and records the obtained pending signal set in the user state pending signal set global variable address, the method further includes:
[0027] Determine whether there is an initial pending signal set in the kernel state pending signal set global variable address;
[0028] If there is an initial pending signal set in the kernel state pending signal set global variable address, the instruction address of the user field data in the kernel state thread stack is modified to the entry address of the preset signal dispatch function, and the return address of the signal dispatch function is set to the instruction address of the moment before the process falls into the kernel state;
[0029] If the initial pending signal set does not exist in the kernel state pending signal set global variable address, the return address of the process is kept as the instruction address when the process falls into the kernel state.
[0030] Optionally, restoring the user field data in the kernel state thread stack to return the process to the user state, and sequentially performing signal processing on the pending signal set according to the signal processing function includes:
[0031] Restore the user field data in the kernel state thread stack to the physical register to return the process to the user state;
[0032] According to the signal distribution function, the corresponding signal processing function is assigned to process the pending signals in the pending signal set in turn to obtain a process after the signal processing.
[0033] In a second aspect, an embodiment of the present invention provides a signal processing system for a process in an embedded real-time operating system, comprising:
[0034] The initialization module of the embedded real-time operating system is used to record the user-state signal processing function in the user system call library of the embedded real-time operating system, and before starting, perform the user system call library initialization, pass the user-state pending signal set global variable address to the process control block structure, and obtain the kernel-state pending signal set global variable address;
[0035] A signal processing module is used to record the trigger signal in the kernel state pending signal set global variable address if there is a trigger signal of the process, save the user field data in the kernel state thread stack when the user system call library calls the process into the kernel state, perform kernel processing on the trigger signal in the kernel state, and record the obtained pending signal set in the user state pending signal set global variable address; and restore according to the user field data in the kernel state thread stack to return the process to the user state, and perform signal processing on the pending signal set in sequence according to the signal processing function.
[0036] In a third aspect, an embodiment of the present invention provides an electronic device, comprising:
[0037] at least one database; and
[0038] a memory in communication with the at least one database;
[0039] The memory stores instructions that can be executed by the at least one database, and the instructions are executed by the at least one database so that the at least one database can execute the signal processing method steps of the process in the embedded real-time operating system described above.
[0040] In a fourth aspect, an embodiment of the present invention provides a computer-readable medium having computer executable instructions stored thereon, and when the executable instructions are executed by a processor, the steps of the signal processing method for a process in an embedded real-time operating system described above are implemented.
[0041] (III) Beneficial effects
[0042] The beneficial effect of the present invention is as follows: the signal processing method of a process in an embedded real-time operating system of the present invention adopts a technical solution of transferring the global variable address of the pending signal set in the user state to set the global variable address of the pending signal set in the kernel state for recording the trigger signal, and transferring the pending signal set obtained after the trigger signal is processed by the kernel to the global variable address of the pending signal set in the user state for recording. Compared with the prior art, it records the pending signal set in the user state, so that after processing the pending signal set of the process in the user state, there is no need to enter the kernel state again to access other pending signals, which reduces the number of process state switching, reduces the number of stack pushes and pops, and thus reduces the consumption of CPU resources and memory by the process in the signal processing process.
[0043] Secondly, the signal processing function is recorded in the user state, which isolates different processes and prevents them from accessing each other, thus improving the security and isolation of process execution.
[0044] In addition, the user state executes the signal processing function registered by the user according to the pending signal set obtained after kernel processing, so that the kernel state does not need to perceive the signal processing function, thereby reducing the coupling between the signal processing function and the kernel state. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 A schematic flow chart of a signal processing method for a process in an embedded real-time operating system provided by an embodiment of the present invention;
[0046] Figure 2 A schematic diagram of an application scenario of a signal processing method for a process in an embedded real-time operating system provided by an embodiment of the present invention;
[0047] Figure 3 A schematic diagram of an application scenario of transmission of a pending signal set provided by an embodiment of the present invention;
[0048] Figure 4 A schematic diagram of an application scenario of a registration signal processing function provided by an embodiment of the present invention;
[0049] Figure 5 A schematic diagram of an application scenario of sending a trigger signal to a target process provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0050] In order to better explain the present invention and facilitate understanding, the present invention is described in detail below through specific implementation modes in conjunction with the accompanying drawings.
[0051] Prior to this, in order to facilitate understanding of the technical solution provided by the present invention, some basic information related to the technical solution of the present application is first introduced below, and the solution of the present application can be subsequently adjusted and controlled based on the basic information.
[0052] Embedded real-time operating system: When external events or data are generated, it can accept and process them at a fast enough speed. The processing results can control the production process or respond quickly to the processing system within the specified events, and control all real-time tasks to run in a coordinated manner. It is used to control, monitor or assist in the operation of machines and equipment.
[0053] Signal processing: Signal processing refers to the process of receiving and processing signals sent from the system or other processes in an embedded real-time system. Signal is an asynchronous notification mechanism used to notify the process of an event or condition, and the process can take corresponding actions based on the received signal.
[0054] Kernel state: It is an execution state in a computer system, also commonly referred to as operating system state. In kernel state, the CPU has the highest execution privileges and can directly access the computer's hardware resources, such as memory, CPU registers, input and output devices, etc. At this time, the embedded real-time operating system can execute its privileged instructions to implement key system functions, such as process management, memory management, file system management, etc. Programs running in kernel state can perform more advanced functions.
[0055] User state: the execution state when running in a user program. In user state, the CPU's execution privileges are relatively low and are restricted by the embedded real-time operating system. It can only access limited hardware resources and interfaces provided by the operating system. In user state, programs cannot directly access hardware resources and can only execute non-privileged instructions. Their capabilities and privileges are strictly limited.
[0056] Kernel stack: The kernel stack is the stack used by the embedded real-time operating system kernel in kernel state. The kernel stack is also commonly called the kernel state thread stack. It is allocated and managed by the embedded real-time operating system. The kernel stack is used to store important information during the execution of the operating system kernel, such as interrupt handling, exception handling, system calls, etc.
[0057] refer to Figure 1-5 As shown, an embodiment of the present invention proposes a signal processing method for a process in an embedded real-time operating system. The execution subject of the method in this embodiment can be a control device that controls the embedded real-time operating system process to perform signal processing. The control device is connected to the user system call library and the process control block structure in the embedded real-time operating system. The signal processing method includes:
[0058] S100, recording the user-state signal processing function in the user system call library of the embedded real-time operating system, and before starting, executing the user system call library initialization, passing the user-state pending signal set global variable address to the process control block structure, and obtaining the kernel-state pending signal set global variable address.
[0059] S200. If there is a trigger signal of the process, the trigger signal is recorded in the kernel state pending signal set global variable address. When the user system call library calls the process and it falls into the kernel state, the user field data is saved in the kernel state thread stack, and the trigger signal is kernel processed in the kernel state, and the obtained pending signal set is recorded in the user state pending signal set global variable address; and, the user field data in the kernel state thread stack is restored to return the process to the user state, and signal processing is performed on the pending signal set in sequence according to the signal processing function.
[0060] In this embodiment, the address of the global variable address of the pending signal set in the user state is transferred, the global variable address of the pending signal set in the kernel state is set in the kernel state for recording the trigger signal, and the pending signal set obtained after the trigger signal is processed by the kernel is transferred to the global variable address of the pending signal set in the user state for recording. Compared with the prior art, it records the pending signal set in the user state, so that after processing the pending signal set of the process in the user state, there is no need to enter the kernel state again to access other pending signals, which reduces the number of process state switching, reduces the number of stack pushes and pops, and further reduces the consumption of CPU resources and memory by the process during signal processing.
[0061] Secondly, in this embodiment, the signal processing function is recorded in the user state, and different processes are isolated so that the processes cannot access each other, thereby improving the security and isolation of the process execution.
[0062] Furthermore, in this embodiment, the user state executes the user-registered signal processing function according to the pending signal set obtained after kernel processing, so that the kernel state does not need to perceive the signal processing function, thereby reducing the coupling between the signal processing function and the kernel state.
[0063] In order to better understand the above technical solution, exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided to enable a clearer and more thorough understanding of the present invention and to fully convey the scope of the present invention to those skilled in the art.
[0064] Specifically, refer to Figure 1 As shown, an embodiment of the present invention provides a signal processing method for a process in an embedded real-time operating system, which includes:
[0065] S100, recording the user-state signal processing function in the user system call library of the embedded real-time operating system, and before starting, executing the user system call library initialization, passing the user-state pending signal set global variable address to the process control block structure, and obtaining the kernel-state pending signal set global variable address.
[0066] For example, step S100 of this embodiment may include the following sub-steps S110 and S120:
[0067] S110 . Based on the signal category information of the process in the embedded real-time operating system, register the signal processing function of the process, and record the signal processing function in the user system call library.
[0068] There can be multiple signal processing functions, and each process can register signal processing functions for different signal types. For example, the SIGALARM signal is usually used to set a timer, and the signal is triggered when the time expires and the process registered for the signal is terminated. However, if the user registers a signal processing function for the signal, when the signal expires and is triggered, the user-registered signal processing function will be executed instead of terminating the process. The sample program uses the alarm system call to set the timer to 5 seconds, and sends a SIGALARM signal at the end of the cycle. The pause system call is used to pause the process. The signal processing program uses the printf statement to output "Hello World!" and exit the program. The specific sample program is as follows:
[0069] #include<stdio.h>
[0070] #include<signal.h>
[0071] #include<unistd.h>
[0072] void sig_handler(int signo)
[0073] {
[0074] if (signo == SIGALRM)
[0075] printf("Hello World!\n");
[0076] exit(0);
[0077] }
[0078] int main(void)
[0079] {
[0080] if(signal(SIGALRM,sig_handler)==SIG_ERR)
[0081] printf("Cannot handle SIGALRM\n");
[0082] alarm(5);
[0083] pause();
[0084] return 0;
[0085] }
[0086] S120. Before starting the main function of the process user in the embedded real-time operating system, execute the user system call library initialization, pass the user state pending signal set global variable address to the process control block structure, and obtain the kernel state pending signal set global variable address.
[0087] In this embodiment, the user system call library initializes and sets the user state pending signal set address to the process control block structure, and sets the pending signal set to the pending signal set address passed in when the user state is initialized before returning to the user state. When the user state processes the signal, there is no need to enter the kernel state to access the pending signal set in the kernel, which reduces the number of state switching of the process, thereby reducing the consumption of CPU resources in the embedded real-time operating system.
[0088] S200. If there is a trigger signal of the process, the trigger signal is recorded in the kernel state pending signal set global variable address. When the user system call library calls the process and it falls into the kernel state, the user field data is saved in the kernel state thread stack, and the trigger signal is kernel processed in the kernel state, and the obtained pending signal set is recorded in the user state pending signal set global variable address; and, the user field data in the kernel state thread stack is restored to return the process to the user state, and signal processing is performed on the pending signal set in sequence according to the signal processing function.
[0089] To better understand the above step S200, the above step S200 is described in detail below in combination with sub-steps S211 to S212, sub-steps S221 to S225, and sub-steps S231 to S232.
[0090] In this embodiment, sub-steps S211 to S212 are detailed descriptions of "if there is a trigger signal of the process, then recording the trigger signal in the kernel state pending signal set global variable address" in step S200, as follows:
[0091] S211, obtaining an external signal received by the embedded real-time operating system, and determining whether there is a trigger signal of a process in the external signal.
[0092] S212a. If there is a trigger signal of the process in the external signal, the trigger signal is recorded in the kernel state pending signal set global variable address.
[0093] S212b. If there is no trigger signal of the process in the external signal, the execution state of the process is maintained, and the user field data including the instruction address stored in the physical register of the embedded real-time operating system is updated in real time.
[0094] Among them, the physical register is used to temporarily save the user field data during the process execution. Later, as long as the user field data in the physical register can be restored to be exactly the same as before entering the kernel state, the process can continue to execute from the instruction address in the user field data.
[0095] In this embodiment, sub-steps S221 to S225 are detailed descriptions of "when the user system call library call process falls into the kernel state, the user field data is saved in the kernel state thread stack, and the trigger signal is kernel processed in the kernel state, and the obtained pending signal set is recorded in the user state pending signal set global variable address" in step S200, as follows:
[0096] S221. When the user system call library calls the process and falls into the kernel state, the user field data is saved in the kernel state thread stack.
[0097] S222. Based on the signal shielding set of the process, shield the sub-signals in the trigger signal corresponding to the signal shielding set to obtain an initial pending signal set.
[0098] In a specific embodiment, a signal mask set (also called a signal mask word or a signal mask) is used to determine pending signals that should be ignored or blocked by a process. Each process has a signal mask set associated with it in the kernel, and the signal mask set determines the pending signals that should be ignored or blocked by the process, so that the pending signals always remain in a pending state until the process completes the signal processing work.
[0099] S223. When the process falls into the kernel state, the initial pending signal set is processed by the kernel, and the obtained pending signal set is recorded in the user state pending signal set global variable address.
[0100] The pending signal set processed by the kernel is passed from the kernel state to the global variable address of the pending signal set in the user state, so that the user state executes the user-registered signal processing function according to the pending signal set processed by the kernel, which improves the execution efficiency of signal processing, and the kernel state does not need to perceive the user state signal processing function, further reducing the coupling between the signal processing function in the user state and the kernel.
[0101] S224. Determine whether there is an initial pending signal set in the kernel state pending signal set global variable address.
[0102] S225a. If there is an initial pending signal set in the kernel state pending signal set global variable address, the instruction address of the user field data in the kernel state thread stack is modified to the entry address of the preset signal dispatch function, and the return address of the signal dispatch function is set to the instruction address of the moment before the process fell into the kernel state.
[0103] S226b. If the initial pending signal set does not exist in the kernel state pending signal set global variable address, the return address of the process is kept as the instruction address when the process falls into the kernel state.
[0104] In this embodiment, sub-steps S231 to S232 are detailed descriptions of "recovering the user field data in the kernel thread stack to return the process to the user state, and performing signal processing on the pending signal set in sequence according to the signal processing function" in step S200, as follows:
[0105] S231, restore the user field data in the kernel state thread stack to the physical register to return the process to the user state. The user field data saved in the kernel stack is restored. The data is user state data. Once restored to the physical register, the process will return to the user state.
[0106] S232. According to the signal distribution function, a corresponding signal processing function is assigned to sequentially process pending signals in the pending signal set to obtain a process after signal processing.
[0107] An embodiment of the present invention provides a signal processing method for a process in an embedded real-time operating system, further comprising:
[0108] S300, after the pending signal set is processed, the control process returns to the instruction address to continue execution according to the instruction address obtained by restoring the user field data in the kernel state thread stack.
[0109] In a specific embodiment, reference Figure 2-5 As shown, process A is the process that needs to perform signal processing, and process B contains the trigger signal of process A. The specific steps of the signal processing process are as follows:
[0110] The first step, such as Figure 3 As shown, before the main function of process A is started, the user system call library is initialized and the address of the global variable of the pending signal set in the user state is passed to the kernel state. The kernel state records the address in the control block structure of process A.
[0111] The second step is, Figure 4 As shown, the user-mode signal processing function registered by the user is recorded in the user system call library.
[0112] The third step is Figure 3 As shown, when process B triggers a signal, the trigger signal is passed to the kernel state pending signal set global variable address of the process A control block structure.
[0113] The fourth step is to make process A fall into kernel state through the user system call library call, and save the user scene data to the kernel state thread stack.
[0114] The fifth step is to perform kernel processing on the unmasked pending signal set before process A returns to the user state, and set the processed pending signal set to the user state pending signal set global variable address recorded by process A.
[0115] Step 6. Before process A returns to user state, if there is an unmasked pending signal in kernel state, the instruction address of the user field data in the kernel state thread stack is modified to the entry address of the preset signal dispatch function, and the return address of the signal dispatch function is set to the instruction address of the moment before the process falls into kernel state, so that the return address of process A is the user state instruction register address before entering kernel state, otherwise process A directly returns to the instruction address when entering kernel state to continue execution.
[0116] The seventh step is to restore the user field data in the kernel state thread stack to the physical register so that the process returns to the user state and enters the user state signal distribution function.
[0117] Step 8: Execute the recorded user-registered signal processing functions in sequence according to the pending signals in the global variable address of the user-mode pending signal set.
[0118] Step 9. Based on the instruction address in the user's field data, control process A to return to the instruction address to continue execution.
[0119] Secondly, an embodiment of the present invention further provides a signal processing system for a process in an embedded real-time operating system, which comprises:
[0120] The initialization module of the embedded real-time operating system is used to record the user-state signal processing function in the user system call library of the embedded real-time operating system, and before starting, perform the user system call library initialization, pass the user-state pending signal set global variable address to the process control block structure, and obtain the kernel-state pending signal set global variable address.
[0121] A signal processing module is used to record the trigger signal in the kernel state pending signal set global variable address if there is a trigger signal of the process, save the user field data in the kernel state thread stack when the user system call library calls the process into the kernel state, perform kernel processing on the trigger signal in the kernel state, and record the obtained pending signal set in the user state pending signal set global variable address; and restore according to the user field data in the kernel state thread stack to return the process to the user state, and perform signal processing on the pending signal set in sequence according to the signal processing function.
[0122] Furthermore, an embodiment of the present invention further provides an electronic device, comprising:
[0123] at least one database; and
[0124] a memory in communication with at least one database;
[0125] The memory stores instructions that can be executed by at least one database, and the instructions are executed by at least one database so that at least one database can execute the signal processing method steps of the process in the embedded real-time operating system described above.
[0126] Finally, a computer-readable medium stores computer-executable instructions, which, when executed by a processor, implement the signal processing method steps of the process in the embedded real-time operating system described above.
[0127] In summary, the present invention proposes a signal processing method for a process in an embedded real-time operating system. First, the user system call library is initialized, and the address of the pending signal set in the user state is set to the kernel state process control block structure. Before the process returns from the kernel state to the user state, the pending signal set is set to the pending signal set address passed in when the user state is initialized. Therefore, when the user state processes the signal, there is no need to enter the kernel to access the pending signal set in the kernel, which reduces the number of state switching of the process and reduces the consumption of CPU resources. Secondly, the signal processing function is recorded in the user state, and different processes are isolated, so that processes cannot access each other, which improves the security and isolation of the process execution. Finally, the user state executes the user-registered signal processing function according to the pending signal set obtained after the kernel processing, so that the kernel state does not need to perceive the signal processing function, and the coupling between the signal processing function and the kernel state is reduced.
[0128] Since the system / device described in the above embodiments of the present invention is a system / device used to implement the method of the above embodiments of the present invention, a person skilled in the art can understand the specific structure and deformation of the system / device based on the method described in the above embodiments of the present invention, and thus will not be described in detail here. All systems / devices used in the method of the above embodiments of the present invention belong to the scope of protection of the present invention.
[0129] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0130] The present invention is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present invention. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions.
[0131] It should be noted that in the claims, any reference numerals placed between brackets shall not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claims. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The invention may be implemented by means of hardware comprising several different components and by means of a suitably programmed computer. In the claims enumerating several means, several of these means may be embodied by the same hardware. The use of the words first, second, third, etc., is for convenience of expression only and does not indicate any order. These words may be understood as part of the component name.
[0132] In addition, it should be noted that, in the description of this specification, the description of the terms "one embodiment", "some embodiments", "embodiment", "example", "specific example" or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are contradictory.
[0133] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments after knowing the basic creative concept. Therefore, the claims should be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present invention.
[0134] Obviously, those skilled in the art can make various modifications and variations to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention should also include these modifications and variations.
Claims
1. A signal processing method for a process in an embedded real-time operating system, characterized in that: include: The user-state signal processing function is recorded in the user system call library of the embedded real-time operating system, and before starting, the user system call library is initialized, the user-state pending signal set global variable address is passed to the process control block structure, and the kernel-state pending signal set global variable address is obtained; If there is a trigger signal for the process, the trigger signal will be recorded in the kernel state pending signal set global variable address. When the user system call library calls the process and it falls into the kernel state, the user field data will be saved in the kernel state thread stack, and the trigger signal will be kernel processed in the kernel state. The obtained pending signal set will be recorded in the user state pending signal set global variable address; and, the user field data in the kernel state thread stack will be restored to return the process to the user state, and signal processing will be performed on the pending signal set in sequence according to the signal processing function.
2. The method according to claim 1, characterized in that Also includes: After the pending signal set is processed, the control process returns to the instruction address to continue execution according to the instruction address obtained by restoring the user field data in the kernel state thread stack.
3. The method according to claim 1, characterized in that The user-state signal processing function is recorded in the user system call library of the embedded real-time operating system, and before startup, the user system call library is initialized, and the user-state pending signal set global variable address is passed to the process control block structure. Obtaining the kernel-state pending signal set global variable address includes: Based on the signal category information of the process in the embedded real-time operating system, a signal processing function of the process is registered, and the signal processing function is recorded in a user system call library; Before the main function of the process user is started in the embedded real-time operating system, the user system call library is initialized, the user state pending signal set global variable address is passed to the process control block structure, and the kernel state pending signal set global variable address is obtained.
4. The method according to claim 1, characterized in that If there is a trigger signal for the process, the trigger signal is recorded in the kernel state pending signal set global variable address including: Obtaining an external signal received by the embedded real-time operating system, and determining whether there is a trigger signal of a process in the external signal; If there is a trigger signal of the process in the external signal, the trigger signal is recorded in the kernel state pending signal set global variable address; If there is no trigger signal of the process in the external signal, the execution state of the process is maintained, and the user field data containing the instruction address stored in the physical register of the embedded real-time operating system is updated in real time.
5. The method according to claim 4, characterized in that When the user system call library calls the process into the kernel state, the user field data is saved in the kernel state thread stack, and the trigger signal is processed in the kernel state. The pending signal set obtained is recorded in the user state pending signal set global variable address including: When the user system call library calls the process into kernel state, the user's on-site data is saved in the kernel state thread stack; Based on the signal shielding set of the process, shield the sub-signals in the trigger signal corresponding to the signal shielding set to obtain an initial pending signal set; When the process falls into the kernel state, the initial pending signal set is processed by the kernel, and the pending signal set obtained is recorded in the user state pending signal set global variable address.
6. The method according to claim 5, characterized in that When the process falls into the kernel state, the kernel processes the initial pending signal set, and after recording the pending signal set in the user state pending signal set global variable address, it also includes: Determine whether there is an initial pending signal set in the kernel state pending signal set global variable address; If there is an initial pending signal set in the kernel state pending signal set global variable address, the instruction address of the user field data in the kernel state thread stack is modified to the entry address of the preset signal dispatch function, and the return address of the signal dispatch function is set to the instruction address of the moment before the process falls into the kernel state; If the initial pending signal set does not exist in the kernel state pending signal set global variable address, the return address of the process is kept as the instruction address when the process falls into the kernel state.
7. The method according to claim 6, characterized in that The user field data in the kernel thread stack is restored to return the process to the user state, and the pending signal set is processed in sequence according to the signal processing function, including: Restore the user field data in the kernel state thread stack to the physical register to return the process to the user state; According to the signal distribution function, the corresponding signal processing function is assigned to process the pending signals in the pending signal set in turn to obtain a process after the signal processing.
8. A signal processing system for a process in an embedded real-time operating system, characterized in that: include: The initialization module of the embedded real-time operating system is used to record the user-state signal processing function in the user system call library of the embedded real-time operating system, and before starting, perform the user system call library initialization, pass the user-state pending signal set global variable address to the process control block structure, and obtain the kernel-state pending signal set global variable address; A signal processing module is used to record the trigger signal in the kernel state pending signal set global variable address if there is a trigger signal of the process, save the user field data in the kernel state thread stack when the user system call library calls the process into the kernel state, perform kernel processing on the trigger signal in the kernel state, and record the obtained pending signal set in the user state pending signal set global variable address; and restore according to the user field data in the kernel state thread stack to return the process to the user state, and perform signal processing on the pending signal set in sequence according to the signal processing function.
9. An electronic device, characterized in that: include: at least one database; as well as a memory in communication with the at least one database; The memory stores instructions that can be executed by the at least one database, and the instructions are executed by the at least one database so that the at least one database can execute the signal processing method steps of the process in the embedded real-time operating system as described in any one of claims 1-7.
10. A computer-readable medium having computer-executable instructions stored thereon, characterized in that: When the executable instructions are executed by the processor, the steps of the signal processing method for a process in an embedded real-time operating system as described in any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Process scheduling method and apparatus and host device
CN107797848A
Message forwarding method, message forwarding device, storage medium and electronic equipment
CN111262784A
Process crash information collection method and device based on eBPF
CN116594796A
Method and system for inter-process communication
WO2021217529A1
