A signal processing method for processes in an embedded real-time operating system

By recording signal processing functions in user state and initializing the user system call library in the embedded real-time operating system, the problem of high CPU resource and memory consumption in the process signal processing in the existing technology is solved, and more efficient signal processing and lower kernel state coupling are achieved.

CN119179522BActive Publication Date: 2025-09-19SUPCON TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411208141.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-30
Publication Date
2025-09-19
Estimated Expiration
2044-08-30

AI Technical Summary

Technical Problem

In the prior art, the process signal processing in an embedded real-time operating system frequently switches between kernel state and user state, resulting in high CPU resource and memory consumption, and high coupling between the signal processing function and the kernel state.

Method used

By recording the signal processing function in user state and initializing the user system call library before the process starts, the address of the global variable of the pending signal set in user state is passed to the process control block structure, and the address of the global variable of the pending signal set in kernel state is obtained. After the process handles the signal in kernel state, the pending signal set is recorded in the global variable address of the pending signal set in user state, thus reducing the number of process state switches.

Benefits of technology

It reduces the consumption of CPU resources and memory during process signal processing, improves the security and isolation of process execution, and reduces the coupling between signal processing functions and kernel state.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119179522B_ABST
    Figure CN119179522B_ABST
Patent Text Reader

Abstract

The present invention relates to a signal processing method for a process in an embedded real-time operating system, comprising: recording a signal processing function in a user system call library, executing user system call library initialization, transferring a user state pending signal set global variable address to kernel state, and obtaining the kernel state pending signal set global variable address; recording a trigger signal in the kernel state pending signal set global variable address; saving user field data in a kernel state thread stack when a calling process falls into kernel state; performing kernel processing on the trigger signal in kernel state, recording the obtained pending signal set in the user state pending signal set global variable address; and restoring the process based on the user field data to return it to user state, and executing signal processing on the pending signal set based on the signal processing function. The present invention solves the technical problems of high CPU resource and memory consumption and high coupling between the signal processing function and kernel state when a process executes signal processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present 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 used by an embedded real-time operating system for resource allocation and scheduling. It is an independently running entity that the system uses to allocate and schedule resources and is the carrier for application execution. Each process has its own independent address space, including code segments, data segments, stacks, and system resources required for runtime (such as file descriptors and signal handlers).

[0003] After the user specifies a signal handler, the process must return from kernel state to user space (user state) when executing the signal handler because the program has excessive control privileges when the signal handler is in kernel state, which can easily damage system resources and hardware devices.

[0004] At present, in the existing technology, 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 field data to the end of 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] The process signal processing in the aforementioned prior art suffers from the following technical drawbacks: First, because the process signal processing involves returning to user mode and entering kernel mode at least twice, the frequent state switching consumes a significant amount of CPU resources. Second, because the process signal processing requires frequent stack pushes and pops to protect user field data, it consumes a significant amount of memory. Third, because kernel mode needs to be aware of the signal processing function, the signal processing function is highly coupled to kernel mode. Summary of the Invention

[0006] (1) Technical issues to be solved

[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] (2) Technical solution

[0009] In order to achieve the above objectives, 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. Before startup, 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 for 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 obtained by restoring the user field data in the kernel state thread stack to continue execution.

[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 the 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 for 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 for 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, 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 the kernel state, the user field data is saved in the kernel state thread stack;

[0024] Based on the signal shield set of the process, the sub-signals corresponding to the signal shield set in the trigger signal are shielded to obtain the initial pending signal set;

[0025] When the process falls into the kernel state, 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.

[0026] Optionally, when the process falls into the kernel state, after kernel processing is performed on the initial pending signal set and the obtained pending signal set is recorded 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 the kernel state pending signal set global variable address contains an initial pending signal set, 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 before the process falls into the kernel state;

[0029] If the kernel state pending signal set global variable address does not contain the initial pending signal set, 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 context data in the kernel 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 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 startup, 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] The 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; when the user system call library calls the process into the kernel state, save the user field data in the kernel state thread stack; 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 communicatively coupled to 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 to enable the at least one database to 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, which, when executed by a processor, implement the signal processing method steps of a process in an embedded real-time operating system as described above.

