Stack monitoring method, device, electronic device and readable storage medium

By adding the stack wrapper application software component to the stack wrapper module, the kernel, task and interrupt service program stacks are monitored, which solves the problem of low stack monitoring efficiency, realizes automated monitoring and overflow prevention, and ensures the stable operation of the software. .

CN118312949BActive Publication Date: 2024-08-30SHANGHAI PHIGENT QIJI CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410733089.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-07
Publication Date
2024-08-30
Estimated Expiration
2044-06-07

AI Technical Summary

Technical Problem

Stack monitoring efficiency in the existing technology is low, making it difficult to detect and avoid stack overflow in time, which may lead to problems such as data loss, memory anomalies, and operating system crashes.

Method used

Add the stack wrapper application software component in the stack wrapper module, monitor the kernel stack, task stack and interrupt service routine stack, generate configuration files, obtain initialization configuration information, add runnable entities for monitoring, and adjust according to usage Configure values ​​to avoid overflow.

Benefits of technology

It realizes automated monitoring of the target stack, improves monitoring efficiency, avoids stack overflow problems in a timely manner, and ensures the normal operation of software programs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118312949B
    Figure CN118312949B
Patent Text Reader

Abstract

The embodiment of the present invention provides a stack monitoring method, device, electronic device and readable storage medium, the method comprising: adding a stack wrapper application software component in a stack wrapper module in advance; monitoring a target stack based on the stack wrapper application software component, wherein the target stack includes a kernel stack, a task stack, and an interrupt service program stack. The embodiment of the present invention monitors the target stack by adding a stack wrapper application software component in the stack wrapper module, thereby realizing automatic monitoring of the target stack, thereby improving the efficiency of target stack monitoring, and further laying a solid foundation for timely avoiding problems caused by stack overflow.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the field of automotive electronics and software technology, and in particular to a stack monitoring method, a stack monitoring device, an electronic device, and a computer-readable storage medium. Background Art

[0002] The stack is a specific storage area or register, one end of which is fixed (the bottom of the stack) and the other end is floating (the top of the stack). It is mainly used to save and restore field data and temporarily save local variables during function calls and interrupt switching.

[0003] The two most important operations in a stack are push and pop. The push operation adds an element to the top of the stack, and the pop operation is the opposite, removing an element from the top of the stack and reducing the size of the stack by 1. When the stack is full, it will overflow. The stack has a certain capacity limit. When the capacity limit is exceeded, an overflow will occur.

[0004] However, stack overflow will cause the data stored in the stack to be lost, resulting in a series of problems such as memory anomalies, program errors, and even operating system crashes. Therefore, how to monitor the stack efficiently is particularly important. Summary of the invention

[0005] The embodiments of the present invention provide a stack monitoring method, device, electronic device and computer-readable storage medium to solve the problem of low stack monitoring efficiency.

[0006] An embodiment of the present invention discloses a stack monitoring method, the method comprising:

[0007] Pre-adding a stack wrapper application software component in the stack wrapper module;

[0008] The target stack is monitored based on the stack wrapper application software component, wherein the target stack includes a kernel stack, a task stack, and an interrupt service program stack.

[0009] Optionally, before the step of adding the stack wrapper application software component in the stack wrapper module in advance, the method further comprises:

[0010] Initialize and configure the target stack in the AUTOSAR OS module in advance;

[0011] When it is detected that the initialization configuration is completed, a configuration file is generated.

[0012] Optionally, after the step of generating a configuration file when it is detected that the initialization configuration has been completed, the method further comprises:

[0013] According to the configuration file, initialization configuration information of the target stack is obtained, wherein the initialization configuration information of the target stack at least includes configuration values ​​of the target stack, a kernel list, a task list, and an interrupt service program list.

[0014] Optionally, monitoring the target stack based on the stack wrapper application software component includes:

[0015] According to project requirements, a first executable entity, a second executable entity, and a third executable entity are added to the stack wrapper application software component, wherein the first executable entity is used to monitor the kernel stack, the second executable entity is used to monitor the task stack, and the third executable entity is used to monitor the interrupt service program stack;

