CN116820893A - Time protection method and device - Google Patents

Time protection method and device Download PDF

Info

Publication number
CN116820893A
CN116820893A CN202310896573.6A CN202310896573A CN116820893A CN 116820893 A CN116820893 A CN 116820893A CN 202310896573 A CN202310896573 A CN 202310896573A CN 116820893 A CN116820893 A CN 116820893A
Authority
CN
China
Prior art keywords
target
duration
interrupt
time
task
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310896573.6A
Other languages
Chinese (zh)
Inventor
于洪斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jingwei Hengrun Tianjin Research And Development Co ltd
Original Assignee
Jingwei Hengrun Tianjin Research And Development Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jingwei Hengrun Tianjin Research And Development Co ltd filed Critical Jingwei Hengrun Tianjin Research And Development Co ltd
Priority to CN202310896573.6A priority Critical patent/CN116820893A/en
Publication of CN116820893A publication Critical patent/CN116820893A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3013Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system is an embedded system, i.e. a combination of hardware and software dedicated to perform a certain function in mobile devices, printers, automotive or aircraft systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F1/00Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
    • G06F1/04Generating or distributing clock signals or signals derived directly therefrom
    • G06F1/10Distribution of clock signals, e.g. skew
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3051Monitoring arrangements for monitoring the configuration of the computing system or of the computing system component, e.g. monitoring the presence of processing resources, peripherals, I/O links, software programs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/14Handling requests for interconnection or transfer
    • G06F13/20Handling requests for interconnection or transfer for access to input/output bus
    • G06F13/24Handling requests for interconnection or transfer for access to input/output bus using interrupt
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/485Task life-cycle, e.g. stopping, restarting, resuming execution

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Quality & Reliability (AREA)
  • Software Systems (AREA)
  • Mathematical Physics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application discloses a time protection method and a time protection device. The method comprises the following steps: the method comprises the steps of monitoring target time length of target tasks or target interrupts in an operating system, wherein the target time length comprises at least one of execution time length, locking time length and interval time length, the locking time length is time length of target resources occupied by the target tasks or time length of target interrupts, calling a time protection function corresponding to the target time length of the target tasks or the target interrupts under the condition that the target time length meets a preset condition, and executing operation indicated by a preset return value in the time protection function so as to perform time protection on the operating system. In this way, the operating system can be effectively time-protected.

Description