[0041] (3) Beneficial effects

[0042] The beneficial effects of the present invention are as follows: a signal processing method for a process in an embedded real-time operating system adopts a technical solution of transferring the global variable address of a user-state pending signal set to set the global variable address of a kernel-state pending signal set in kernel state for recording a trigger signal, and transferring the pending signal set obtained after kernel processing of the trigger signal to the global variable address of the user-state pending signal set for recording. Compared with the prior art, the method records the pending signal set in user state, so that after processing the pending signal set of a process in user state, there is no need to re-enter kernel state to access other pending signals, thereby reducing the number of process state switches, the number of stack pushes and pops, and thus reducing the consumption of CPU resources and memory by the process during signal processing.

[0043] Secondly, the signal processing function is recorded in the user state, isolating different processes so that processes cannot access each other, thereby improving the security and isolation of process execution.

[0044] In addition, 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, 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 one 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 pending signal set transmission 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 methods 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 this application is first introduced below, and the solution of this application can be subsequently adjusted and controlled based on this basic information.

[0052] Embedded real-time operating system: When external events or data are generated, it can accept and process them at a sufficiently fast speed. The processing results can control the production process or respond quickly to the processing system within the specified events, and control the coordinated operation of all real-time tasks to control, monitor or assist in the operation of machines and equipment.

[0053] Signal processing: Signal processing is the process of receiving and processing signals from the system or other processes in embedded real-time systems. Signals are asynchronous notification mechanisms used to inform a process of an event or condition, allowing the process to take appropriate action based on the received signal.

[0054] Kernel state: This is an execution state in a computer system, often also referred to as operating system state. In kernel state, the CPU has the highest execution privileges, allowing direct access to the computer's hardware resources, such as memory, CPU registers, and input and output devices. At this point, the embedded real-time operating system can execute its privileged instructions and implement key system functions, such as process management, memory management, and file system management. Programs running in kernel state can perform more advanced functions.

[0055] User state: This refers to the execution state when running a user program. In user state, the CPU has relatively low execution privileges, restricted by the embedded real-time operating system, and 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, with their capabilities and permissions 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. Record the user-state signal processing function in the user system call library of the embedded real-time operating system, and before startup, perform 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.

[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 user-state pending signal set global variable is transferred to set the kernel-state pending signal set global variable address in 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 user-state pending signal set global variable address for recording. Compared with the prior art, this method records the pending signal set in user state, eliminating the need to re-enter kernel state to access other pending signals after processing the pending signal set of a process in user state. This reduces the number of process state switches, the number of stack pushes and pops, and thus reduces the CPU resource and memory consumption of 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] To better understand the above technical solutions, 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. Rather, 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. Record the user-state signal processing function in the user system call library of the embedded real-time operating system, and before startup, perform 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.

[0066] For example, step S100 of this embodiment may include the following sub-steps S110 and S120:

[0067] S110 . Register a signal processing function of the process based on the signal category information of the process in the embedded real-time operating system, and record the signal processing function in a 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. When the timer expires, the signal is triggered 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 period. The pause system call is used to pause the process. The signal handler 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, perform 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 address of the pending signal set in user mode to the process control block structure. Before returning to user mode, the pending signal set is set to the pending signal set address passed in during user mode initialization. When processing signals in user mode, there is no need to enter kernel mode to access the pending signal set in the kernel. This reduces the number of state switches in the process and, in turn, reduces CPU resource consumption 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 conjunction 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 explanations of "if there is a trigger signal of the process, 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 a trigger signal of a process is contained 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 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 a detailed description of "when the user system call library calling process falls into kernel state, saving the user field data in the kernel state thread stack, performing kernel processing on the trigger signal in the kernel state, and recording the obtained pending signal set in the user state pending signal set global variable address" in step S200, as follows:

[0096] S221. When the user system call library calls a process that falls into the kernel state, the user field data is saved in the kernel state thread stack.

[0097] S222 : Based on the signal shield set of the process, shield the sub-signals in the trigger signal corresponding to the signal shield set to obtain an initial pending signal set.

[0098] In one embodiment, a signal mask set (also known as a signal mask or signal word) 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. The signal mask set determines the pending signals that should be ignored or blocked by the process, so that the pending signals remain in a pending state until the process completes signal handling.

[0099] S223. When the process falls into the kernel state, kernel processing is performed on the initial pending signal set, 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 falls 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 explanations of "restoring the user context data in the kernel 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" 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. Restore the user field data saved in the kernel stack, which is the 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 obtained by restoring the user context data in the kernel thread stack to continue execution.

[0109] In a specific embodiment, referring to 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 signal processing steps 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, such as 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 field 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] In the eighth step, the recorded user-registered signal processing functions are executed 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 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, comprising:

[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 startup, 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] The 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; when the user system call library calls the process into the kernel state, save the user field data in the kernel state thread stack; 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 communicatively coupled to 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 to enable at least one database to 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 user-state pending signal set is set in 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 processing signals in the user state, there is no need to enter the kernel to access the pending signal set in the kernel, which reduces the number of state switches 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, thereby improving the security and isolation during process execution. Finally, 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, reducing the coupling between the signal processing function and the kernel state.

[0128] Since the systems / devices described in the above embodiments of the present invention are systems / devices used to implement the methods of the above embodiments of the present invention, those skilled in the art will be able to understand the specific structures and variations of these systems / devices based on the methods described in the above embodiments of the present invention, and thus will not be described in detail here. All systems / devices used in the methods of the above embodiments of the present invention are within the scope of protection of the present invention.

[0129] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. 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 magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0130] The present invention is described with reference to flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions.

[0131] It should be noted that, in the claims, any reference signs 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 claims enumerating several means, several of these means may be embodied by one and the same hardware. The use of the words first, second, third etc. is for convenience 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" 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 expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine different embodiments or examples described in this specification and the features of 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 additional changes and modifications to these embodiments after learning the basic creative concept. Therefore, the claims should be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0134] Obviously, those skilled in the art may make various modifications and variations to the present invention without departing from the spirit and scope of the present invention. Thus, if such modifications and variations fall within the scope of the claims and their equivalents, the present invention shall also include such 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 startup, 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, wherein Also includes: After the pending signal set is processed, the control process returns to the instruction address obtained by restoring the user field data in the kernel state thread stack to continue execution.

3. The method according to claim 1, wherein The user-state signal processing function is recorded in the user system call library of the embedded real-time operating system. Before startup, the user system call library is initialized and the global variable address of the user-state pending signal set is passed to the process control block structure. Obtaining the global variable address of the kernel-state pending signal set 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 the 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, wherein 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 for 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, wherein 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 obtained pending signal set is recorded in the user state pending signal set global variable address including: 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; Based on the signal shield set of the process, the sub-signals corresponding to the signal shield set in the trigger signal are shielded to obtain the initial pending signal set; When the process falls into the kernel state, 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.

6. The method according to claim 5, wherein When the process falls into the kernel state, the kernel processes the initial pending signal set and records the pending signal set in the user state pending signal set global variable address, and further includes: Determine whether there is an initial pending signal set in the kernel state pending signal set global variable address; If the kernel state pending signal set global variable address contains an initial pending signal set, 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 before the process falls into the kernel state; If the kernel state pending signal set global variable address does not contain the initial pending signal set, 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, wherein 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 includes: 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 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 startup, 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; The 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; when the user system call library calls the process into the kernel state, save the user field data in the kernel state thread stack; 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 communicatively coupled to 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 according to any one of claims 1 to 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 according to any one of claims 1 to 7 are implemented.