Signal processing method, device and equipment and computer readable storage medium
By setting and processing signal response threads according to signal priority, the problem of signal processing mechanism affecting the reliability, certainty and real-time nature of the real-time operating system in the priorities of the signal is solved, and more efficient signal processing and emergency response are achieved.
Patent Information
- Application Number
- CN202311227883.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-21
- Publication Date
- 2025-03-21
AI Technical Summary
Existing signal processing mechanisms affect the reliability, certainty, and real-time nature of real-time operating systems, especially in emergency tasks and non-emergency signal processing.
By obtaining the priority of the target signal, setting a signal response thread, and setting thread priority according to the signal priority, adding the signal response thread to the corresponding signal response thread group, and processing the pending threads in sequence from high to low priority.
This method can avoid non-emergency signals affecting the processing of emergency tasks, ensure real-time accuracy of emergency signal response, and thus improve the reliability, certainty and real-time nature of the real-time operating system.
Smart Images

Figure CN119668790A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a signal processing method, apparatus, device, and computer-readable storage medium. Background Art
[0002] Receiving a signal is an uncertain emergency. The signal processing mechanism of the existing operating system is: when a thread receives a signal, the operating system will wait until the scheduling point of the thread, then suspend the execution of the thread's program, save the thread's context, and execute the signal processing function of the signal. When the signal processing function of the signal is completed, the operating system will restore the context saved before the thread was suspended, and execute the program that was originally suspended by the thread again.
[0003] In some scenarios: 1) The target thread is currently executing an urgent task and has received many signals, but these signals are not urgent. According to the existing signal processing mechanism, when the scheduling point of the target thread arrives, the execution of the thread will be suspended, and the previously suspended thread will be executed after all signal processing functions are executed, which will affect the certainty and reliability of the thread task execution time; 2) The target thread is currently executing a non-urgent task. At this time, if an urgent signal is sent to the target thread, the target thread needs to wait until the scheduling point and return to the user space to execute the signal processing function, which will affect the real-time response to the emergency signal.
[0004] Therefore, the existing signal processing mechanism will affect the reliability, determinism and real-time performance of the real-time operating system. Summary of the invention
[0005] In order to solve the above technical problems, the present disclosure provides a signal processing method, apparatus, device and computer-readable storage medium.
[0006] In a first aspect, an embodiment of the present disclosure provides a signal processing method, including:
[0007] When receiving a target signal, obtaining a priority of the target signal;
[0008] Setting a signal response thread for the target signal, and setting the priority of the signal response thread according to the priority of the target signal; wherein the higher the priority of the target signal, the higher the priority of the corresponding signal response thread;
[0009] The signal response thread is added to the corresponding signal response thread group. For any signal response thread group, the threads to be processed in the signal response thread group are processed in order of priority from high to low, so as to execute the signal response thread in the signal response thread group so that the target signal is processed.
[0010] In some embodiments, the target signal carries attribute information including at least one of the following:
[0011] The type identifier of the target signal, the identifier of the target sending end of the target signal, and the target destination end thread identifier of the target signal.
[0012] In some embodiments, the attribute information of the target signal includes a type identifier of the target signal; and setting a signal response thread for the target signal includes:
[0013] Determining whether a signal response thread corresponding to the type identifier of the target signal already exists;
[0014] If yes, determining the signal response thread corresponding to the type identifier of the target signal as the signal response thread of the target signal;
[0015] If not, a signal response thread is created for the target signal.
[0016] In some embodiments, before setting a signal response thread for the target signal, the method further includes:
[0017] Determining whether the target signal is a signal that is allowed to be responded to, according to whether the attribute information of the target signal meets a preset attribute information condition;
[0018] The step of setting a signal response thread for the target signal includes:
[0019] If the target signal is a signal that is allowed to be responded to, a signal response thread is set for the target signal according to the type identifier of the target signal, wherein target signals with the same type identifier correspond to the same signal response thread.
[0020] In some embodiments, the attribute information of the target signal includes an identifier of a target sending end of the target signal and a type identifier of the target signal; and judging whether the target signal is a signal allowed to be responded to according to whether the attribute information of the target signal satisfies a preset attribute information condition includes:
[0021] Determining whether the target sending end of the target signal has the sending authority according to the identifier of the target sending end of the target signal and the identifier of the sending end with the sending authority that is stored in advance;
[0022] Determining whether the type identifier of the target signal is the same as the type identifier of the signal currently being processed;
[0023] According to the type identifier of the target signal and the pre-stored type identifier of the ignored signal, determining whether the type of the target signal is the ignored signal type;
[0024] If the target sending end of the target signal has the sending permission, the type identifier of the target signal is different from the type identifier of the signal currently being processed, and the type of the target signal is not an ignored signal type, then the target signal is a signal that is allowed to be responded to.
[0025] In some embodiments, the attribute information of the target signal includes a target destination thread identifier of the target signal; the signal response thread group includes a target destination thread;
[0026] The adding the signal response thread to the corresponding signal response thread group includes:
[0027] A signal response thread group where the target destination thread is located is found according to the target destination thread identifier of the target signal, and the signal response thread is added to the signal response thread group where the target destination thread is located.
[0028] In some embodiments, processing the threads to be processed in the signal response thread group in descending order of priority includes:
[0029] Comparing the priorities of the signal response threads in the signal response thread group and the target destination thread, and determining the thread corresponding to the highest priority as the target thread;
[0030] Process the target thread;
[0031] After the target thread is processed, the thread with the highest priority among the remaining threads in the signal response thread group is determined as the target thread, and the processing continues until all threads in the signal response thread group are processed.
[0032] In some embodiments, the processing of the target thread includes:
[0033] When the target thread is the signal response thread, running a signal processing function to process the signal response thread;
[0034] Determine whether there is a signal with the same type identifier as the target signal in the currently received signal;
[0035] If it exists, the signal processing function is called to process the signal with the same type identifier as the target signal in the currently received signal.
[0036] In some embodiments, the processing of the target thread includes:
[0037] When the target thread is a target destination end thread, the target destination end thread is processed in a preset manner.
[0038] In a second aspect, an embodiment of the present disclosure provides a signal processing device, including:
[0039] An obtaining module, used for obtaining the priority of the target signal when receiving the target signal;
[0040] A creation module is used to set a signal response thread for the target signal, and set the priority of the signal response thread according to the priority of the target signal; wherein the higher the priority of the target signal, the higher the priority of the corresponding signal response thread;
[0041] A processing module is used to add the signal response thread to the corresponding signal response thread group. For any signal response thread group, the threads to be processed in the signal response thread group are processed in order from high to low priority, so as to execute the signal response thread in the signal response thread group so that the target signal is processed.
[0042] In a third aspect, an embodiment of the present disclosure provides an electronic device, including:
[0043] Memory;
[0044] Processor; and
[0045] Computer programs;
[0046] The computer program is stored in the memory and is configured to be executed by the processor to implement the method as described in the first aspect.
[0047] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the method as described in the first aspect.
[0048] In a fifth aspect, an embodiment of the present disclosure further provides a computer program product, which includes a computer program or instructions, and when the computer program or instructions are executed by a processor, the signal processing method as described above is implemented.
[0049] The signal processing method, apparatus, device and computer-readable storage medium provided by the embodiments of the present disclosure obtain the priority of the target signal when receiving the target signal, set a signal response thread for the target signal, and set the priority of the signal response thread according to the priority of the target signal; wherein, the higher the priority of the target signal, the higher the priority of the corresponding signal response thread, and the signal is threadedly processed, each signal has a signal response thread with a priority, the signal response thread is added to the corresponding signal response thread group, and the threads to be processed in the signal response thread group are processed in order from high to low priority, that is, each time a thread receives a new signal, it does not need to wait for the scheduling point of the thread, suspend the execution of the program of the thread, and resume the original program of the thread after the signal processing function of the new signal is executed, but waits for other signals with a higher priority than the new signal to be processed, and then directly processes the signal, thereby saving the signal processing flow, and preventing non-urgent signals from affecting the processing of urgent tasks, and ensuring the real-time response of urgent signals, thereby ensuring the reliability, determinism and real-time performance of the real-time operating system. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0051] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0052] Figure 1 A flow chart of a signal processing method provided by an embodiment of the present disclosure;
[0053] Figure 2 A flow chart of a signal processing method provided by another embodiment of the present disclosure;
[0054] Figure 3 A flow chart of a signal processing method provided by another embodiment of the present disclosure;
[0055] Figure 4 A schematic diagram of the structure of a signal processing device provided in an embodiment of the present disclosure;
[0056] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0057] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0058] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0059] The embodiment of the present disclosure provides a signal processing method, which is introduced below in conjunction with a specific embodiment.
[0060] Figure 1 The flowchart of the signal processing method provided by the embodiment of the present disclosure. The method can be applied to electronic devices, which can be portable mobile devices such as smart phones, tablet computers, laptops, car navigation devices, smart sports equipment, etc.; they can also be fixed devices such as personal computers and smart home appliances. The method can be applied to the scene of signal processing. The method solves the problem that the signal processing mechanism in the prior art will affect the reliability, determinism and real-time performance of the real-time operating system. When the target signal is received, the priority of the target signal is obtained, a signal response thread is set for the target signal, and the priority of the signal response thread is set according to the priority of the target signal; wherein, the higher the priority of the target signal, the higher the priority of the corresponding signal response thread, the signal is threaded, each signal has a signal response thread with a priority, the signal response thread is added to the corresponding signal response thread group, and the threads to be processed in the signal response thread group are processed in order from high to low priority, which can avoid non-emergency signals affecting the processing of emergency tasks, and can ensure the real-time performance of emergency signal response, thereby ensuring the reliability, determinism and real-time performance of the real-time operating system. It can be understood that the signal processing method provided by the embodiment of the present disclosure can also be applied in other scenarios, which are not limited here.
[0061] Below Figure 1 The signal processing method shown in the figure is introduced, and the specific steps of the method are as follows:
[0062] S101. When a target signal is received, obtain the priority of the target signal.
[0063] In this step, when a target signal is received, the electronic device can obtain the priority of the target signal. The number of target signals received by the electronic device can be one or more; the priority of the target signal can be the urgency carried by the signal transmitter when sending the signal. After receiving the target signal, the electronic device determines its corresponding priority according to the urgency carried by the target signal and the pre-saved correspondence between the urgency and the priority; it can also be the priority directly carried by the target signal sent by the signal transmitter. In some embodiments, the priority of the target signal can also be set by the user. In response to the user's setting operation, the corresponding priority is configured for the target signal, wherein the setting operation carries the priority to be configured.
[0064] In some embodiments, when an electronic device receives a target signal, the electronic device will register the target signal and configure the priority of the target signal to save the priority of the target signal as the attribute information of the target signal. When registering a signal, the electronic device will also configure other relevant information of the target signal (for example, signal type, sender, destination process, etc.). Optionally, the sender of the signal carries the urgency of the signal when sending the signal. When configuring the priority of the target signal according to the urgency, for an urgent signal, the priority of the signal is configured to be higher, and for a non-urgent signal, the priority of the signal is configured to be lower.
[0065] In some embodiments, the target signal carries at least one of the following attribute information: a type identifier of the target signal, an identifier of a target sending end of the target signal, and an identifier of a target destination thread of the target signal.
[0066] The attribute information of the signal may be any one or a combination of the type identifier of the target signal, the identifier of the target sending end of the target signal, the target destination end thread identifier of the target signal, or other information, which is not limited in this embodiment.
[0067] The target destination thread is the thread on which the signal acts; the sender of the signal refers to the application or device that sends the signal; the types of signals include start, exit, etc., and each type corresponds to a type identifier.
[0068] S102, setting a signal response thread for the target signal, and setting the priority of the signal response thread according to the priority of the target signal; wherein, the higher the priority of the target signal is, the higher the priority of the corresponding signal response thread is.
[0069] In order to reduce the workload of the electronic device, the electronic device creates a signal response thread for each type of signal and sets the priority of the signal response thread according to the priority of the signal. The higher the priority of the target signal, the higher the priority of the corresponding signal response thread.
[0070] In some embodiments, the S102 sets a signal response thread for the target signal, including but not limited to S1021, S1022, and S1023:
[0071] S1021, determining whether a signal response thread corresponding to the type identifier of the target signal already exists;
[0072] In this embodiment, the electronic device determines whether a signal response thread corresponding to the type identifier of the target signal already exists, and if not, executes S1022; if so, executes S1023.
[0073] S1022: If not, setting a signal response thread for the target signal;
[0074] When there is no signal response thread corresponding to the type identifier of the target signal in the electronic device, a signal response thread is set for the target signal.
[0075] S1023: If yes, determine the signal response thread corresponding to the type identifier of the target signal as the signal response thread of the target signal.
[0076] When a signal response thread corresponding to the type identifier of the target signal already exists in the electronic device, the signal response thread is not created, and the signal response thread corresponding to the type identifier of the target signal is determined as the signal response thread of the target signal. Since signals of the same signal type correspond to the same signal response thread, if a signal response thread of this type already exists, it does not need to be created, thereby avoiding repeated creation of signal response threads and causing signal response thread redundancy.
[0077] S103, adding the signal response thread to the corresponding signal response thread group. For any signal response thread group, processing the threads to be processed in the signal response thread group in order of priority from high to low, so as to execute the signal response thread in the signal response thread group so that the target signal is processed.
[0078] After creating the signal response thread, the electronic device further adds the signal response thread to the corresponding signal response thread group, wherein the signal response thread group includes one or more signal response threads and a target destination thread, and the signal response thread group is equivalent to a container or queue for storing threads to be processed. For any signal response thread group, the threads to be processed in the signal response thread group are processed in order of priority from high to low, so as to execute the signal response thread in the signal response thread group so that the target signal is processed. Specifically, according to the priority of the signal response thread and the target destination thread in the signal response thread group, each thread is processed in order from high to low priority, thereby realizing the processing of the target signal.
[0079] The embodiment of the present disclosure obtains the priority of the target signal when a target signal is received, sets a signal response thread for the target signal, and sets the priority of the signal response thread according to the priority of the target signal; wherein, the higher the priority of the target signal, the higher the priority of the corresponding signal response thread, and the signal response thread is added to the corresponding signal response thread group. For any signal response thread group, the threads to be processed in the signal response thread group are processed in descending order of priority to execute the signal response thread in the signal response thread group so that the target signal is processed. The present invention solves the problem that the signal processing mechanism in the prior art may affect the reliability, determinism and real-time performance of a real-time operating system. When a target signal is received, the priority of the target signal is obtained, a signal response thread is set for the target signal, and the priority of the signal response thread is set according to the priority of the target signal; wherein, the higher the priority of the target signal, the higher the priority of the corresponding signal response thread; the signal is threadedly processed, each signal has a signal response thread with a priority, the signal response thread is added to the corresponding signal response thread group, and the threads to be processed in the signal response thread group are processed in sequence from high to low priority, that is, each time a thread receives a new signal, it does not need to wait for the scheduling point of the thread, suspend the execution of the program of the thread, and resume the original program of the thread after the signal processing function of the new signal is executed, but waits for other signals with a higher priority than the new signal to be processed, and then directly processes the signal, thereby saving the signal processing flow, and avoiding the non-urgent signal from affecting the processing of the urgent task, and ensuring the real-time performance of the urgent signal response, thereby ensuring the reliability, determinism and real-time performance of the real-time operating system.
[0080] Figure 2 A flow chart of a signal processing method provided by another embodiment of the present disclosure is as follows: Figure 2 As shown, the method includes the following steps:
[0081] S201. When a target signal is received, obtain the priority of the target signal.
[0082] Specifically, the implementation process and principle of S201 and S101 are the same, and will not be repeated here.
[0083] S202: Determine whether the target signal is a signal that is allowed to be responded to, based on whether the attribute information of the target signal meets a preset attribute information condition.
[0084] After obtaining the attribute information of the signal, the electronic device determines whether the target signal is a signal that is allowed to be responded to according to whether the attribute information of the target signal satisfies the preset attribute information condition. Specifically, if the attribute information of the target signal satisfies the preset attribute information condition, the target signal is determined to be a signal that is allowed to be responded to; otherwise, the target signal is determined not to be a signal that is allowed to be responded to.
[0085] In some embodiments, S202 may include but is not limited to S2021, S2022, S2023, S2024:
[0086] S2021, judging whether the target sending end of the target signal has sending authority according to the identifier of the target sending end of the target signal and the identifier of the sending end with sending authority that is stored in advance;
[0087] In the electronic device, sending permissions are opened for some senders, while other senders do not have sending permissions. Signals sent by senders without sending permissions will not be allowed to be processed. Based on the identifier of the target sender of the target signal and the identifier of the sender with sending permissions that is pre-saved, it is determined whether the target sender of the target signal has sending permissions.
[0088] S2022, determining whether the type identifier of the target signal is the same as the type identifier of the signal currently being processed;
[0089] The electronic device determines whether the type identifier of the target signal is the same as the type identifier of the signal currently being processed, and if they are the same, the signal will be blocked (suspended).
[0090] S2023: judging whether the type of the target signal is an ignored signal type according to the type identifier of the target signal and the pre-stored type identifier of the ignored signal;
[0091] The electronic device is provided with a type number of the ignored signal, and can judge whether the type of the target signal is the ignored signal type according to the type identifier of the target signal and the type identifier of the ignored signal stored in advance.
[0092] Among them, the execution order of S2021, S2022 and S2023 can be executed simultaneously or not at the same time. When they are not executed simultaneously, the execution order of S2021, S2022 and S2023 can be set arbitrarily, which will not be elaborated here.
[0093] S2024. If the target sending end of the target signal has the sending permission, the type identifier of the target signal is different from the type identifier of the signal currently being processed, and the type of the target signal is not an ignored signal type, then the target signal is a signal that is allowed to be responded to.
[0094] If the target sender of the target signal has the sending permission, the type identifier of the target signal is different from the type identifier of the signal currently being processed, and the type of the target signal is not an ignored signal type, the electronic device determines that the target signal is a signal that is allowed to be responded to; otherwise, the electronic device determines that the target signal is not a signal that is allowed to be responded to.
[0095] S203. If the signal is a signal that is allowed to be responded to, a signal response thread is set for the target signal, and the priority of the signal response thread is set according to the priority of the target signal; wherein, the higher the priority of the target signal, the higher the priority of the corresponding signal response thread.
[0096] When the signal is a signal that is allowed to be responded to, the electronic device sets a signal response thread for the target signal and sets the priority of the signal response thread according to the priority of the target signal; wherein, the higher the priority of the target signal, the higher the priority of the corresponding signal response thread.
[0097] In some embodiments, the electronic device will create a signal response thread group for each target destination thread in advance, and add the target destination thread to the signal response thread group. The thread on which the signal acts is called the target destination thread. In other words, the signal response thread group includes the target destination thread.
[0098] S204: Find out the signal response thread group where the target destination thread is located according to the target destination thread identifier of the target signal, and add the signal response thread to the signal response thread group where the target destination thread is located.
[0099] The electronic device finds the signal response thread group where the target destination thread is located according to the target destination thread identifier of the target signal, and adds the signal response thread to the signal response thread group where the target destination thread is located. At this time, the signal response thread group includes the target destination thread and the signal response thread.
[0100] S205: Process the threads to be processed in the signal response thread group in order of priority from high to low.
[0101] In this step, the electronic device processes the threads to be processed in the signal response thread group in descending order of priority. Specifically, the electronic device processes each thread in descending order of priority according to the priority of the signal response thread and the target destination thread in the signal response thread group.
[0102] The embodiment of the present disclosure obtains the priority of the target signal when a target signal is received, and determines whether the target signal is a signal that is allowed to be responded to based on whether the attribute information of the target signal meets the preset attribute information conditions. If the signal is a signal that is allowed to be responded to, a signal response thread is set for the target signal, and the priority of the signal response thread is set according to the priority of the target signal; wherein, the higher the priority of the target signal, the higher the priority of the corresponding signal response thread. Further, a target destination thread is created for the destination identifier, the target destination thread is added to the signal response thread group, the signal response thread group where the target destination thread is located is found according to the target destination thread identifier of the target signal, and the signal response thread is added to the signal response thread group where the target destination thread is located. Then, the threads to be processed in the signal response thread group are processed in order of priority from high to low. Compared with the prior art, since the target signal is first judged whether it is a signal that is allowed to be responded to based on whether the attribute information of the target signal meets the preset attribute information conditions, the security of the real-time operating system can be improved. Furthermore, the signal response thread group where the target destination thread is located is found according to the target destination thread identifier of the target signal, and the signal response thread is added to the signal response thread group where the target destination thread is located. Then, according to the priority of the signal response thread and the target destination thread in the signal response thread group, each thread is processed in sequence from high to low priority, which can avoid non-urgent signals affecting the processing of urgent tasks, and can ensure the real-time response of urgent signals, thereby ensuring the reliability, determinism and real-time performance of the real-time operating system.
[0103] Figure 3 A flow chart of a signal processing method provided by another embodiment of the present disclosure is as follows: Figure 3 As shown, the method includes the following steps:
[0104] S301. When a target signal is received, obtain the priority of the target signal.
[0105] Specifically, the implementation process and principle of S301 and S101 are the same, and will not be repeated here.
[0106] S302, setting a signal response thread for the target signal, and setting the priority of the signal response thread according to the priority of the target signal; wherein, the higher the priority of the target signal is, the higher the priority of the corresponding signal response thread is.
[0107] Specifically, the implementation process and principle of S302 and S102 are the same, and will not be repeated here.
[0108] S303: Find out the signal response thread group where the target destination thread is located according to the target destination thread identifier of the target signal, and add the signal response thread to the signal response thread group where the target destination thread is located.
[0109] Specifically, the implementation process and principle of S303 and S204 are the same, and will not be repeated here.
[0110] S304: Compare the priorities of the signal response threads in the signal response thread group and the target destination thread, and determine the thread corresponding to the highest priority as the target thread.
[0111] After adding the signal response thread to the signal response thread group where the target destination thread is located, the electronic device compares the priorities of the signal response threads in the signal response thread group and the target destination thread, and determines the thread corresponding to the highest priority as the target thread.
[0112] S305: Process the target thread.
[0113] After determining the target thread, the electronic device processes the target thread.
[0114] In some embodiments, S305 may include but is not limited to S3051, S3052, S3053:
[0115] S3051, when the target thread is the signal response thread, running a signal processing function to process the signal response thread;
[0116] In this step, when the target thread is the signal response thread, that is, when the signal response thread has the highest priority, the electronic device runs the signal processing function to process the signal response thread, thereby ensuring the real-time performance of the emergency signal response.
[0117] S3052, determining whether there is a signal with the same type identifier as the target signal in the currently received signal;
[0118] Since each type of signal creates a signal response thread, the essence of this step is to determine whether there is a signal of the same type as the currently received signal that is blocked (suspended).
[0119] S3053: If so, call the signal processing function to process the signal with the same type identifier as the target signal in the currently received signal.
[0120] If so, the electronic device calls the signal processing function to process the signal with the same type identifier as the target signal in the currently received signal until there is no signal with the same type identifier as the target signal in the currently received signal.
[0121] In some embodiments, the processing the target thread includes: when the target thread is a target destination thread, processing the target destination thread in a preset manner.
[0122] When the target thread is the target destination thread, that is, the target destination thread has the highest priority, the target destination thread is processed in a preset manner. The target destination thread is a common thread, and the processing of the target destination thread can be realized by running the corresponding instructions. Specifically, the electronic device processes the tasks in the target destination thread, which can prevent non-urgent signals from affecting the processing of urgent tasks.
[0123] The process of processing the target destination thread in a preset manner is a prior art and will not be described in detail here.
[0124] S306 , when the target thread is processed, the thread with the highest priority among the remaining threads in the signal response thread group is determined as the target thread, and the processing continues until all threads in the signal response thread group are processed.
[0125] After the target thread is processed, the electronic device determines the thread with the highest priority among the remaining threads in the signal response thread group as the target thread, and continues processing until all threads in the signal response thread group are processed.
[0126] When a target signal is received in the embodiment of the present disclosure, the priority of the target signal is obtained, a signal response thread is set for the target signal, and the priority of the signal response thread is set according to the priority of the target signal; wherein, the higher the priority of the target signal, the higher the priority of the corresponding signal response thread. Further, the signal response thread group where the target destination thread is located is found according to the target destination thread identifier of the target signal, the signal response thread is added to the signal response thread group where the target destination thread is located, the priorities of the signal response threads and the target destination threads in the signal response thread group are compared, the thread corresponding to the highest priority is determined as the target thread, and the target thread is processed. Then, when the target thread is processed, the thread with the highest priority among the remaining threads in the signal response thread group is determined as the target thread, and the processing continues until all threads in the signal response thread group are processed. Compared with the prior art, since the priorities of the signal response thread and the target destination thread in the signal response thread group are compared, the thread corresponding to the highest priority is determined as the target thread, and the target thread is processed. After the target thread is processed, the thread with the highest priority among the remaining threads in the signal response thread group is determined as the target thread, and the processing is continued until all threads in the signal response thread group are processed. This can avoid non-emergency signals affecting the processing of emergency tasks, and can ensure the real-time performance of emergency signal response, thereby ensuring the reliability, determinism and real-time performance of the real-time operating system.
[0127] Figure 4 Schematic diagram of the structure of the signal processing device provided in the embodiment of the present disclosure. The signal processing device may be the electronic device as described in the above embodiment, or the signal processing device may be a component or assembly in the electronic device. The signal processing device provided in the embodiment of the present disclosure may execute the processing flow provided in the signal processing method embodiment, such as Figure 4 As shown, the signal processing device 40 includes: an obtaining module 41, a creating module 42, and a processing module 43; wherein the obtaining module 41 is used to obtain the priority of the target signal when the target signal is received; the creating module 42 is used to set a signal response thread for the target signal, and set the priority of the signal response thread according to the priority of the target signal; wherein, the higher the priority of the target signal, the higher the priority of the corresponding signal response thread; the processing module 43 is used to add the signal response thread to the corresponding signal response thread group, and for any signal response thread group, the threads to be processed in the signal response thread group are processed in order from high to low priority, so as to execute the signal response thread in the signal response thread group so that the target signal is processed.
[0128] Optionally, the attribute information of the target signal includes a type identifier of the target signal; when the creation module 42 sets a signal response thread for the target signal, it is specifically used to: determine whether a signal response thread corresponding to the type identifier of the target signal already exists; if so, determine the signal response thread corresponding to the type identifier of the target signal as the signal response thread of the target signal; if not, create a signal response thread for the target signal.
[0129] Optionally, the device further includes: a judgment module 44; the judgment module 44 is used to judge whether the target signal is a signal that is allowed to be responded to according to whether the attribute information of the target signal meets a preset attribute information condition;
[0130] When the creation module 42 sets a signal response thread for the target signal, it is specifically used to: if the target signal is a signal allowed to be responded to, set a signal response thread for the target signal according to the type identifier of the target signal, wherein target signals with the same type identifier correspond to the same signal response thread.
[0131] Optionally, the attribute information of the target signal includes an identifier of a target sending end of the target signal and a type identifier of the target signal; when the judgment module 44 judges whether the target signal is a signal that is allowed to be responded to based on whether the attribute information of the target signal satisfies a preset attribute information condition, it is specifically used to: judge whether the target sending end of the target signal has the sending authority based on the identifier of the target sending end of the target signal and the identifier of the sending end with sending authority that is pre-saved; judge whether the type identifier of the target signal is the same as the type identifier of a signal currently being processed; judge whether the type of the target signal is an ignored signal type based on the type identifier of the target signal and the type identifier of an ignored signal that is pre-saved; if the target sending end of the target signal has the sending authority, the type identifier of the target signal is different from the type identifier of the signal currently being processed, and the type of the target signal is not an ignored signal type, then the target signal is a signal that is allowed to be responded to.
[0132] Optionally, the attribute information of the target signal includes the target destination thread identifier of the target signal; the signal response thread group includes the target destination thread; when the processing module 43 adds the signal response thread to the corresponding signal response thread group, it is specifically used to: find out the signal response thread group where the target destination thread is located according to the target destination thread identifier of the target signal, and add the signal response thread to the signal response thread group where the target destination thread is located.
[0133] Optionally, when the processing module 43 processes the pending threads in the signal response thread group in order of priority from high to low, it is specifically used to: compare the priorities of the signal response threads and the target destination threads in the signal response thread group, and determine the thread corresponding to the highest priority as the target thread; process the target thread; after the target thread is processed, determine the thread with the highest priority among the remaining threads in the signal response thread group as the target thread, and continue processing until all threads in the signal response thread group are processed.
[0134] Optionally, when the processing module 43 processes the target thread, it is specifically used to: when the target thread is the signal response thread, run the signal processing function to process the signal response thread; determine whether there is a signal with the same type identifier as the target signal in the currently received signal; if so, call the signal processing function to process the signal with the same type identifier as the target signal in the currently received signal.
[0135] Figure 4 The signal processing device of the illustrated embodiment can be used to execute the technical solution of the above-mentioned method embodiment, and its implementation principle and technical effect are similar and will not be described in detail here.
[0136] Figure 5 Schematic diagram of the structure of an electronic device in the embodiment of the present disclosure. Figure 5 , which shows a structural schematic diagram of an electronic device 600 suitable for implementing the embodiments of the present disclosure. Figure 5 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0137] like Figure 5 As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 to a random access memory (RAM) 603 to implement the signal processing method of the embodiment described in the present disclosure. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0138] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 5 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0139] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains a program code for executing the method shown in the flowchart, thereby implementing the signal processing method as described above. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0140] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0141] In addition, an embodiment of the present disclosure further provides a vehicle, comprising: a memory; a processor; and a computer program; wherein the computer program is stored in the memory and is configured to be executed by the processor to implement the signal processing method as described above.
[0142] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0143] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0144] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device:
[0145] When receiving a target signal, obtaining a priority of the target signal;
[0146] Setting a signal response thread for the target signal, and setting the priority of the signal response thread according to the priority of the target signal; wherein the higher the priority of the target signal, the higher the priority of the corresponding signal response thread;
[0147] The signal response thread is added to the corresponding signal response thread group. For any signal response thread group, the threads to be processed in the signal response thread group are processed in order of priority from high to low, so as to execute the signal response thread in the signal response thread group so that the target signal is processed.
[0148] Optionally, when the above one or more programs are executed by the electronic device, the electronic device may also execute other steps described in the above embodiments.
[0149] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0150] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0151] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, limit the unit itself.
[0152] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0153] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0154] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0155] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0156] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. A signal processing method, characterized in that: The method comprises: When receiving a target signal, obtaining a priority of the target signal; Setting a signal response thread for the target signal, and setting the priority of the signal response thread according to the priority of the target signal; wherein the higher the priority of the target signal, the higher the priority of the corresponding signal response thread; The signal response thread is added to the corresponding signal response thread group. For any signal response thread group, the threads to be processed in the signal response thread group are processed in order of priority from high to low, so as to execute the signal response thread in the signal response thread group so that the target signal is processed.
2. The method according to claim 1, characterized in that The attribute information of the target signal includes a type identifier of the target signal; and setting a signal response thread for the target signal includes: Determining whether a signal response thread corresponding to the type identifier of the target signal already exists; If yes, determining the signal response thread corresponding to the type identifier of the target signal as the signal response thread of the target signal; If not, a signal response thread is created for the target signal.
3. The method according to claim 1, characterized in that Before setting a signal response thread for the target signal, the method further includes: Determining whether the target signal is a signal that is allowed to be responded to, according to whether the attribute information of the target signal meets a preset attribute information condition; The step of setting a signal response thread for the target signal includes: If the target signal is a signal that is allowed to be responded to, a signal response thread is set for the target signal according to the type identifier of the target signal, wherein target signals with the same type identifier correspond to the same signal response thread.
4. The method according to claim 3, characterized in that The attribute information of the target signal includes an identifier of a target sending end of the target signal and a type identifier of the target signal; and judging whether the target signal is a signal that is allowed to be responded to according to whether the attribute information of the target signal satisfies a preset attribute information condition includes: Determining whether the target sending end of the target signal has the sending authority according to the identifier of the target sending end of the target signal and the identifier of the sending end with the sending authority that is stored in advance; Determining whether the type identifier of the target signal is the same as the type identifier of the signal currently being processed; According to the type identifier of the target signal and the pre-stored type identifier of the ignored signal, determining whether the type of the target signal is the ignored signal type; If the target sending end of the target signal has the sending permission, the type identifier of the target signal is different from the type identifier of the signal currently being processed, and the type of the target signal is not an ignored signal type, then the target signal is a signal that is allowed to be responded to.
5. The method according to claim 1, characterized in that The attribute information of the target signal includes the target destination thread identifier of the target signal; the signal response thread group includes the target destination thread; The adding the signal response thread to the corresponding signal response thread group includes: A signal response thread group where the target destination thread is located is found according to the target destination thread identifier of the target signal, and the signal response thread is added to the signal response thread group where the target destination thread is located.
6. The method according to claim 5, characterized in that The processing of the threads to be processed in the signal response thread group in order of priority from high to low includes: Comparing the priorities of the signal response threads in the signal response thread group and the target destination thread, and determining the thread corresponding to the highest priority as the target thread; Process the target thread; After the target thread is processed, the thread with the highest priority among the remaining threads in the signal response thread group is determined as the target thread, and the processing continues until all threads in the signal response thread group are processed.
7. The method according to claim 6, characterized in that The processing of the target thread includes: When the target thread is the signal response thread, running a signal processing function to process the signal response thread; Determine whether there is a signal with the same type identifier as the target signal in the currently received signal; If it exists, the signal processing function is called to process the signal with the same type identifier as the target signal in the currently received signal.
8. A signal processing device, characterized in that: include: An obtaining module, used for obtaining the priority of the target signal when receiving the target signal; A creation module is used to set a signal response thread for the target signal, and set the priority of the signal response thread according to the priority of the target signal; wherein the higher the priority of the target signal, the higher the priority of the corresponding signal response thread; A processing module is used to add the signal response thread to the corresponding signal response thread group. For any signal response thread group, the threads to be processed in the signal response thread group are processed in order from high to low priority, so as to execute the signal response thread in the signal response thread group so that the target signal is processed.
9. An electronic device, characterized in that: include: Memory; processor; as well as Computer programs; The computer program is stored in the memory and is configured to be executed by the processor to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.