[0016] The kernel stack is monitored according to the first executable entity, the task stack is detected according to the second executable entity, and the interrupt service program stack is monitored according to the third executable entity.

[0017] Optionally, the stack wrapper module includes a stack wrapper monitoring output module, after the step of monitoring the target stack based on the stack wrapper application software component, comprising:

[0018] In the case where it is detected that the monitoring of the target stack has been completed, obtaining the actual value of the target stack through the stack wrapper monitoring output module;

[0019] A usage rate of the target stack is determined according to the actual value of the target stack and the configuration value of the target stack.

[0020] Optionally, after the step of determining the usage rate of the target stack according to the actual value of the target stack and the configuration value of the target stack, the method further comprises:

[0021] Pre-set target thresholds;

[0022] The configuration value of the target stack is adjusted in the AUTOSAR OS module according to the target threshold and the usage rate of the target stack.

[0023] Optionally, the stack wrapper module includes a stack wrapper monitoring configuration module, and the method further includes:

[0024] Pre-configuring a monitoring switch in the stack wrapper monitoring configuration module;

[0025] If the monitoring switch is turned on, the compiler generates a Debug version;

[0026] If the monitoring switch is in the off state, the compiler generates a Release version.

[0027] The embodiment of the present invention further discloses a stack monitoring device, the device comprising:

[0028] Creating a stack wrapper application software component module for pre-adding the stack wrapper application software component in the stack wrapper module;

[0029] The stack monitoring module is used to monitor the target stack based on the stack wrapper application software component, wherein the target stack includes a kernel stack, a task stack, and an interrupt service program stack.

[0030] Optionally, the device further comprises:

[0031] Initialization configuration module, used to initialize and configure the target stack in the AUTOSAR OS module in advance;

[0032] The configuration file generation module is used to generate a configuration file when it is detected that the initialization configuration has been completed.

[0033] Optionally, the device further comprises:

[0034] The initialization configuration information acquisition module is used to acquire the initialization configuration information of the target stack according to the configuration file, wherein the initialization configuration information of the target stack at least includes the configuration value of the target stack, the kernel list, the task list, and the interrupt service program list.

[0035] Optionally, the stack monitoring module includes:

[0036] An add executable entity submodule is used to add a first executable entity, a second executable entity, and a third executable entity in the stack wrapper application software component according to project requirements, wherein the first executable entity is used to monitor the kernel stack, the second executable entity is used to monitor the task stack, and the third executable entity is used to monitor the interrupt service program stack;

[0037] The target stack monitoring submodule is used to monitor the kernel stack according to the first executable entity, detect the task stack according to the second executable entity, and monitor the interrupt service program stack according to the third executable entity.

[0038] Optionally, the device further comprises:

[0039] A stack wrapper monitoring output module, used for obtaining an actual value of the target stack through the stack wrapper monitoring output module when it is detected that the monitoring of the target stack has been completed;

[0040] The target stack usage acquisition module is used to determine the target stack usage according to the actual value of the target stack and the configuration value of the target stack.

[0041] Optionally, the device further comprises:

[0042] A data setting module, used to pre-set a target threshold;

[0043] A control adjustment module is used to adjust the configuration value of the target stack in the AUTOSAROS module according to the target threshold and the usage rate of the target stack.

[0044] Optionally, the device further comprises:

[0045] A switch configuration module, used to pre-configure the monitoring switch in the stack wrapper monitoring configuration module;

[0046] A Debug version generation module, used for generating a Debug version by the compiler if the monitoring switch is turned on;

[0047] The Release version generation module is used for the compiler to generate a Release version if the monitoring switch is in the off state.

[0048] The embodiment of the present invention further discloses an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0049] The memory is used to store computer programs;

[0050] The processor is used to implement the method described in the embodiment of the present invention when executing the program stored in the memory.

[0051] The embodiment of the present invention further discloses a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the embodiment of the present invention.

[0052] The embodiment of the present invention further discloses a computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, enables the processors to execute the method described in the embodiment of the present invention.

[0053] The embodiments of the present invention include the following advantages:

[0054] In the embodiment of the present invention, a stack wrapper application software component is added to the stack wrapper module in advance; based on the stack wrapper application software component, the target stack is monitored, wherein the target stack includes a kernel stack, a task stack, and an interrupt service program stack. The embodiment of the present invention monitors the target stack by adding a stack wrapper application software component to the stack wrapper module, thereby realizing automatic monitoring of the target stack, thereby improving the efficiency of target stack monitoring, and further laying a solid foundation for timely avoiding problems caused by stack overflow. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 It is one of the step flow charts of a stack monitoring method provided in an embodiment of the present invention;

[0056] Figure 2 This is a second step flow chart of a stack monitoring method provided in an embodiment of the present invention;

[0057] Figure 3 This is a step flow chart of a stack monitoring method provided in an embodiment of the present invention;

[0058] Figure 4 This is a fourth step flow chart of a stack monitoring method provided in an embodiment of the present invention;

[0059] Figure 5 This is a fifth step flow chart of a stack monitoring method provided in an embodiment of the present invention;

[0060] Figure 6 This is a sixth step flow chart of a stack monitoring method provided in an embodiment of the present invention;

[0061] Figure 7 is a device block diagram of a stack monitoring device provided in an embodiment of the present invention;

[0062] Figure 8 It is a schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present invention. DETAILED DESCRIPTION

[0063] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0064] Reference Figure 1 , shows a flowchart of a stack monitoring method provided in an embodiment of the present invention, which may specifically include the following steps:

[0065] Step 101, pre-adding a stack wrapper application software component in a stack wrapper module.

[0066] It should be noted that the AUTOSAR architecture is mainly divided into three layers: application software layer (AppL), real-time runtime environment (RTE) and basic software layer (BSW). Among them, the application software layer is composed of multiple application software components (SWC), where each application software component can be understood as a .c file (and .h).

[0067] In the embodiment of the present invention, it is necessary to add a stack wrapper application software component in advance in the stack wrapper module, wherein the stack wrapper module runs on the micro control unit.

[0068] Step 102 : monitoring a target stack based on a stack wrapper application software component, wherein the target stack includes a kernel stack, a task stack, and an interrupt service routine stack.

[0069] It should be noted that, in the embodiment of the present invention, the target stack is monitored by the stack wrapper application software component, wherein the target stack includes a kernel stack, a task stack, and an interrupt service program stack.

[0070] The present invention monitors the target stack by adding a stack wrapper application software component in the stack wrapper module, thereby realizing automatic monitoring of the target stack, thereby improving the efficiency of target stack monitoring, and further laying a solid foundation for timely avoiding problems caused by stack overflow.

[0071] Further, in an embodiment of the present invention, if Figure 2 As shown, before step 101, the following steps are also included:

[0072] Step 201 : Initialize and configure the target stack in the AUTOSAR OS module in advance.

[0073] Step 202: When it is detected that the initialization configuration is completed, a configuration file is generated.

[0074] In an embodiment of the present invention, the target stack is initialized and configured in the AUTOSAR OS module, specifically, the space of the kernel stack is initialized and configured, the space of the task stack is initialized and configured, and the space of the interrupt service program stack is initialized and configured. After the initialization configuration is completed, a configuration file can be generated according to the initialization configuration of the target stack. Among them, the AUTOSAR OS module is located in the AUTOSAR architecture. It should be noted that the present application does not specifically limit the number of configuration files generated.

[0075] The present application configures the target stack in the AUTOSAR OS module and generates a configuration file, thereby achieving the technical effect of directly obtaining the initialization configuration space of the target stack through the AUTOSAR OS module.

[0076] Furthermore, in an embodiment of the present invention, after step 202, the following step is also included: according to the configuration file, obtaining the initialization configuration information of the target stack, wherein the initialization configuration information of the target stack at least includes the configuration value of the target stack, the kernel list, the task list, and the interrupt service program list.

