CN115757039A - Program monitoring method and device, electronic equipment and storage medium - Google Patents
Program monitoring method and device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN115757039A CN115757039A CN202211492584.XA CN202211492584A CN115757039A CN 115757039 A CN115757039 A CN 115757039A CN 202211492584 A CN202211492584 A CN 202211492584A CN 115757039 A CN115757039 A CN 115757039A
- Authority
- CN
- China
- Prior art keywords
- atomic
- variable
- atomic variable
- program
- preset
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 114
- 238000012545 processing Methods 0.000 claims abstract description 48
- 238000012544 monitoring process Methods 0.000 claims description 43
- 238000004590 computer program Methods 0.000 claims description 16
- 230000004044 response Effects 0.000 claims 1
- 230000008569 process Effects 0.000 abstract description 51
- 238000004891 communication Methods 0.000 abstract description 46
- 238000011084 recovery Methods 0.000 abstract description 10
- 238000010586 diagram Methods 0.000 description 11
- 230000006870 function Effects 0.000 description 11
- 238000004806 packaging method and process Methods 0.000 description 6
- 238000005457 optimization Methods 0.000 description 5
- 238000007726 management method Methods 0.000 description 4
- 238000005516 engineering process Methods 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 230000004913 activation Effects 0.000 description 2
- 230000003993 interaction Effects 0.000 description 2
- 238000013507 mapping Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000002159 abnormal effect Effects 0.000 description 1
- 238000003491 array Methods 0.000 description 1
- 238000013473 artificial intelligence Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 230000000295 complement effect Effects 0.000 description 1
- 238000004883 computer application Methods 0.000 description 1
- 125000004122 cyclic group Chemical group 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000001514 detection method Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000005538 encapsulation Methods 0.000 description 1
- 238000000605 extraction Methods 0.000 description 1
- 239000012530 fluid Substances 0.000 description 1
- 239000011521 glass Substances 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000010801 machine learning Methods 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 230000001953 sensory effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Quality & Reliability (AREA)
- Software Systems (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention discloses a program monitoring method, a program monitoring device, electronic equipment and a storage medium. Wherein, the method comprises the following steps: processing message information of a target monitoring program into an atomic variable according to a preset configuration file, storing the atomic variable based on a preset shared space, and executing message processing according to the atomic variable in the preset shared space. The embodiment of the invention realizes lock-free communication through reading and writing the atomic variable and stores the atomic variable containing data and state in the shared space, thereby reducing the expenditure of system resources, reducing the communication time delay, supporting the lossless recovery of the previous data and state after the service process is crashed and restarted, and having higher reliability.
Description
Technical Field
The present invention relates to the field of computer application technologies, and in particular, to a program monitoring method and apparatus, an electronic device, and a storage medium.
Background
The program monitoring technology, as an important technology for the safety development of the automobile software function, mainly comprises the following three functions: the method comprises the steps of active point detection (whether a monitoring program operates normally), dead time monitoring (whether the monitoring program completes execution within a specified time), and logic sequence monitoring (whether each program segment operates according to a preset time sequence). In the existing program monitoring method, generally, a monitored process periodically sends heartbeat data (such as time, process number, program number, state and the like) to a service process, and then the service process performs preset logic judgment to judge whether problems such as an active point timeout error, an end time timeout error, a logic sequence error and the like exist, and performs corresponding error processing when an error occurs.
However, the existing program monitoring method has the following problems:
1. the existing program monitoring method mainly uses Unix Domain Sockets (UDS) and shared Memory (SHMEM) to perform inter-process communication, and both the two communication modes are locked communication, which may increase system resource overhead and communication delay.
2. The heartbeat data sent by the monitored process has no state, and the state data is stored in the service process, which may cause: if the service process crashes and exits, the state data of the monitored process is lost, hot switching and lossless recovery cannot be realized, and the reliability is low.
Disclosure of Invention
The invention provides a program monitoring method, a program monitoring device, electronic equipment and a storage medium, which are used for changing locked communication into non-locked communication through atomic variable reading and writing, reducing the expenditure of system resources and communication time delay, and simultaneously, by storing the atomic variable containing data and state in a shared space, the method can support the lossless recovery of the previous data and state after a service process is crashed and restarted, and has higher reliability.
According to an aspect of the present invention, there is provided a program monitoring method, wherein the method includes:
processing message information of a target monitoring program into an atomic variable according to a preset configuration file;
saving an atomic variable based on a preset shared space;
and executing message processing according to the atom variable in the preset shared space.
According to another aspect of the present invention, there is provided a program monitor generating apparatus including:
the variable generation module is used for processing the message information of the target monitoring program into an atomic variable according to a preset configuration file;
the variable temporary storage module is used for storing the atomic variables based on a preset shared space;
and the message processing module is used for executing message processing according to the atom variable in the preset shared space.
According to another aspect of the present invention, there is provided an electronic apparatus including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to enable the at least one processor to perform the program monitoring method according to any of the embodiments of the invention.
According to another aspect of the present invention, there is provided a computer-readable storage medium storing computer instructions for causing a processor to implement a program monitoring method according to any one of the embodiments of the present invention when the computer instructions are executed.
According to the technical scheme of the embodiment of the invention, the message information of the target monitoring program is processed into the atomic variable according to the preset configuration file, the atomic variable is stored based on the preset shared space, and the message processing is executed according to the atomic variable in the preset shared space. The embodiment of the invention realizes lock-free communication through reading and writing the atomic variable and stores the atomic variable containing data and state in the shared space, thereby reducing the expenditure of system resources, reducing the communication time delay, supporting the lossless recovery of the previous data and state after the service process is crashed and restarted, and having higher reliability.
It should be understood that the statements in this section do not necessarily identify key or critical features of the embodiments of the present invention, nor do they necessarily limit the scope of the invention. Other features of the present invention will become apparent from the following description.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a flowchart of a program monitoring method according to an embodiment of the present invention;
FIG. 2 is a flowchart of a program monitoring method according to a second embodiment of the present invention;
FIG. 3 is a flowchart of a program monitoring method according to a third embodiment of the present invention;
FIG. 4 is a diagram illustrating an exemplary structure of a program monitoring system according to a third embodiment of the present invention;
FIG. 5 is a diagram illustrating an example of a data structure of an atomic variable according to another embodiment of the present invention;
FIG. 6 is a flowchart illustrating a data state process according to a third embodiment of the present invention;
FIG. 7 is an exemplary diagram of pseudo-sharing of CPU Cache according to a third embodiment of the present invention;
FIG. 8 is a diagram illustrating a flow of cache optimization according to a third embodiment of the present invention;
fig. 9 is a schematic structural diagram of a program monitoring apparatus according to a fourth embodiment of the present invention;
fig. 10 is a schematic structural diagram of an electronic device implementing the program monitoring method according to the embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example one
Fig. 1 is a flowchart of a program monitoring method according to an embodiment of the present invention, where the present embodiment is applicable to monitoring a target monitoring program, and the method may be executed by a program monitoring device, where the program monitoring device may be implemented in a form of hardware and/or software, and the program monitoring device may be configured in an electronic device, for example, the electronic device may include a vehicle-mounted device, a mobile device, and the like. As shown in fig. 1, a program monitoring method provided in this embodiment specifically includes the following steps:
and S110, processing the message information of the target monitoring program into an atomic variable according to a preset configuration file.
In the embodiment of the present invention, the preset configuration file may be understood as a file configured for the target monitoring program, and the preset configuration file may include parameters such as a task number, a program number, a dependency relationship between the program and the program, time consumed by the program itself, time consumed by the entire task, and heartbeat time of the task. The target monitoring program may be understood as a program segment to be monitored, which may comprise one or more program segments of the task to be monitored. The message information may be understood as a message containing monitoring data and monitoring status of the target monitoring program, and the message information may include running time, task number, program number, timeout error status, timing error status, and the like of the target monitoring program. The atomic variable can be understood as an integer data variable in multi-thread lock-free communication, the operation performed on the atomic variable is an atomic operation, the atomic operation refers to an operation which is not interrupted by a thread scheduling mechanism, once the operation is started, the operation is not interrupted by any other task or event before the execution is finished, and the lock-free communication can be changed into lock-free communication through the atomic variable operation, so that the communication delay is reduced.
Specifically, the message information of the target monitoring program may be determined according to configuration items in a preset configuration file, where the preset configuration file may include, but is not limited to, one of the following parameter information: the method comprises the following steps of processing information into an atomic variable, wherein the processing process comprises but is not limited to the following modes: the method comprises the steps of packaging message information into corresponding atom variables by calling some Application Program Interface (API) function libraries, packaging the message information into corresponding atom variables by calling some self-defined or third-party atom variable operation toolkits, and the like. In one embodiment, a preset configuration file containing parameters such as a task number, a program number, a pre-and-post dependency relationship of a program and the like can be started and loaded, a target monitoring program can be run, message information containing monitoring data and monitoring states of the program can be packaged into corresponding atomic variables through some API interface function libraries or atomic variable operation toolkits after the target monitoring program is run or at preset intervals.
And S120, saving the atomic variable based on the preset shared space.
In the embodiment of the present invention, the preset shared space may be understood as a data storage space for storing the atomic variable, and the preset shared space may include at least a cache and a shared memory.
Specifically, after the message information of the target monitoring program is processed into the atomic variable, the atomic variable may be saved to a corresponding location of a preset shared space, where the preset shared space may include at least a cache and a shared memory, a pointer or a memory address may be allocated to the atomic variable during the compilation, the atomic variable may be saved according to a data type of the atomic variable, and the atomic variable may be stored in the shared memory in an original code or a complementary code of the atomic variable. In one embodiment, the preset shared space may include a cache and a shared memory, and when the atomic variable is stored, if the atomic variable still exists in the cache, the atomic variable may be preferentially stored in the cache; if the atomic variable is not present in the cache, the atomic variable may be saved to shared memory.
And S130, executing message processing according to the atom variable in the preset shared space.
In the embodiment of the present invention, the message processing may be understood as a processing method of message information for the target monitoring program, and the message processing may include message reading, timeout error processing, timing error processing, data state updating, and the like.
Specifically, some message processing may be performed on the atomic variables stored in the preset shared space, and the message processing procedure may include, but is not limited to, several types: reading an atomic variable in a preset shared space, and analyzing state information of a target monitoring program from the atomic variable; judging whether the program has overtime errors or time sequence errors, if so, reporting fault information such as corresponding fault codes and fault reasons to background management personnel or a functional safety management module to process the program error state; and after the program error state is processed, clearing the error state of the current target monitoring program, and updating the atom variable in the preset shared space.
According to the technical scheme of the embodiment of the invention, the message information of the target monitoring program is processed into the atomic variable according to the preset configuration file, the atomic variable is stored based on the preset shared space, and the message processing is executed according to the atomic variable in the preset shared space. The embodiment of the invention realizes lock-free communication through reading and writing the atomic variable and stores the atomic variable containing data and state in the shared space, thereby reducing the expenditure of system resources, reducing the communication time delay, supporting the lossless recovery of the previous data and state after the service process is crashed and restarted, and having higher reliability.
Further, on the basis of the above inventive embodiments, the atomic variables include at least one of: time identification field, state identification field, sequence number field, task identification field and check code field.
In the embodiment of the present invention, the time identification field may be understood as a field for characterizing the running time of the target monitoring program, and the time identification field may be calculated from 0, and the unit may be 10 microseconds. The state identification field may be understood as a field for characterizing the state information of the target monitoring program, and may include whether an out-of-order error exists, whether a timeout error exists, whether the target monitoring program is in an active state, and the like. The sequence number field may be understood as a field for characterizing a program number. The task identification field can be understood as a field for characterizing the task number. The check code field may be understood as a field for characterizing the validity check, and the check code type may include parity check code, hamming check code, cyclic redundancy check code, and the like.
Example two
Fig. 2 is a flowchart of a program monitoring method provided in the second embodiment of the present invention, which is further optimized and expanded based on the foregoing embodiment, and can be combined with various optional technical solutions in the foregoing embodiment. As shown in fig. 2, the program monitoring method provided in the second embodiment specifically includes the following steps:
s210, searching a data identifier and a state identifier corresponding to the message information in a preset configuration file.
In the embodiment of the present invention, the data identifier may be understood as data information included in the message information, and the data identifier may include information such as a program number, a task number, and a check code. The state identifier may be understood as state information contained in the message information, and the state identifier may include a timing error state, a timeout error state, a start state, an activation state, and the like.
Specifically, the data identifier and the state identifier corresponding to the message information of the target monitoring program may be searched according to configuration information such as a task number and a program number in a preset configuration file, where the data representation may include but is not limited to: program number, task number and check code; the state representation may include, but is not limited to: a sequential error state, a timeout error state, a start state, an active state.
And S220, calling a preset monitoring library to package the data identifier and the state identifier into an atomic variable.
In the embodiment of the present invention, the preset monitoring library may be understood as an API interface function library for implementing atomic variable encapsulation, and the preset monitoring library may include atomic operation API functions provided by C + +, and the like.
Specifically, the message information including the data identifier and the state identifier may be encapsulated into an atomic variable by calling a preset monitoring library, where the preset monitoring library may include, but is not limited to: the method comprises the following steps of C + + -provided atomic operation API functions, java-provided Java-output-current-atomic operation API functions and a self-defined atomic variable packaging library, further, according to actual needs, allocating different Bit bits and Bit sizes to data identifications and state identifications, and packaging the data identifications and the state identifications into atomic variables of corresponding data types by utilizing the API functions such as atomic _ int64_ t and the like.
Further, on the basis of the embodiment of the present invention, the preset shared space at least includes a cache and a shared memory.
In the embodiment of the invention, the Cache can be a CPU Cache (Cache), which is a storage with smaller capacity but higher speed between the CPU and a main memory, because the speed of the CPU is far higher than that of the main memory, the CPU directly accesses data from the memory and waits for a certain time period, the Cache stores a part of data which is just used or recycled by the CPU, and when the CPU uses the part of data again, the CPU can be directly called from the Cache, thereby reducing the waiting time of the CPU and improving the efficiency of data reading and writing. Shared memory is understood to be a large-capacity memory that can be accessed by different processes in interprocess communication, i.e. different processes can share and interact data by accessing the same internal memory area (i.e. shared memory). Each process can map its own virtual address to a specific region in the physical memory, and when different processes associate the same physical memory region with their respective virtual address spaces, the processes can implement inter-process communication by sharing the memory. If a process changes the contents of the shared memory area, other processes will perceive the change in the area.
And S230, judging whether an atomic variable exists in a cache in the preset shared space.
Specifically, according to a pointer or a memory address corresponding to an atomic variable, whether a Cache is hit or not can be determined by adopting a direct mapping mode, a full-link Cache mode, a group link Cache mode and the like according to whether an effective bit of corresponding storage data in a Cache line is 0 or 1, and then whether the atomic variable exists in the Cache is determined.
S240, if the atomic variable exists, storing the atomic variable into a cache; and if the atomic variable does not exist, storing the atomic variable into a shared memory, wherein the shared memory at least comprises a heartbeat monitoring sequence and a time sequence monitoring sequence.
In the embodiment of the present invention, the heartbeat monitoring sequence is understood to be used for storing an atomic variable including heartbeat data of the target monitoring program, and the heartbeat monitoring sequence may include one or more atomic variables characterizing the heartbeat data of the target monitoring program. The time-series monitoring sequence may be understood as an atomic variable for storing time-series data including the target monitoring program, and the time-series monitoring sequence may include one or more atomic variables characterizing the time-series data of the target monitoring program.
Specifically, if an atomic variable exists in a Cache in the preset shared space, the atomic variable may be stored in the Cache by using a direct mapping mode, a fully-connected Cache mode, a group-connected Cache mode, and the like according to a corresponding pointer or a memory address of the atomic variable; if the atomic variable does not exist in the shared memory, the atomic variable can be stored to a corresponding storage position in the shared memory according to a pointer or a memory address corresponding to the atomic variable, wherein the shared memory at least comprises a heartbeat monitoring sequence and a time sequence monitoring sequence; further, the heartbeat monitoring sequence and the time sequence monitoring sequence may be respectively located in two independent message queues, and the message queue types may include an ActiveMQ message queue, a RabbitMQ message queue, a ZeroMQ message queue, a Kafka message queue, and the like, which is not limited by the embodiment of the present invention.
And S250, judging whether an atomic variable exists in a cache in the preset shared space.
S260, if the atomic variable exists, reading the atomic variable in the cache until the cache is empty; and if not, reading the atomic variable of the shared memory in the preset shared space.
Specifically, if an atomic variable exists in the cache in the preset shared space, the atomic variable in the cache can be preferentially read according to a pointer or a memory address corresponding to the atomic variable; if not, the atomic variables in the shared memory can be read.
S270, extracting the state identification and the data identification of the atomic variable, and executing message processing corresponding to the state identification and the data identification.
Specifically, data identifiers such as a task number, a program number, and a check code, and state identifiers such as a timing error state and a timeout error state may be extracted from the read atomic variables, and the specific extraction manner may include, but is not limited to: the method comprises the steps of extracting a state identifier and a data identifier in an atomic variable according to an atomic variable packaging principle, analyzing and acquiring field information contained in the atomic variable, judging the state of a current target monitoring program according to the state identifier and the data identifier, reporting fault information such as fault codes and fault reasons to a background manager or a functional safety management module for program error state processing if overtime errors or time sequence errors occur, and clearing the error state of the current target monitoring program after the program error state processing, for example, resetting a flag bit representing overtime errors or out-of-order errors in the atomic variable.
According to the technical scheme of the embodiment of the invention, the data identification and the state identification corresponding to the message information are searched in the preset configuration file, the preset monitoring library is called to package the data identification and the state identification into the atomic variable, whether the atomic variable exists in the cache in the preset shared space is judged, and if the atomic variable exists in the cache, the atomic variable is stored in the cache; if the atomic variable does not exist, storing the atomic variable into a shared memory, wherein the shared memory at least comprises a heartbeat monitoring sequence and a time sequence monitoring sequence, judging whether the atomic variable exists in a cache in a preset shared space, and if the atomic variable exists in the cache, reading the atomic variable in the cache until the cache is empty; and if the state identifier does not exist in the shared memory, reading the atomic variable of the shared memory in the preset shared space, extracting the state identifier and the data identifier of the atomic variable, and executing message processing corresponding to the state identifier and the data identifier. The embodiment of the invention changes the locked communication into the non-locked communication through the reading and writing of the atomic variable, can effectively reduce the system resource overhead and reduce the communication time delay, simultaneously, the atomic variable of the message has the data and the data state, namely, the data and the data state are both stored in the shared space, can support the realization of the hot switching and the lossless recovery of the service after the service process is crashed and restarted, and has higher reliability.
Further, on the basis of the above embodiment of the present invention, the storage length of the atomic variable is the same as the cache line of the cache.
In this embodiment of the present invention, the atomic variable may be a plurality of basic variable types, for example, the atomic variable may include a uint64_ t, a long, a char32_ t, a uint _ least8_ t, and the like, where each basic variable type corresponds to a different number of bytes (i.e., a storage length); a cache line of a cache is typically an integer power of 2 consecutive bytes; to avoid the false sharing problem, the storage length of the atomic variable may be extended to the cache line size of the cache according to the cache line size of the caches of different platforms. In an embodiment, if the cache line size of the cache is 64 bytes, and the atomic variable is represented by a uint64_ t type occupying 8 bytes, to avoid the problem of low cache hit rate due to false sharing, 7 long type variables (8 bytes) may be placed before and after the atomic variable of 8 bytes, that is, the atomic variable is filled with meaningless variables to ensure that the entire atomic variable monopolizes the entire cache line.
Further, on the basis of the above embodiment of the invention, the method may further include:
and updating the state information of the corresponding atomic variable in a preset shared memory space according to the processing result of the exception handling.
Specifically, after the timeout error or the sequence error of the current target monitoring program is processed, the state information of the corresponding atomic variable in the preset shared memory space may be updated, and the flag bit representing the timeout error or the out-of-order error in the atomic variable may be reset.
EXAMPLE III
Fig. 3 is a flowchart of a program monitoring method according to a third embodiment of the present invention. On the basis of the foregoing embodiments, this embodiment provides an implementation manner of a program monitoring method, which can implement monitoring on a target monitoring program based on atomic variable reading and writing. Fig. 4 is a diagram illustrating an exemplary structure of a program monitoring system according to a third embodiment of the present invention.
As shown in fig. 3, a program monitoring method provided in the third embodiment of the present invention specifically includes the following steps:
s310, starting the monitored process and the monitoring service process, and loading the configuration file.
In the embodiment of the invention, all parameters such as task numbers, program numbers, the front-back dependency relationship of the programs, the consumed time of the whole task, the heartbeat time of the task and the like are configured in the configuration file. Specifically, after the monitored process and the monitoring service process are started, the monitored process, the monitoring service process and the monitoring library may load the required configuration file.
And S320, reporting the state information by the monitored process, writing the state information into the atomic variable and storing the atomic variable into the shared memory.
In the embodiment of the present invention, each message is compressed into an 8-byte atomic variable as shown in fig. 5, and the atomic variable contains message field information as shown in the following table:
s330, the monitoring service process periodically reads the memory queue, processes the data and the state in the memory queue, and writes back the state data to the shared memory.
In the embodiment of the invention, two independent message queues, namely a heartbeat monitoring list and a time sequence monitoring list, are arranged in a shared memory, each queue is integrated by an atomic variable message, and the atomic variable comprises data and a state.
Fig. 6 is a flowchart illustrating a data state processing procedure provided in the third embodiment. The update logic for a particular data state is as follows: when the monitored process writes the message, the message state is updated at the same time, such as a time sequence error state, a timeout error state, a starting state, an activation state and the like; when the monitoring service process reads the message, the logic judgment and the message state judgment are carried out, and after the message is processed, the message state of the data is updated; therefore, if the data or the state is not processed, the data or the state is always stored in the memory, and after the abnormal restart of the monitoring service process, the previous data and state can be recovered in a lossless manner, so that hot switching and lossless recovery are realized.
The third embodiment also provides an optimization method for the CPU Cache. The caches of the CPUs are used for data access by taking a Cache Line (Cache Line) as a unit, the Cache lines of most CPUs are 64 bytes, and if one Cache Line contains a plurality of data variables, new writing of each variable can cause invalidation of other variables in the Cache Line under a multi-concurrent read-write scene, so that the problem of pseudo sharing is caused. FIG. 7 is an exemplary diagram of CPU Cache pseudo sharing. To avoid the pseudo sharing problem, the method for optimizing the CPU Cache provided in this embodiment is as follows: and expanding each message atomic variable into 64 bytes to monopolize exactly one Cache Line, eliminating the problem of false sharing of the CPU Cache, and further improving the communication performance. Fig. 8 is a flowchart illustrating a cache optimization process provided in the third embodiment.
Further, on the basis of the above embodiments of the present invention, the atomic variable can only be a basic variable type, and the third embodiment is configured as a fluid 64_ t type (8 bytes), and can also be replaced with 4 bytes or more than 8 bytes of other platforms. The main idea is to realize lock-free communication through reading and writing of atomic variables.
Further, based on the above embodiments of the invention, the state data may also include more state definitions or different Bit bits and Bit sizes. The main idea is that the message body comprises data and state to enable hot-switching and lossless recovery
Further, on the basis of the embodiment of the invention, the optimization of the CPU Cache can specifically expand the size of the variable according to the size of the CPU Cache Line, and the main idea is that one CPU Cache Line only contains one variable, so that the problem of pseudo sharing is solved.
The following table is an example of the time consuming results of using atomic variables to implement lock-free communication and lock-on communication.
As can be seen from the above table, the time consumption for implementing lock-free communication using an atomic variable is much less than that for communication with a lock, which means that the monitored process and the service process perform atomic operation to read and write a message, and the lock-free communication is changed from lock communication, so that the communication delay can be reduced.
According to the technical scheme of the embodiment of the invention, the monitored process and the monitoring service process are started, the configuration file is loaded, the monitored process reports the state information, the state information is written into the atomic variable and is stored in the shared memory, and the monitoring service process periodically reads the memory queue, processes the data and the state in the memory queue and writes back the state data to the shared memory. According to the embodiment of the invention, the monitored process and the service process adopt the atomic operation to read and write the message, so that the locking communication is changed into the non-locking communication, the system resource overhead can be effectively reduced, and the communication time delay can be reduced; meanwhile, the atomic variable of the message carries data and data states and is stored in the shared memory, so that hot switching and lossless recovery can be realized after the service process is crashed and restarted, and the reliability of communication is improved; in addition, the atomic variable is expanded to monopolize one cache line through the optimization of the CPU cache, the problem of pseudo sharing is eliminated, the hit rate of the CPU cache is improved, and the communication performance is further improved.
Example four
Fig. 9 is a schematic structural diagram of a program monitoring device according to a fourth embodiment of the present invention. As shown in fig. 9, the apparatus includes:
and the variable generation module 41 is configured to process the message information of the target monitoring program into an atomic variable according to a preset configuration file.
And the variable temporary storage module 42 is configured to store the atomic variable based on the preset shared space.
And a message processing module 43, configured to execute message processing according to the atomic variable in the preset shared space.
According to the technical scheme of the embodiment of the invention, the message information of the target monitoring program is processed into the atomic variable through the variable generation module according to the preset configuration file, the variable temporary storage module stores the atomic variable based on the preset shared space, and the message processing module executes message processing according to the atomic variable in the preset shared space. The embodiment of the invention realizes lock-free communication through reading and writing the atomic variable and stores the atomic variable containing data and state in the shared space, thereby reducing the expenditure of system resources, reducing the communication time delay, supporting the lossless recovery of the previous data and state after the service process is crashed and restarted, and having higher reliability.
Further, on the basis of the above embodiment of the invention, the variable generation module 41 includes:
and the identifier searching unit is used for searching the data identifier and the state identifier corresponding to the message information in the preset configuration file.
And the atomic variable packaging unit is used for calling a preset monitoring library to package the data identifier and the state identifier into an atomic variable.
Further, on the basis of the above embodiment of the present invention, the preset shared space at least includes a cache and a shared memory, and correspondingly, the variable temporary storage module 42 includes:
the first judging unit is used for judging whether an atomic variable exists in a cache in a preset shared space.
An atomic variable storage unit, configured to store an atomic variable in a cache if the atomic variable exists; and if the atomic variable does not exist, storing the atomic variable into a shared memory, wherein the shared memory at least comprises a heartbeat monitoring sequence and a time sequence monitoring sequence.
Further, on the basis of the above-mentioned embodiment of the invention, the message processing module 43 includes:
and the second judging unit is used for judging whether the cache in the preset shared space has the atomic variable or not.
The atomic variable reading unit is used for reading the atomic variable in the cache until the cache is empty if the atomic variable exists; and if not, reading the atomic variable of the shared memory in the preset shared space.
And the message processing unit is used for extracting the state identifier and the data identifier of the atomic variable and executing message processing corresponding to the state identifier and the data identifier.
Further, on the basis of the above embodiment of the invention, the method further includes:
and the state updating module is used for updating the state information of the corresponding atomic variable in a preset shared memory space according to the processing result of the exception handling.
Further, on the basis of the above-described embodiment of the invention, the atomic variables include at least one of: time identification field, state identification field, sequence number field, task identification field and check code field.
Further, on the basis of the above embodiment of the present invention, the storage length of the atomic variable is the same as the cache line of the cache.
The program monitoring device provided by the embodiment of the invention can execute the program monitoring method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
EXAMPLE five
FIG. 10 illustrates a schematic diagram of an electronic device 50 that may be used to implement an embodiment of the invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 10, the electronic device 50 includes at least one processor 51, and a memory communicatively connected to the at least one processor 51, such as a Read Only Memory (ROM) 52, a Random Access Memory (RAM) 53, and the like, wherein the memory stores a computer program executable by the at least one processor, and the processor 51 may perform various suitable actions and processes according to the computer program stored in the Read Only Memory (ROM) 52 or the computer program loaded from a storage unit 58 into the Random Access Memory (RAM) 53. In the RAM 53, various programs and data necessary for the operation of the electronic apparatus 50 can also be stored. The processor 51, the ROM 52, and the RAM 53 are connected to each other via a bus 54. An input/output (I/O) interface 55 is also connected to bus 54.
A plurality of components in the electronic apparatus 50 are connected to the I/O interface 55, including: an input unit 56 such as a keyboard, a mouse, or the like; an output unit 57 such as various types of displays, speakers, and the like; a storage unit 58 such as a magnetic disk, an optical disk, or the like; and a communication unit 59 such as a network card, modem, wireless communication transceiver, etc. The communication unit 59 allows the electronic device 50 to exchange information/data with other devices via a computer network such as the internet and/or various telecommunication networks.
The processor 51 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of the processor 51 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various dedicated Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, or the like. The processor 51 performs the various methods and processes described above, such as the program monitoring method.
In some embodiments, the program monitoring method may be implemented as a computer program tangibly embodied in a computer-readable storage medium, such as storage unit 58. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 50 via the ROM 52 and/or the communication unit 59. When the computer program is loaded into the RAM 53 and executed by the processor 51, one or more steps of the program monitoring method described above may be performed. Alternatively, in other embodiments, the processor 51 may be configured to perform the program monitoring method by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), system on a chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be performed. A computer program can execute entirely on a machine, partly on a machine, as a stand-alone software package partly on a machine and partly on a remote machine or entirely on a remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical host and VPS service are overcome.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present invention may be executed in parallel, sequentially, or in different orders, and are not limited herein as long as the desired result of the technical solution of the present invention can be achieved.
The above-described embodiments should not be construed as limiting the scope of the invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made in accordance with design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims (10)
1. A program monitoring method, the method comprising:
processing message information of a target monitoring program into an atom variable according to a preset configuration file;
saving the atomic variable based on a preset shared space;
and executing message processing according to the atomic variables in the preset shared space.
2. The method according to claim 1, wherein the processing the message information of the target monitoring program into an atomic variable according to a preset configuration file comprises:
searching a data identifier and a state identifier corresponding to the message information in the preset configuration file;
and calling a preset monitoring library to package the data identifier and the state identifier into the atomic variable.
3. The method of claim 1 or 2, wherein the atomic variables comprise at least one of: time identification field, state identification field, sequence number field, task identification field and check code field.
4. The method according to claim 1, wherein the predefined shared space at least includes a cache and a shared memory, and in response, the saving the atomic variable based on the predefined shared space includes:
judging whether the atomic variable exists in the cache in the preset shared space or not;
if so, storing the atomic variable to the cache;
and if the atomic variable does not exist, storing the atomic variable into the shared memory, wherein the shared memory at least comprises a heartbeat monitoring sequence and a time sequence monitoring sequence.
5. The method according to claim 1, wherein said performing message processing according to the atomic variable in the preset shared space comprises:
judging whether the atomic variable exists in a cache in the preset shared space or not;
if so, reading the atomic variable in the cache until the cache is empty;
if the atomic variable does not exist in the preset shared space, reading the atomic variable of the shared memory in the preset shared space;
and extracting the state identification and the data identification of the atomic variable, and executing the message processing corresponding to the state identification and the data identification.
6. The method of claim 4, wherein the atomic variable is stored the same length as a cache line of the cache.
7. The method of claim 5, further comprising:
and updating the state information corresponding to the atomic variable in the preset shared memory space according to the processing result of the exception handling.
8. A program monitoring apparatus, the apparatus comprising:
the variable generation module is used for processing the message information of the target monitoring program into an atomic variable according to a preset configuration file;
the variable temporary storage module is used for storing the atomic variables based on a preset shared space;
and the message processing module is used for executing message processing according to the atomic variable in the preset shared space.
9. An electronic device, characterized in that the electronic device comprises:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the program monitoring method of any one of claims 1-7.
10. A computer-readable storage medium storing computer instructions for causing a processor to implement the program monitoring method according to any one of claims 1 to 7 when executed.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211492584.XA CN115757039A (en) | 2022-11-25 | 2022-11-25 | Program monitoring method and device, electronic equipment and storage medium |
PCT/CN2023/104590 WO2024109068A1 (en) | 2022-11-25 | 2023-06-30 | Program monitoring method and apparatus, and electronic device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211492584.XA CN115757039A (en) | 2022-11-25 | 2022-11-25 | Program monitoring method and device, electronic equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115757039A true CN115757039A (en) | 2023-03-07 |
Family
ID=85338175
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211492584.XA Pending CN115757039A (en) | 2022-11-25 | 2022-11-25 | Program monitoring method and device, electronic equipment and storage medium |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN115757039A (en) |
WO (1) | WO2024109068A1 (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2024109068A1 (en) * | 2022-11-25 | 2024-05-30 | 惠州市德赛西威智能交通技术研究院有限公司 | Program monitoring method and apparatus, and electronic device and storage medium |
Family Cites Families (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9009203B2 (en) * | 2013-02-19 | 2015-04-14 | Sap Se | Lock-free, scalable read access to shared data structures using garbage collection |
US10067960B2 (en) * | 2015-06-04 | 2018-09-04 | Microsoft Technology Licensing, Llc | Controlling atomic updates of indexes using hardware transactional memory |
CN110287044B (en) * | 2019-07-02 | 2021-08-03 | 广州虎牙科技有限公司 | Lock-free shared memory processing method and device, electronic equipment and readable storage medium |
CN111190732A (en) * | 2019-12-27 | 2020-05-22 | 成都欧珀通信科技有限公司 | Timed task processing system and method, storage medium and electronic device |
CN113407414A (en) * | 2021-06-24 | 2021-09-17 | 厦门科灿信息技术有限公司 | Program operation monitoring method, device, terminal and storage medium |
CN114217986A (en) * | 2021-12-03 | 2022-03-22 | 腾讯科技(深圳)有限公司 | Data processing method, device, equipment, storage medium and product |
CN115757039A (en) * | 2022-11-25 | 2023-03-07 | 惠州市德赛西威智能交通技术研究院有限公司 | Program monitoring method and device, electronic equipment and storage medium |
-
2022
- 2022-11-25 CN CN202211492584.XA patent/CN115757039A/en active Pending
-
2023
- 2023-06-30 WO PCT/CN2023/104590 patent/WO2024109068A1/en unknown
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2024109068A1 (en) * | 2022-11-25 | 2024-05-30 | 惠州市德赛西威智能交通技术研究院有限公司 | Program monitoring method and apparatus, and electronic device and storage medium |
Also Published As
Publication number | Publication date |
---|---|
WO2024109068A1 (en) | 2024-05-30 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109522128B (en) | Segmented multithreading task execution method and device | |
CN114513545A (en) | Request processing method, device, equipment and medium | |
CN114936173B (en) | Read-write method, device, equipment and storage medium of eMMC device | |
CN113364877A (en) | Data processing method, device, electronic equipment and medium | |
CN115757039A (en) | Program monitoring method and device, electronic equipment and storage medium | |
US8862786B2 (en) | Program execution with improved power efficiency | |
US8341368B2 (en) | Automatic reallocation of structured external storage structures | |
CN113553216A (en) | Data recovery method and device, electronic equipment and storage medium | |
US6675238B1 (en) | Each of a plurality of descriptors having a completion indicator and being stored in a cache memory of an input/output processor | |
CN118193485A (en) | Concurrency control method and device, electronic equipment and storage medium | |
CN107589907B (en) | Data processing method, electronic device and computer readable storage medium | |
CN112463037B (en) | Metadata storage method, device, equipment and product | |
CN115390992A (en) | Virtual machine creating method, device, equipment and storage medium | |
CN114691781A (en) | Data synchronization method, system, device, equipment and medium | |
CN114528082A (en) | Task scheduling method and device, electronic equipment and storage medium | |
CN115617451A (en) | Data processing method and data processing device | |
CN110968595A (en) | Single-thread sql statement execution method, equipment and storage medium | |
CN113986134A (en) | Method for storing data, method and device for reading data | |
US20210208869A1 (en) | System and method to provide smm runtime telemetry support | |
CN114064301A (en) | Data storage and reading method, device and equipment for single writer and multiple readers | |
CN118689682A (en) | Fault storage method and device, electronic equipment and storage medium | |
CN115454660A (en) | Task management method and device, electronic equipment and storage medium | |
CN118034985A (en) | Data processing method, device, electronic equipment and storage medium | |
CN116594764A (en) | Application program updating method and device, electronic equipment and storage medium | |
CN115599828A (en) | Information processing method, device, equipment and storage medium |
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 |