Time protection method and device
Technical Field
The application belongs to the technical field of computers, and particularly relates to a time protection method and device.
Background
In embedded operating systems, if a task or interrupt misses its deadline at runtime, this will result in a time error that propagates through the operating system, causing other normally running tasks or interrupts to miss its deadline as well.
However, since the deadline of a task or interrupt is generally set to be relatively broad, when a certain task or interrupt is found to miss its deadline, a time error is likely to have occurred for a while, and it is impossible to determine whether it is caused by a currently running task or interrupt or by a previously running task or interrupt.
Therefore, the operating system cannot be effectively time-protected.
Disclosure of Invention
The embodiment of the application provides a time protection method and a time protection device, which can solve the problem that an operating system cannot be effectively protected in time in the prior art.
In a first aspect, an embodiment of the present application provides a time protection method, including:
monitoring a target duration of a target task or target interrupt in an operating system, wherein the target duration comprises at least one of an execution duration, a locking duration and an interval duration, the locking duration is a duration of a target resource occupied by the target task or a duration of the target interrupt,
under the condition that the target duration meets the preset condition, a time protection function corresponding to the target duration of the target task or the target interrupt is called,
and executing an operation indicated by a preset return value in the time protection function to perform time protection on the operating system, wherein the operation comprises closing a target task, closing a target interrupt or ignoring a time error.
In a second aspect, an embodiment of the present application provides a time protection apparatus, including:
a monitoring module for monitoring a target duration of a target task or a target interrupt in an operating system, wherein the target duration comprises at least one of an execution duration, a locking duration and an interval duration, the locking duration is a duration of a target resource occupied by the target task or a duration of the target interrupt,
A calling module for calling a time protection function corresponding to the target duration of the target task or the target interrupt under the condition that the target duration meets the preset condition,
and the execution module is used for executing the operation indicated by the preset return value in the time protection function so as to perform time protection on the operating system, wherein the operation comprises closing the target task, closing the target interrupt or ignoring the time error.
In a third aspect, an embodiment of the present application provides an electronic device, including: a processor and a memory storing computer program instructions,
the processor, when executing the computer program instructions, implements a time protection method as shown in any of the embodiments of the first aspect.
In a fourth aspect, embodiments of the present application provide a computer storage medium having stored thereon computer program instructions which, when executed by a processor, implement the time protection method shown in any of the embodiments of the first aspect.
In a fifth aspect, embodiments of the present application provide a computer program product, instructions in which, when executed by a processor of an electronic device, cause the electronic device to perform the time protection method shown in any of the embodiments of the first aspect.
The time protection method and the time protection device can monitor the target duration of the target task or the target interrupt in the operating system, and call the time protection function corresponding to the target duration of the target task or the target interrupt under the condition that the target duration meets the preset condition, so as to execute the operation indicated by the preset return value in the time protection function, and perform time protection on the operating system. Wherein the target duration includes at least one of an execution duration, a lock duration, and an interval duration. Therefore, the application can monitor the target task or the target interrupt by at least one of the execution duration, the locking duration and the interval duration, thereby being capable of timely finding when a time error occurs. In addition, any task or interrupt can be monitored in a targeted manner, so that the task or interrupt causing the time error can be determined accurately, then the corresponding operation can be executed to protect the time of the operating system, the subsequent task or interrupt can be prevented from being influenced by executing the corresponding operation, and the time error of the operating system can be prevented from spreading. Thus, the time protection of the operating system can be effectively performed.
Drawings
In order to more clearly illustrate the technical solution of the embodiments of the present application, the drawings that are needed to be used in the embodiments of the present application will be briefly described, and it is possible for a person skilled in the art to obtain other drawings according to these drawings without inventive effort.
Figure 1 is a task execution failure timing diagram provided by one embodiment of the present application,
figure 2 is one of the flowcharts of a time protection method provided by one embodiment of the present application,
figure 3 is a schematic diagram of a time channel according to one embodiment of the present application,
figure 4 is a schematic diagram of state switching of a target task according to one embodiment of the present application,
figure 5 is a schematic diagram of a state switch for a target interrupt according to one embodiment of the present application,
figure 6 is a second flowchart of a time protection method according to an embodiment of the present application,
figure 7 is a third flowchart of a time protection method according to an embodiment of the present application,
figure 8 is a flowchart of a time protection method according to one embodiment of the present application,
figure 9 is a flowchart of a time protection method according to one embodiment of the present application,
Figure 10 is a flowchart of a time protection method according to one embodiment of the present application,
figure 11 is a schematic view of a time protection device according to an embodiment of the present application,
fig. 12 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Features and exemplary embodiments of various aspects of the present application will be described in detail below, and in order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be described in further detail below with reference to the accompanying drawings and the detailed embodiments. It should be understood that the particular embodiments described herein are meant to be illustrative of the application only and not limiting. It will be apparent to one skilled in the art that the present application may be practiced without some of these specific details. The following description of the embodiments is merely intended to provide a better understanding of the application by showing examples of the application.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises the element.
As background, in embedded operating systems, if a task or interrupt misses the deadline at runtime, a time error will be caused, and this error will propagate through the operating system, causing other normally running tasks or interrupts to miss the deadline.
However, since the deadline of a task or interrupt is generally set to be relatively broad, when a certain task or interrupt is found to miss its deadline, a time error is likely to have occurred for a while, and it is impossible to determine whether it is caused by a currently running task or interrupt or by a previously running task or interrupt.
For example, as shown in fig. 1, the execution time of the task a and the task B is too long, and at the same time, the task B starts too early, so that the normally running task C misses its deadline and a time error occurs. However, by monitoring the deadline, it can only be found that the task C missed its deadline, and it cannot be known that the task C missed the deadline because the execution time of the task a and the task B is too long, and at the same time, the task B starts too early, and it cannot be found that a time error occurs in time when the execution time of the task a is too long initially.
Based on this, the embodiment of the application provides a time protection method, and the time protection method provided by the embodiment of the application is described below.
Fig. 2 is a schematic flow chart of a time protection method according to an embodiment of the application.
As shown in fig. 2, the execution subject of the time protection method may be a time protection apparatus, and the time protection method may include the steps of:
s210, monitoring target task or target interrupt time length in the operating system,
s220, under the condition that the target duration meets the preset condition, invoking a time protection function corresponding to the target duration of the target task or the target interrupt,
s230, executing the operation indicated by the preset return value in the time protection function so as to perform time protection on the operating system.
Therefore, the target time length of the target task or the target interrupt in the operating system is monitored, and the time protection function corresponding to the target time length of the target task or the target interrupt is called under the condition that the target time length meets the preset condition, so that the operation indicated by the preset return value in the time protection function is executed, and the operating system is time-protected. Wherein the target duration includes at least one of an execution duration, a lock duration, and an interval duration. Therefore, the application can monitor the target task or the target interrupt by at least one of the execution duration, the locking duration and the interval duration, thereby being capable of timely finding when a time error occurs. In addition, any task or interrupt can be monitored in a targeted manner, so that the task or interrupt causing the time error can be determined accurately, then the corresponding operation can be executed to protect the time of the operating system, the subsequent task or interrupt can be prevented from being influenced by executing the corresponding operation, and the time error of the operating system can be prevented from spreading. Thus, the time protection of the operating system can be effectively performed.
Referring to S210, the target duration may include at least one of an execution duration, a lock duration, and an interval duration. The locking duration may be a duration of a target resource occupied by the target task or a duration of the target interrupt. The target resource may be any shared resource occupied by the target task. The target interrupt may be a class two interrupt or a global interrupt.
Referring to S220, different preset conditions may be set for different tasks or target durations of interrupts. Different preset conditions are set for the execution time, the locking time and the interval time of the same task or interrupt respectively.
Here, the target duration meeting the preset condition may indicate that a time error occurs, and thus a corresponding time protection function needs to be called.
Illustratively, the time protection function may be a hook function (ProtectionHook).
Referring to S230, different time lengths of different tasks or interrupts correspond to different time protection functions, which may differ in preset return values. Different preset return values may indicate different operations. For example, the different operations may include, but are not limited to, closing the target task, closing the target interrupt, and ignoring the time error.
Specifically, the operations indicated by the different preset return values may be set according to actual requirements. For example, if the target duration of the target task or the target interrupt satisfies the preset condition and affects the normal operation of the operating system, the operation indicated by the preset return value may be set to close the target task or close the target interrupt, and if the target duration of the target task or the target interrupt satisfies the preset condition and does not affect the normal operation of the operating system, the operation indicated by the preset return value may be set to ignore the time error.
As shown in fig. 3, in order to implement the time protection method provided by the embodiment of the present application, when designing the timing interrupt corresponding to the time protection device, the embodiment of the present application selects a timer module to implement, that is, a time protection timer 310, where the time protection timer 310 has 4 independent timing channels and 4 different interrupt sources. The timing interruption configuration of the time protection device can be set by a user, and the timing period can be selected according to the required timing precision. At the same time, the timed interrupt of the time protection device alone can occupy the highest interrupt priority of the system and can be treated as a first type of interrupt.
Wherein, 4 independent timing channels are respectively: a reference time channel 321, an execution time channel 322, an interrupt lock time channel 323, and a resource lock time channel 324. All of these 4 timing channels can be used as internal channels of the operating system and are not open to the user.
Specifically, the reference time channel 321 may be used to provide a time reference for each execution of the task and the class ii interrupt, where the task and the class ii interrupt need to record the time as a reference for calculating the interval duration.
The execution time channel 322 may be used to monitor the execution duration of a task or interrupt. Because the operating system can only execute a certain task or interrupt service function at the same time, the condition that the execution time of a plurality of tasks or interrupt service functions is monitored at the same time does not exist, and therefore the operating system can monitor the execution time of the currently executing task or interrupt by only needing one execution time channel 322. The monitored object of the execution time channel 322 is always the execution duration of the task or interrupt currently being executed.
An interrupt lockout time channel 323 may be used to lock out duration monitoring of tasks or interrupts in an operating system that shut down global interrupts or interrupts of a second type.
The resource lock time channel 324 may be used to monitor the duration of the locked resource.
Based on this, when the monitoring of any one of the 4 timing channels has a time error, the timer interrupt of the corresponding timing channel can be triggered, in the interrupt processing function, the time protection function can be triggered, the operating system can execute corresponding operations by setting a return value in the time protection function, and the operations executed by the operating system can include, but are not limited to, closing the current task, closing the current interrupt, and ignoring the time error.
In addition, the state switching of the task may be as shown in fig. 4, and the state switching of the second type interrupt may be as shown in fig. 5.
The specific process of the time protection method is described in detail below based on the above-mentioned state switching of 4 timing channels and tasks and state switching of the second class interrupt.
In some embodiments, in the case where the target time period includes an interval time period, in order to more accurately monitor the interval time period of the target task or the target interrupt, S210 may include:
in the case that the target task or the target interrupt is activated, acquiring the activation time of the target task or the target interrupt and the historical activation time of the previous time of the target task or the target interrupt,
And determining the interval duration of the target task or the target interrupt according to the activation time and the historical activation time.
Here, the reference time channel may be a timing channel for providing a time reference for each execution of a task or interruption. The interval duration may be monitored based on a reference time channel. The interval duration may refer to an interval duration during which the target task or target interrupts two adjacent executions. The current time can be recorded as the activation time when the target task or the target interrupt is activated each time, and the time when the target task or the target interrupt is activated last time, namely the historical activation time, is obtained. The historical activation time minus the current activation time can then obtain the interval duration.
Illustratively, as shown in FIG. 4, the target task being activated may refer to the target task being switched from either the suspended state 410 or the wait state 420 to the ready state 430. As shown in FIG. 5, the target interrupt being activated may refer to target interrupt occurrence 510.
Therefore, the accurate interval duration of the task or the interrupt can be calculated by accurately recording the activation time of the task or the interrupt through the reference time channel, so that the interval duration of the task or the interrupt can be monitored more accurately.
Based on this, in some embodiments, in order to effectively perform time protection, S220 may include:
And calling a time protection function corresponding to the interval duration of the target task or the target interrupt under the condition that the interval duration is smaller than the preset interval duration.
Here, if the interval duration of the task or interrupt of the high priority is too short, it may cause the task or interrupt of the low priority to miss the deadline, so the interval duration of the task or interrupt of the high priority cannot be too short. Therefore, the preset interval duration may be set to be the shortest interval duration, and of course, the specific value of the preset interval duration may be set according to the actual requirement, which is not limited herein.
Specifically, if the interval duration of the target task or the target interrupt is smaller than the preset interval duration, it may be determined that a time error occurs, and thus the time protection function may be invoked. If the interval duration of the target task or the target interrupt is not less than the preset interval duration, it can be determined that no time error occurs, so that a time protection function does not need to be called.
For example, as shown in fig. 6, each time task a or interrupt a is activated to run, i.e., switched from a suspended state or a wait state to a ready state, the reference time channel may record a time stamp according to the task identification or interrupt identification, while the time stamp may be saved as a historical activation time into the structure variable. In the reference time channel, the program calculates the interval time length of the task A or the interrupt A which activates the operation again, namely, makes a difference between the activation time recorded at this time and the historical activation time recorded at the previous time, compares the difference with the preset interval time length, does not trigger a time protection function if the difference is not smaller than the preset interval time length, indicates that no time error occurs, and triggers the time protection function if the difference is smaller than the preset interval time length, indicates that the time error occurs.
Therefore, by setting the preset interval duration, the interval duration of the task or the interrupt is monitored, and the abnormal interval duration can be found out in time, so that corresponding operation is executed in time, and time protection of an operating system is realized.
In some embodiments, in the case where the target time period includes an execution time period, in order to more accurately monitor the execution time period of the target task or the target interrupt, S210 may include:
in the case where the target task is switched from the ready state to the execution state, the execution duration of the target task is monitored through the execution time channel,
in the case of a target interrupt, the execution time of the target interrupt is monitored through an execution time channel.
Here, the execution time channel may be a timing channel for monitoring the execution duration of a task or interrupt. The execution duration may be monitored by an execution time channel.
For example, as shown in fig. 4, the monitoring of the execution duration of the target task may be initiated when the target task is switched from the ready state 430 to the execution state 440, and the execution duration of the target task may be continuously monitored while the target task is in the execution state 440. As shown in fig. 5, when the target interrupt occurs 510, monitoring of the execution duration of the target interrupt may be started, the target interrupt enters the execution 520 state after the target interrupt occurs, and during the process that the target interrupt is in the execution 520 state, the execution duration of the target interrupt may be continuously monitored.
In this way, the execution time of a task or interrupt can be monitored more accurately through the execution time channel.
In some embodiments, to conserve system resources, the method may further include:
under the condition that the target task is switched from the execution state to the ready state, the execution time of the target task is paused to be monitored, the difference value between the preset execution time of the target task and the current executed time of the target task is stored,
in the case where the target task is switched from the execution state to the suspended state or the waiting state, monitoring of the execution time period of the target task is stopped,
stopping monitoring the execution time of the target interrupt under the condition that the target interrupt is preempted by other interrupts in the execution process, storing the difference value between the preset execution time of the target interrupt and the current executed time of the target interrupt,
in the case of preempting a return and continuing to execute the target interrupt, continuing to monitor the execution duration of the target interrupt,
and under the condition that the target interrupt returns, stopping monitoring the execution duration of the target interrupt.
Specifically, as shown in fig. 4, when the target task is switched from the execution state 440 to the ready state 430, monitoring of the execution duration of the target task may be suspended, and a difference value between the preset execution duration of the target task and the current executed duration of the target task may be stored. It is also possible to stop monitoring the execution duration of the target task and reset the preset execution duration when the target task is switched from the execution state 440 to the suspended state 410 or the waiting state 420.
As shown in fig. 5, when a target interrupt is preempted 530 by other interrupt types during execution 520, monitoring of the execution duration of the target interrupt may be stopped, and the difference between the preset execution duration of the target interrupt and the current executed duration of the target interrupt may be stored. Then, while preempting back and continuing to execute 520 the target interrupt, continuing to monitor the execution duration of the target interrupt. Further, monitoring the execution duration of the target interrupt may be stopped upon the target interrupt return 540.
In this way, by suspending or stopping the monitoring of the execution duration in the process of not requiring the monitoring of the execution duration, system resources can be saved.
Based on this, in some embodiments, in order to effectively perform time protection, S220 may include:
and calling a time protection function corresponding to the execution duration of the target task or the target interrupt under the condition that the execution duration is longer than the preset execution duration.
Here, the specific value of the preset interval duration may be set according to actual requirements, which is not limited herein. If the execution time of the target task or the target interrupt is longer than the preset execution time, it can be determined that the time error occurs, so that the time protection function can be called. If the execution duration of the target task or the target interrupt is not greater than the preset execution duration, it can be determined that no time error occurs, so that the time protection function does not need to be called.
For example, time protection based on the execution duration can be divided into two cases.
First, as shown in FIG. 7, task A or interrupt A is not interrupted by a higher priority task or interrupt during execution. When the state of the task A or the interrupt A is switched from the ready state to the execution state, the program starts an execution time channel, and the preset execution time length corresponding to the task A or the interrupt A is loaded in a comparison register, when the execution time length of the task A or the interrupt A exceeds the preset execution time length, the execution time length of the task A or the interrupt A is considered to be overlong, at the moment, the interrupt of the execution time channel is triggered, a time protection function is called, and when the execution time length of the task A or the interrupt A does not exceed the preset execution time length, the execution time length of the task A or the interrupt A is considered to be normal, and the interrupt of the execution time channel is not triggered, namely the time protection function is not called.
Second, as shown in FIG. 8, task A or interrupt A is interrupted during execution by a higher priority task B or interrupt B. When the state of the task A or the interrupt A is switched from the ready state to the execution state, the program starts an execution time channel, and a preset execution time length A corresponding to the task A or the interrupt A is loaded in a comparison register, when the task A or the interrupt A being executed is interrupted by a task B or an interrupt B with higher priority, before the task or the interrupt is switched, a difference value between the preset execution time length A and the current executed time length of the task A or the interrupt A is stored, and a global array of task identifiers and interrupt identifiers can be designed in program codes for storing the difference value. Meanwhile, if the task B or the interrupt B with higher priority also needs to be time-protected based on the execution time length, the preset execution time length A loaded in the comparison register needs to be updated to the preset execution time length B corresponding to the task B or the interrupt B, and the execution time channel starts to protect the execution time of the task B or the interrupt B after the update is completed. When the execution duration of the task B or the interrupt B exceeds the preset execution duration B, the execution duration of the task B or the interrupt B is considered to be too long, the interrupt of the execution time channel is triggered, the time protection function is called, and when the execution duration of the task B or the interrupt B does not exceed the preset execution duration B, the execution duration of the task B or the interrupt B is considered to be normal, the interrupt of the execution time channel is not triggered, and the time protection function is not called.
Therefore, by setting the preset execution duration, the execution duration of the task or the interrupt is monitored, and the task or the interrupt can be found out in time when the execution duration is abnormal, so that corresponding operation is executed in time, and time protection of an operating system is realized.
In some embodiments, in the case where the target time period includes the locking time period of the target resource, in order to more accurately monitor the locking time period of the target resource, S210 may include:
and under the condition that the target resource is occupied, monitoring the locking duration of the target resource through a resource locking time channel.
Here, the lock duration of the target resource may be a blocking duration of the lock target resource. The resource lock time channel may be a timing channel for monitoring the duration of the locked resource. The locking duration of the target resource can be monitored through a resource locking time channel. The locking time of the target resource can be monitored more accurately through the resource locking time channel.
In some embodiments, in the case where the target duration includes the lock-up duration of the target interrupt, in order to more accurately monitor the lock-up duration of the target interrupt, S210 may include:
in the case where the target interrupt is locked, the lock duration of the target interrupt is monitored through the interrupt lock time channel.
Here, the lock-up period of the target interrupt may be a blocking period for suspending the target interrupt. The interrupt lockout time channel may be a timing channel for lock duration monitoring of tasks or interrupts in the operating system that shut down global interrupts or interrupts of the second type. The lock duration of the target interrupt may be monitored by interrupting the lock time channel. The locking duration of the target interrupt can be monitored more accurately through the interrupt locking time channel.
Based on this, in some embodiments, in order to effectively perform time protection, S220 may include:
and under the condition that the locking time length is longer than the preset locking time length, calling a time protection function corresponding to the locking time length of the target resource or the target interrupt.
Here, the specific value of the preset locking period may be set according to actual requirements, which is not limited herein. If the locking time length of the target resource or the target interrupt is longer than the preset locking time length, the time error can be determined to occur, and therefore the time protection function can be called. If the locking duration of the target resource or the target interrupt is not greater than the preset locking duration, it can be determined that no time error occurs, so that a time protection function does not need to be called.
For example, the time protection based on the lock-out duration of the target interrupt may be as shown in fig. 9. The interrupt locking time channel can monitor locking time based on the mark of the target interrupt, when the target interrupt calls the interrupt closing function, the program can acquire the mark of the target interrupt, acquire the preset locking time corresponding to the target interrupt according to the mark of the target interrupt, load the preset locking time into a comparison register of the interrupt locking time channel, when the locking time of the target interrupt exceeds the preset locking time, trigger the interrupt of the interrupt locking time channel, call the time protection function in the interrupt service function, when the target interrupt is released, reset the preset locking time, clear the loading value in the comparison register, and store the loading value into the global variable based on the mark of the target interrupt. If the locking duration of the target interrupt does not exceed the preset locking duration, the interrupt of the interrupt locking time channel is not triggered, and the time protection function is not called.
Illustratively, the time protection based on the lock duration of the target resource may be as shown in FIG. 10. The resource locking time channel is mainly used for monitoring locking time based on the identification of the target resource, the implementation mode is similar to the interrupt locking time, when the target task obtains the target resource, the identification of the target resource is obtained, the program can obtain the preset locking time according to the identification of the target resource, meanwhile, the preset locking time is stored in a comparison register of the resource locking time channel, when the locking time of the target resource exceeds the preset locking time, the interrupt of the resource locking time channel is triggered, a time protection function is called in an interrupt service function, when the target resource is released, the preset locking time is reset, the loading value in the comparison register is cleared, and the loading value is stored in a global variable based on the identification of the target resource. If the locking time of the target resource does not exceed the preset locking time, the interruption of the resource locking time channel is not triggered, and the time protection function is not called.
Therefore, the resource or the interrupted locking time is monitored by setting the preset locking time, and the abnormal locking time can be found in time, so that corresponding operation is executed in time, and the time protection of an operating system is realized.
Based on the same inventive concept, the embodiment of the application also provides a time protection device. The following describes the time protection device provided in the embodiment of the present application in detail with reference to fig. 11.
Fig. 11 is a schematic structural diagram of a time protection device according to an embodiment of the present application.
As shown in fig. 11, the time protection device may include:
a monitoring module 1101, configured to monitor a target duration of a target task or a target interrupt in an operating system, where the target duration includes at least one of an execution duration, a locking duration, and an interval duration, and the locking duration is a duration of a target resource occupied by the target task or a duration of the target interrupt,
a calling module 1102, configured to call a time protection function corresponding to a target task or a target duration of a target interrupt if the target duration meets a preset condition,
the execution module 1103 is configured to execute an operation indicated by a preset return value in the time protection function, so as to perform time protection on the operating system, where the operation includes closing the target task, closing the target interrupt, or ignoring the time error.
Therefore, the target duration of the target task or the target interrupt in the operating system can be monitored, and the time protection function corresponding to the target duration of the target task or the target interrupt is called under the condition that the target duration meets the preset condition, so that the operation indicated by the preset return value in the time protection function is executed, and the operating system is time-protected. Wherein the target duration includes at least one of an execution duration, a lock duration, and an interval duration. Therefore, the application can monitor the target task or the target interrupt by at least one of the execution duration, the locking duration and the interval duration, thereby being capable of timely finding when a time error occurs. In addition, any task or interrupt can be monitored in a targeted manner, so that the task or interrupt causing the time error can be determined accurately, then the corresponding operation can be executed to protect the time of the operating system, the subsequent task or interrupt can be prevented from being influenced by executing the corresponding operation, and the time error of the operating system can be prevented from spreading. Thus, the time protection of the operating system can be effectively performed.
In some embodiments, where the target duration includes an interval duration, to more accurately monitor the interval duration of the target task or target interrupt, the monitoring module 1101 may include:
An acquisition sub-module for acquiring the activation time of the target task or target interrupt and the historical activation time of the target task or target interrupt before being activated through a reference time channel in the case that the target task or target interrupt is activated, the reference time channel being a timing channel for providing a time reference for each execution of the task or interrupt,
and the determining submodule is used for determining the interval duration of the target task or the target interrupt according to the activation time and the historical activation time.
In some implementations, to effectively time-protect, the calling module 1102 may include:
the first calling sub-module is used for calling a time protection function corresponding to the interval duration of the target task or the target interrupt under the condition that the interval duration is smaller than the preset interval duration.
In some embodiments, in the case where the target time period includes an execution time period, in order to more accurately monitor the execution time period of the target task or the target interrupt, the monitoring module 1101 may include:
a first monitoring sub-module for monitoring the execution time of the target task through an execution time channel, which is a timing channel for monitoring the execution time of the task or interrupt, in the case that the target task is switched from the ready state to the execution state,
And the second monitoring submodule is used for monitoring the execution duration of the target interrupt through the execution time channel under the condition that the target interrupt occurs.
In some embodiments, to save system resources, the apparatus may further include:
a pause sub-module for pausing the execution time length of the target task and storing the difference value between the preset execution time length of the target task and the current executed time length of the target task under the condition that the target task is switched from the execution state to the ready state,
a first stopping sub-module for stopping monitoring the execution time of the target task in the condition that the target task is switched from the execution state to the suspension state or the waiting state,
a second stopping sub-module, configured to stop monitoring the execution duration of the target interrupt and store a difference between the preset execution duration of the target interrupt and the current executed duration of the target interrupt when the target interrupt is preempted by other interrupts during the execution process,
a third monitoring sub-module, configured to continuously monitor an execution duration of the target interrupt in case of preempting to return and continuously executing the target interrupt,
and the third stopping sub-module is used for stopping monitoring the execution duration of the target interrupt under the condition that the target interrupt returns.
In some implementations, to effectively time-protect, the calling module 1102 may include:
and the second calling sub-module is used for calling a time protection function corresponding to the execution duration of the target task or the target interrupt under the condition that the execution duration is longer than the preset execution duration.
In some embodiments, in the case where the target time period includes a lock time period of the target resource, in order to more accurately monitor the lock time period of the target resource, the monitoring module 1101 may include:
and the fourth monitoring submodule is used for monitoring the locking time length of the target resource through a resource locking time channel under the condition that the target resource is occupied, wherein the resource locking time channel is a timing channel used for monitoring the time length of the locking resource.
In some embodiments, in the case where the target duration includes a lock-out duration of the target interrupt, to more accurately monitor the lock-out duration of the target interrupt, the monitoring module 1101 may include:
and the fifth monitoring submodule is used for monitoring the locking duration of the target interrupt through an interrupt locking time channel under the condition that the target interrupt is locked, wherein the interrupt locking time channel is a timing channel used for monitoring the locking duration of the task or the interrupt in an operation system for closing the global interrupt or the second type of interrupt.
In some implementations, to effectively time-protect, the calling module 1102 may include:
and the third calling sub-module is used for calling a time protection function corresponding to the locking duration of the target resource or the target interrupt under the condition that the locking duration is longer than the preset locking duration.
Fig. 12 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
As shown in fig. 12, the electronic device 12 is capable of implementing a time protection method and a structure diagram of an exemplary hardware architecture of the electronic device of the time protection apparatus according to an embodiment of the present application. The electronic device may refer to an electronic device in an embodiment of the present application.
The electronic device 12 may include a processor 1201 and a memory 1202 storing computer program instructions.
In particular, the processor 1201 may include a Central Processing Unit (CPU), or an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), or may be configured as one or more integrated circuits that implement embodiments of the present application.
Memory 1202 may include mass storage for data or instructions. By way of example, and not limitation, memory 1202 may include a Hard Disk Drive (HDD), floppy Disk Drive, flash memory, optical Disk, magneto-optical Disk, magnetic tape, or universal serial bus (Universal Serial Bus, USB) Drive, or a combination of two or more of the above. Memory 1202 may include removable or non-removable (or fixed) media where appropriate. Memory 1202 may be internal or external to the integrated gateway disaster recovery device, where appropriate. In a particular embodiment, the memory 1202 is a non-volatile solid-state memory. In particular embodiments, memory 1202 may include Read Only Memory (ROM), random Access Memory (RAM), magnetic disk storage media devices, optical storage media devices, flash memory devices, electrical, optical, or other physical/tangible memory storage devices. Thus, in general, memory 1202 includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software comprising computer-executable instructions and when the software is executed (e.g., by one or more processors) it is operable to perform the operations described with reference to a method in accordance with an aspect of the application.
The processor 1201 implements any of the time protection methods of the above embodiments by reading and executing computer program instructions stored in the memory 1202.
In one example, the electronic device may also include a communication interface 1203 and a bus 1204. As shown in fig. 12, the processor 1201, the memory 1202, and the communication interface 1203 are connected to each other via a bus 1204 and perform communication with each other.
The communication interface 1203 is mainly used for implementing communication among the modules, devices, units and/or apparatuses in the embodiment of the present application.
Bus 1204 includes hardware, software, or both, that couples the components of the electronic device to one another. By way of example, and not limitation, the buses may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an infiniband interconnect, a Low Pin Count (LPC) bus, a memory bus, a micro channel architecture (MCa) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a video electronics standards association local (VLB) bus, or other suitable bus, or a combination of two or more of the above. Bus 1204 may include one or more buses, where appropriate. Although embodiments of the application have been described and illustrated with respect to a particular bus, the application contemplates any suitable bus or interconnect.
The electronic device may execute the time protection method in the embodiment of the present application, thereby implementing the time protection method and apparatus described in connection with fig. 1 to 11.
In addition, in combination with the time protection method in the above embodiment, the embodiment of the present application may be implemented by providing a computer storage medium. The computer storage medium has stored thereon computer program instructions which, when executed by a processor, implement any of the time protection methods of the above embodiments.
It should be understood that the application is not limited to the particular arrangements and instrumentality described above and shown in the drawings. For the sake of brevity, a detailed description of known methods is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method processes of the present application are not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between steps, after appreciating the spirit of the present application.
The functional blocks shown in the above-described structural block diagrams may be implemented in hardware, software, firmware, or a combination thereof. When implemented in hardware, it may be, for example, an electronic circuit, an Application Specific Integrated Circuit (ASIC), suitable firmware, a plug-in, a function card, or the like. When implemented in software, the elements of the application are the programs or code segments used to perform the required tasks. The program or code segments may be stored in a machine readable medium or transmitted over transmission media or communication links by a data signal carried in a carrier wave. A "machine-readable medium" may include any medium that can store or transfer information. Examples of machine-readable media include electronic circuitry, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio Frequency (RF) links, and the like. The code segments may be downloaded via computer networks such as the internet, intranets, etc.
It should also be noted that the exemplary embodiments mentioned in this disclosure describe some methods or systems based on a series of steps or devices. However, the present application is not limited to the order of the above-described steps, that is, the steps may be performed in the order mentioned in the embodiments, or may be performed in a different order from the order in the embodiments, or several steps may be performed simultaneously.
Aspects of the present application are described above with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions/acts specified in the flowchart and/or block diagram block or blocks. Such a processor may be, but is not limited to being, a general purpose processor, a special purpose processor, an application specific processor, or a field programmable logic circuit. It will also be understood that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware which performs the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In the foregoing, only the specific embodiments of the present application are described, and it will be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the systems, modules and units described above may refer to the corresponding processes in the foregoing method embodiments, which are not repeated herein. It should be understood that the scope of the present application is not limited thereto, and any equivalent modifications or substitutions can be easily made by those skilled in the art within the technical scope of the present application, and they should be included in the scope of the present application.