[0077] It should be noted that in the embodiment of the present invention, after completing the initialization configuration of the target stack and generating the configuration file, further, the configuration value of the target stack, the kernel list, the task list, and the interrupt service program list can be obtained through the configuration file generated by the AUTOSAR OS module. Among them, the kernel list includes the number of kernels and the kernel IDs, and the number of kernels is related to the hardware platform. The number of kernels is different for different hardware platforms; the task list includes the number of tasks and the task IDs, wherein each kernel can run many tasks, and the number of tasks is set according to the project requirements; the interrupt service program list includes the number of interrupt service programs and the IDs of the interrupt service programs, wherein the number of interrupt service programs is set according to the hardware platform and is relatively fixed.

[0078] The present application obtains the configuration value, kernel list, task list, and interrupt service program list of the target stack through the configuration file generated by the AUTOSAR OS module, so as to separate the configuration function of the target stack, thereby achieving the technical effect that the configuration value of the target stack can be modified and the initialization configuration information of the target stack can be re-extracted only through the AUTOSAR OS module.

[0079] Further, in an embodiment of the present invention, if Figure 3 As shown, step 102 may specifically include the following steps:

[0080] Step 301, add a first executable entity, a second executable entity, and a third executable entity in the stack wrapper application software component according to project requirements, wherein the first executable entity is used to monitor the kernel stack, the second executable entity is used to monitor the task stack, and the third executable entity is used to monitor the interrupt service program stack.

[0081] It should be noted that in the AUTOSAR architecture, a Runnable is a component of an application software component that runs in a real-time runtime environment and is called when triggered by a real-time runtime environment periodic event or other event. A Runnable contains the actual running function.

[0082] In an embodiment of the present invention, in order to monitor the kernel stack according to project requirements, it is necessary to add a first executable entity for monitoring the kernel stack in the stack wrapper application software component through the stack wrapper module; in order to monitor the task stack, it is necessary to add a second executable entity for monitoring the task stack in the stack wrapper application software component; in order to monitor the interrupt service program stack, it is necessary to add a third executable entity for monitoring the interrupt service program stack in the stack wrapper application software component.

[0083] Step 302 , monitor the kernel stack according to the first executable entity, monitor the task stack according to the second executable entity, and monitor the interrupt service program stack according to the third executable entity.

[0084] It should be noted that, in an embodiment of the present invention, after completing the addition of the first executable entity, the second executable entity and the third executable entity, it is further possible to monitor the kernel stack through the first executable entity, detect the task stack through the second executable entity, and monitor the interrupt service program stack through the third executable entity.

[0085] The present invention separates the monitoring function of the target stack by adding an executable entity in a stack wrapper application software component and then monitoring the target stack through the executable entity. Since the configuration function of the target stack is implemented in the AUTOSAR OS module and the monitoring function of the target stack is implemented in the stack wrapper module, the technical purpose of decoupling the configuration function of the target stack and the monitoring function of the target stack is further achieved.

[0086] Further, in an embodiment of the present invention, if Figure 4 As shown, after step 102, the following steps are also included:

[0087] Step 401 : when it is detected that the monitoring of the target stack has been completed, the actual value of the target stack is obtained through the stack wrapper monitoring output module.

[0088] Step 402: Determine the usage rate of the target stack according to the actual value of the target stack and the configuration value of the target stack.

[0089] It should be noted that the stack wrapper module includes a stack wrapper monitoring output module, and the stack wrapper monitoring output module can directly output the actual value of the target stack, wherein the actual value of the target stack is the space actually used by the target stack.

[0090] In the embodiment of the present invention, after the monitoring of the target stack is completed, the actual value of the target stack can be directly obtained through the stack wrapper monitoring output module, and further, the usage rate of the target stack can be determined according to the obtained actual value of the target stack and the configuration value of the target stack. Wherein, the usage rate of the target stack = the actual value of the target stack ÷ the configuration value of the target stack.

[0091] The present invention obtains the actual value of the target stack and the usage rate of the target stack through the stack wrapper monitoring output module, thereby realizing the monitoring of the target stack, and further discovering the stack overflow problem in advance through the usage rate of the target stack, laying the foundation for further avoiding the problems caused by the stack overflow.

[0092] Further, in an embodiment of the present invention, if Figure 5 As shown, after step 402, the following steps are also included:

[0093] Step 501, pre-set the target threshold.

[0094] Step 502: According to the target threshold and the usage rate of the target stack, the configuration value of the target stack is adjusted in the AUTOSAR OS module.

[0095] It should be noted that the target threshold is set in advance, and the target threshold is a target threshold of the stack usage rate set according to project requirements.

[0096] In the embodiment of the present invention, the configuration value of the target stack is adjusted in the AUTOSAR OS module according to the preset target threshold and the usage rate of the target stack obtained. For example, the target threshold is 50%, the actual value of the target stack is 1500K, and the configuration value of the target stack is 2000K. According to the usage rate of the target stack = the actual value of the target stack ÷ the configuration value of the target stack, the usage rate of the target stack is 75%. In order to make the usage rate of the target stack reach the preset target threshold of 50%, the configuration value of the target stack should be adjusted from 2000K to 3000K.

[0097] The present invention adjusts the configuration value of the target stack according to the target threshold and the usage rate of the target stack, thereby avoiding the occurrence of stack overflow. Further, the problem caused by the stack overflow is avoided in time, achieving the technical effect of ensuring the normal operation of the software program.

[0098] Further, in an embodiment of the present invention, if Figure 6 As shown, the method also includes:

[0099] Step 601, pre-configure the monitoring switch in the stack wrapper monitoring configuration module.

[0100] Step 602: If the monitoring switch is turned on, the compiler generates a Debug version.

[0101] Step 603: If the monitored switch is in the off state, the compiler generates a Release version.

[0102] It should be noted that Debug means debugging. The Debug version is created for debugging. When the compiler generates the Debug version of the program, it will add debugging auxiliary information and rarely optimize it. The program remains original. Release means release. The Release version is the program that is finally handed over to the user. The compiler will do its best to optimize it. The compiler will also try to reduce the size of the Release version and remove all useless data, including debugging information, to improve execution efficiency.

[0103] In the embodiment of the present invention, the stack wrapper module includes a stack wrapper monitoring configuration module. The monitoring switch is configured in advance in the stack wrapper monitoring configuration module. If it is convenient for programmers to develop and debug, the monitoring switch is set to on, and the compiler will generate a Debug version; if it is to finally hand over the program to the user, the monitoring switch is set to off, and the compiler will generate a Release version.

[0104] The present invention can realize free control of the program output version by setting the monitoring switch. By setting the monitoring switch to on, the technical effect of facilitating programmer development and debugging can be achieved; by setting the monitoring switch to off, the additional burden of program operation can be reduced, and further, the technical effect of improving program operation efficiency can be achieved.

[0105] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0106] Reference Figure 7 , shows a device block diagram of a stack monitoring device provided in an embodiment of the present invention, which may specifically include the following modules:

[0107] Create a stack wrapper application software component module 701, used to add a stack wrapper application software component in the stack wrapper module in advance;

[0108] The stack monitoring module 702 is used to monitor the target stack based on the stack wrapper application software component, wherein the target stack includes a kernel stack, a task stack, and an interrupt service program stack.

[0109] In an exemplary embodiment, the apparatus further comprises:

[0110] Initialization configuration module, used to initialize and configure the target stack in the AUTOSAR OS module in advance;

[0111] The configuration file generation module is used to generate a configuration file when it is detected that the initialization configuration has been completed.

[0112] In an exemplary embodiment, the apparatus further comprises:

[0113] The initialization configuration information acquisition module is used to acquire the initialization configuration information of the target stack according to the configuration file, wherein the initialization configuration information of the target stack at least includes the configuration value of the target stack, the kernel list, the task list, and the interrupt service program list.

[0114] In an exemplary embodiment, a stack monitoring module includes:

[0115] An add executable entity submodule is used to add a first executable entity, a second executable entity, and a third executable entity in the stack wrapper application software component according to project requirements, wherein the first executable entity is used to monitor the kernel stack, the second executable entity is used to monitor the task stack, and the third executable entity is used to monitor the interrupt service program stack;

[0116] The target stack monitoring submodule is used to monitor the kernel stack according to the first executable entity, detect the task stack according to the second executable entity, and monitor the interrupt service program stack according to the third executable entity.