Claims (10)

1. A method of time protection, the method comprising:
monitoring a target duration of a target task or target interrupt in an operating system, wherein the target duration comprises at least one of execution duration, locking duration and interval duration, the locking duration is duration of locking target resources occupied by the target task or duration of locking the target interrupt,
under the condition that the target duration meets the preset condition, invoking a time protection function corresponding to the target duration of the target task or the target interrupt,
and executing the operation indicated by the preset return value in the time protection function to perform time protection on the operating system, wherein the operation comprises closing the target task, closing the target interrupt or ignoring a time error.
2. The method of claim 1, wherein, in the case where the target duration includes the interval duration, the monitoring the target duration of the target task or the target interrupt in the operating system includes:
in the case where the target task or target interrupt is activated, the activation time of the target task or target interrupt and the historical activation time of the target task or target interrupt that was previously activated are acquired through a reference time channel, which is a timing channel for providing a time reference for each execution of a task or interrupt,
and determining the interval duration of the target task or the target interrupt according to the activation time and the historical activation time.
3. The method according to claim 2, wherein the calling the time protection function corresponding to the target duration of the target task or the target interrupt if the target duration satisfies a preset condition includes:
and calling a time protection function corresponding to the interval duration of the target task or the target interrupt under the condition that the interval duration is smaller than the preset interval duration.
4. The method of claim 1, wherein, in the case where the target duration includes the execution duration, monitoring a target duration of a target task or a target interrupt in an operating system includes:
In the case that the target task is switched from the ready state to the execution state, monitoring the execution time length of the target task through an execution time channel, the execution time channel being a timing channel for monitoring the execution time length of a task or an interrupt,
and under the condition that the target interrupt occurs, monitoring the execution duration of the target interrupt through the execution time channel.
5. The method according to claim 4, wherein the method further comprises:
under the condition that the execution state of the target task is switched to the ready state, suspending monitoring the execution time length of the target task, storing the difference value between the preset execution time length of the target task and the current executed time length of the target task,
in the case that the target task is switched from the execution state to the suspension state or the waiting state, the monitoring of the execution time length of the target task is stopped,
stopping monitoring the execution time of the target interrupt under the condition that the target interrupt is preempted by other interrupts in the execution process, storing the difference value between the preset execution time of the target interrupt and the current executed time of the target interrupt,
in the case of preempting a return and continuing to execute the target interrupt, continuing to monitor the execution duration of the target interrupt,
And under the condition that the target interrupt returns, stopping monitoring the execution duration of the target interrupt.
6. The method according to claim 5, wherein the calling the time protection function corresponding to the target duration of the target task or the target interrupt if the target duration satisfies a preset condition includes:
and calling a time protection function corresponding to the execution duration of the target task or the target interrupt under the condition that the execution duration is longer than the preset execution duration.
7. The method of claim 1, wherein, in the case where the target duration includes a lock duration of the target resource, monitoring a target duration of a target task or target interrupt in an operating system comprises:
and under the condition that the target resource is occupied, monitoring the locking time length of the target resource through a resource locking time channel, wherein the resource locking time channel is a timing channel for monitoring the time length of the locking resource.
8. The method of claim 1, wherein, in the case where the target duration includes a lock duration of the target interrupt, monitoring a target duration of a target task or target interrupt in an operating system comprises:
And under the condition that the target interrupt is locked, monitoring the locking time length of the target interrupt through an interrupt locking time channel, wherein the interrupt locking time channel is a timing channel for monitoring the locking time length of an operation of closing a global interrupt or a second type of interrupt in an operating system by a task or interrupt.
9. The method according to claim 7 or 8, wherein the calling the time protection function corresponding to the target duration of the target task or the target interrupt if the target duration satisfies a preset condition includes:
and calling a time protection function corresponding to the locking duration of the target resource or the target interrupt under the condition that the locking duration is longer than the preset locking duration.
10. A time protection device, the device comprising:
a monitoring module, configured to monitor a target duration of a target task or a target interrupt in an operating system, where the target duration includes at least one of an execution duration, a locking duration, and an interval duration, where the locking duration is a duration of locking a target resource occupied by the target task or a duration of locking the target interrupt,
a calling module, configured to call a time protection function corresponding to the target duration of the target task or the target interrupt when the target duration meets a preset condition,
And the execution module is used for executing the operation indicated by the preset return value in the time protection function so as to perform time protection on the operating system, wherein the operation comprises closing the target task, closing the target interrupt or ignoring the time error.
CN202310896573.6A 2023-07-20 2023-07-20 Time protection method and device Pending CN116820893A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310896573.6A CN116820893A (en) 2023-07-20 2023-07-20 Time protection method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310896573.6A CN116820893A (en) 2023-07-20 2023-07-20 Time protection method and device