[0117] In an exemplary embodiment, the apparatus further comprises:

[0118] The stack wrapper monitoring output module is used to obtain the actual value of the target stack through the stack wrapper monitoring output module when it is detected that the monitoring of the target stack has been completed;

[0119] The target stack usage acquisition module is used to determine the target stack usage according to the actual value of the target stack and the configuration value of the target stack.

[0120] In an exemplary embodiment, the apparatus further comprises:

[0121] A data setting module, used to pre-set a target threshold;

[0122] The control adjustment module is used to adjust the configuration value of the target stack in the AUTOSAR OS module according to the target threshold and the usage rate of the target stack.

[0123] In an exemplary embodiment, the apparatus further comprises:

[0124] A switch configuration module, used to configure the monitored switch in the stack wrapper monitoring configuration module in advance;

[0125] The Debug version generation module is used to generate the Debug version of the compiler if the monitoring switch is turned on;

[0126] The Release version generation module is used to generate the Release version when the monitoring switch is off.

[0127] The embodiment of the present invention monitors the target stack by adding a stack wrapper application software component in the stack wrapper module, thereby realizing the automatic monitoring of the target stack, thereby improving the efficiency of the target stack monitoring, and further laying a solid foundation for timely avoiding problems caused by stack overflow; the present application configures the target stack in the AUTOSAROS module and generates a configuration file, thereby achieving the technical effect that the initialization configuration space of the target stack can be directly obtained through the AUTOSAR OS module; the present application obtains the configuration value, kernel list, task list, and interrupt service program list of the target stack through the configuration file generated by the AUTOSAR OS module, so as to separate the configuration function of the target stack, thereby achieving the technical effect that the configuration value of the target stack can be modified and the initialization configuration information of the target stack can be re-extracted only through the AUTOSAR OS module; the present invention adds an executable entity in the stack wrapper application software component, and then monitors the target stack through the executable entity, thereby realizing the separation of the monitoring function of the target stack, because the configuration function of the target stack is in the AUTOSAR The target stack is implemented in the OS module, and the monitoring function of the target stack is implemented in the stack wrapper module. Further, the technical purpose of decoupling the configuration function of the target stack and the monitoring function of the target stack is achieved; the present invention obtains the actual value of the target stack and the usage rate of the target stack through the stack wrapper monitoring output module, realizes the monitoring of the target stack, and then the stack overflow problem can be discovered in advance through the usage rate of the target stack; the present invention adjusts the configuration value of the target stack according to the target threshold and the usage rate of the target stack, and then the stack overflow situation can be avoided. Further, the problem caused by the stack overflow is avoided in time, and the technical effect of ensuring the normal operation of the software program is achieved; the present invention can realize the free control of the program output version by setting the monitoring switch. By setting the monitoring switch to open, the technical effect of facilitating programmer development and debugging can be achieved; by setting the monitoring switch to close, the additional burden of program operation can be reduced, and further, the technical effect of improving program operation efficiency can be achieved.

[0128] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0129] In addition, an embodiment of the present invention further provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned stack monitoring method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0130] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the above stack monitoring embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0131] An embodiment of the present invention also provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the various processes of the above-mentioned stack monitoring method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0132] Figure 8 A schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present invention.

[0133] The electronic device 800 includes but is not limited to: a radio frequency unit 801, a network module 802, an audio output unit 803, an input unit 804, a sensor 805, a display unit 806, a user input unit 807, an interface unit 808, a memory 809, a processor 810, and a power supply 811. Those skilled in the art will appreciate that Figure 8 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and the electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. In the embodiments of the present invention, the electronic device includes but is not limited to a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted terminal, a wearable device, and a pedometer.

[0134] It should be understood that in the embodiment of the present invention, the radio frequency unit 801 can be used for receiving and sending signals during information transmission or communication. Specifically, after receiving downlink data from the base station, it is sent to the processor 810 for processing; in addition, uplink data is sent to the base station. Generally, the radio frequency unit 801 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier, a duplexer, etc. In addition, the radio frequency unit 801 can also communicate with the network and other devices through a wireless communication system.

[0135] The electronic device provides users with wireless broadband Internet access through the network module 802, such as helping users to send and receive emails, browse web pages, and access streaming media.

[0136] The audio output unit 803 can convert the audio data received by the RF unit 801 or the network module 802 or stored in the memory 809 into an audio signal and output it as sound. Moreover, the audio output unit 803 can also provide audio output related to a specific function performed by the electronic device 800 (for example, a call signal reception sound, a message reception sound, etc.). The audio output unit 803 includes a speaker, a buzzer, a receiver, etc.

[0137] The input unit 804 is used to receive audio or video signals. The input unit 804 may include a graphics processor (GPU) 8041 and a microphone 8042. The graphics processor 8041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The processed image frame can be displayed on the display unit 806. The image frame processed by the graphics processor 8041 can be stored in the memory 809 (or other storage medium) or sent via the radio frequency unit 801 or the network module 802. The microphone 8042 can receive sound and can process such sound into audio data. The processed audio data can be converted into a format output that can be sent to a mobile communication base station via the radio frequency unit 801 in the case of a telephone call mode.

[0138] The electronic device 800 also includes at least one sensor 805, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor and a proximity sensor, wherein the ambient light sensor can adjust the brightness of the display panel 8061 according to the brightness of the ambient light, and the proximity sensor can turn off the display panel 8061 and / or the backlight when the electronic device 800 is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary, which can be used to identify the posture of the electronic device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; the sensor 805 can also include a fingerprint sensor, a pressure sensor, an iris sensor, a molecular sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be repeated here.

[0139] The display unit 806 is used to display information input by the user or information provided to the user. The display unit 806 may include a display panel 8061, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.

[0140] The user input unit 807 can be used to receive input digital or character information, and generate key signal input related to user settings and function control of the electronic device. Specifically, the user input unit 807 includes a touch panel 8071 and other input devices 8072. The touch panel 8071, also known as a touch screen, can collect user touch operations on or near it (such as operations performed by users using fingers, styluses, or any other suitable objects or accessories on or near the touch panel 8071). The touch panel 8071 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact point coordinates, and then sends it to the processor 810, receives the command sent by the processor 810 and executes it. In addition, the touch panel 8071 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch panel 8071, the user input unit 807 may also include other input devices 8072. Specifically, other input devices 8072 may include but are not limited to a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be described in detail here.

[0141] Furthermore, the touch panel 8071 may be overlaid on the display panel 8061. When the touch panel 8071 detects a touch operation on or near it, it transmits the information to the processor 810 to determine the type of the touch event. Then, the processor 810 provides a corresponding visual output on the display panel 8061 according to the type of the touch event. Figure 8 In the figure, the touch panel 8071 and the display panel 8061 are used as two independent components to realize the input and output functions of the electronic device. However, in some embodiments, the touch panel 8071 and the display panel 8061 can be integrated to realize the input and output functions of the electronic device, which is not limited here.

[0142] The interface unit 808 is an interface for connecting an external device to the electronic device 800. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device with an identification module, an audio input / output (I / O) port, a video I / O port, a headphone port, etc. The interface unit 808 may be used to receive input (e.g., data information, power, etc.) from an external device and transmit the received input to one or more elements within the electronic device 800 or may be used to transmit data between the electronic device 800 and an external device.

[0143] The memory 809 can be used to store software programs and various data. The memory 809 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 809 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0144] The processor 810 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 809 and calling data stored in the memory 809, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. The processor 810 may include one or more processing units; preferably, the processor 810 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 810.

[0145] The electronic device 800 may also include a power source 811 (such as a battery) for supplying power to various components. Preferably, the power source 811 may be logically connected to the processor 810 through a power management system, thereby implementing functions such as charging, discharging, and power consumption management through the power management system.

[0146] In addition, the electronic device 800 includes some functional modules not shown, which will not be described in detail here.

[0147] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0148] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0149] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.

[0150] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the embodiments of the present invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0151] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0152] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0153] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0154] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0155] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, or optical disks.

[0156] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A stack monitoring method, characterized in that: The method comprises: Initialize and configure the target stack in the AUTOSAR OS module in advance; When it is detected that the initialization configuration has been completed, generating a configuration file; According to the configuration file, initialization configuration information of the target stack is obtained, wherein the initialization configuration information of the target stack at least includes a configuration value of the target stack, a kernel list, a task list, and an interrupt service program list, the kernel list includes the number of kernels and kernel IDs, the task list includes the number of tasks and task IDs, the interrupt service program list includes the number of interrupt service programs and interrupt service program IDs, the number of kernels is determined based on the hardware platform, each kernel runs multiple tasks, the number of tasks is set based on project requirements, and the number of interrupt service programs is pre-set based on the hardware platform; The AUTOSAR OS module is used to modify the configuration file and re-extract the initialization configuration information of the target stack based on the modified configuration file; Pre-adding a stack wrapper application software component in a stack wrapper module, the stack wrapper module running on the micro control unit; The target stack is monitored based on the stack wrapper application software component, wherein the target stack includes a kernel stack, a task stack, and an interrupt service program stack.

2. The method according to claim 1, characterized in that: The monitoring of the target stack based on the stack wrapper application software component includes: According to project requirements, a first executable entity, a second executable entity, and a third executable entity are added to the stack wrapper application software component, wherein the first executable entity is used to monitor the kernel stack, the second executable entity is used to monitor the task stack, and the third executable entity is used to monitor the interrupt service program stack; The kernel stack is monitored according to the first executable entity, the task stack is detected according to the second executable entity, and the interrupt service program stack is monitored according to the third executable entity.

3. The method according to claim 1, characterized in that The stack wrapper module includes a stack wrapper monitoring output module, after the step of monitoring the target stack based on the stack wrapper application software component, including: In the case where it is detected that the monitoring of the target stack has been completed, obtaining the actual value of the target stack through the stack wrapper monitoring output module; The usage rate of the target stack is determined according to the actual value of the target stack and the configuration value of the target stack.

4. The method according to claim 3, characterized in that After the step of determining the usage rate of the target stack according to the actual value of the target stack and the configuration value of the target stack, the method further comprises: Pre-set target thresholds; The configuration value of the target stack is adjusted in the AUTOSAR OS module according to the target threshold and the usage rate of the target stack.

5. The method according to claim 1, characterized in that The stack wrapper module includes a stack wrapper monitoring configuration module, and the method further includes: Pre-configuring a monitoring switch in the stack wrapper monitoring configuration module; If the monitoring switch is turned on, the compiler generates a Debug version; If the monitoring switch is in the off state, the compiler generates a Release version.

6. A stack monitoring device, characterized in that: The device comprises: Initialization configuration module, used to initialize and configure the target stack in the AUTOSAR OS module in advance; A configuration file generating module, used to generate a configuration file when it is detected that the initialization configuration has been completed; an initialization configuration information acquisition module, configured to acquire the initialization configuration information of the target stack according to the configuration file, wherein the initialization configuration information of the target stack at least includes the configuration value of the target stack, a kernel list, a task list, and an interrupt service program list, wherein the kernel list includes the number of kernels and kernel IDs, the task list includes the number of tasks and task IDs, the interrupt service program list includes the number of interrupt service programs and interrupt service program IDs, the number of kernels is determined based on the hardware platform, each kernel runs multiple tasks, the number of tasks is set based on project requirements, and the number of interrupt service programs is pre-set based on the hardware platform; the AUTOSAR OS module is configured to modify the configuration file; Creating a stack wrapper application software component module for pre-adding a stack wrapper application software component in a stack wrapper module, wherein the stack wrapper module runs on a micro control unit; The stack monitoring module is used to monitor the target stack based on the stack wrapper application software component, wherein the target stack includes a kernel stack, a task stack, and an interrupt service program stack.

7. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor is used to implement the method according to any one of claims 1 to 5 when executing the program stored in the memory.

8. A computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, cause the processors to perform the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Stack monitoring method and device, electronic equipment and storage medium

    CN111506472A

  • Stack detection method and device, multi-core processor and computing equipment

    CN117251343A