Publications (1)

Publication Number Publication Date
CN116820893A true CN116820893A (en) 2023-09-29

Family

ID=88122146

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310896573.6A Pending CN116820893A (en) 2023-07-20 2023-07-20 Time protection method and device

Country Status (1)

Country Link
CN (1) CN116820893A (en)

Similar Documents

Publication Publication Date Title
CN111078453B (en) Method, device, computer equipment and storage medium for automatically fusing and recovering micro-service
CN108073446B (en) Timeout prejudging method and device
CN111045810B (en) Task scheduling processing method and device
CN113010275B (en) Interrupt processing method and device
US9424104B2 (en) High performance locks
WO2019128308A1 (en) Method and apparatus for performing scheduling request
CN104391754A (en) Method and device for processing task exception
CN116820893A (en) Time protection method and device
US20170346955A1 (en) Bandwidth aware network statistics collection
CN110832459B (en) Vehicle control device
CN116360930A (en) Task processing method and device
CN114003498A (en) Software anomaly detection method and device and electronic equipment
CN113961431A (en) Service monitoring method and device
KR102358754B1 (en) Apparatus and method for controlling assertion of a trigger signal to a processing circuit
CN116450306B (en) Task scheduling method, device, equipment, storage medium and product
CN112905372A (en) Thread abnormity diagnosis method and device
CN117093249A (en) Watchdog feeding method, device, equipment and medium
US11321163B2 (en) Device and method for monitoring functional safety in integrated circuits (ICS)
CN117632614A (en) CPU core detection method and device
US20240080179A1 (en) Signal determination device, movable object, signal determination method, and computer readable storage medium
JP7120957B2 (en) semiconductor equipment
US20240007486A1 (en) Signal detection apparatus, vehicle, and method
CN112667425B (en) Method and device for processing port oscillation
JP2005293164A (en) Task monitoring system
CN116431377B (en) Watchdog circuit

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination