CN118316987A - Message storage method, system and storage medium - Google Patents
Message storage method, system and storage medium Download PDFInfo
- Publication number
- CN118316987A CN118316987A CN202410455242.3A CN202410455242A CN118316987A CN 118316987 A CN118316987 A CN 118316987A CN 202410455242 A CN202410455242 A CN 202410455242A CN 118316987 A CN118316987 A CN 118316987A
- Authority
- CN
- China
- Prior art keywords
- message
- cache array
- preset structure
- pointer
- storing
- 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 56
- 238000004590 computer program Methods 0.000 claims description 5
- 238000013461 design Methods 0.000 abstract description 12
- 238000005516 engineering process Methods 0.000 description 5
- 238000007726 management method Methods 0.000 description 5
- 238000012545 processing Methods 0.000 description 5
- 238000010586 diagram Methods 0.000 description 4
- 230000005540 biological transmission Effects 0.000 description 3
- 238000004891 communication Methods 0.000 description 3
- 230000006870 function Effects 0.000 description 2
- 238000007781 pre-processing Methods 0.000 description 2
- 230000008569 process Effects 0.000 description 2
- 230000001360 synchronised effect Effects 0.000 description 2
- 238000004458 analytical method Methods 0.000 description 1
- 125000004122 cyclic group Chemical group 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000007723 transport mechanism Effects 0.000 description 1
Landscapes
- Memory System Of A Hierarchy Structure (AREA)
Abstract
A message storage method, system and storage medium, the method includes: converting a received bus message into a preset structure message according to the type of the received bus message by executing a writing task, and storing the preset structure message into a cache array as an array element; and reading a preset structure message from the cache array by executing a reading task, and saving the message. According to the scheme, the load length and the total length of the bus messages are not required to be concerned, the data can be read and written only by sequentially and circularly accessing the array, the problem that memory management and data structure design are complex due to different load lengths and total lengths of the bus messages can be avoided, extra performance cost is avoided, the design is simple, errors are not easy to occur, and efficient disk storage and convenient access of various types of bus messages can be realized.
Description
Technical Field
Embodiments of the present disclosure relate to, but are not limited to, the field of storage technologies, and in particular, to a method, a system, and a storage medium for storing a message.
Background
In the aerospace field, data communication technology is one of the key infrastructures. With the development of technology, various high-speed data buses are widely used, such as buses based on AFDX (Avionics Full Duplex SWITCHED ETHERNET, avionics full duplex ethernet), FC (Fibre Channel) and 1394 (also known as IEEE 1394 or FireWire), and the transmission rate of these buses can reach hundreds of megabits or even several gigabits per second. In such a high-speed data transmission environment, a packet is an ordered group of bytes organized according to a specific protocol as a basic unit of data transmission.
Therefore, various bus message collection and storage systems are developed, the system software processes the received message and then stores the message in a media file, the data rate is high, the software needs to run two tasks in parallel, one task is responsible for receiving the message in real time, preprocessing, storing the preprocessed result message in a local memory buffer area, and the other task reads the stored result message from the local memory buffer area and stores the stored result message in the media file (called a disk storage). However, because the messages with different types and load lengths cause different total lengths of the messages, and the two tasks access the same local memory buffer area at the same time, resource access conflict can be generated. This design presents a number of challenges in implementation: firstly, the synchronization between tasks needs to be precisely controlled to avoid collisions; secondly, since the message length is not fixed, the design of memory management and data structure becomes complex; finally, high data rates require that the software must efficiently run both tasks in parallel, otherwise performance bottlenecks or data processing errors may result.
Disclosure of Invention
The following is a summary of the subject matter described in detail herein. This summary is not intended to limit the scope of the claims.
The present disclosure provides a method, a system and a storage medium for storing messages, which can solve the problems of complex design of memory management and data structure, easy occurrence of data processing errors and resource access conflicts of the existing message collection and storage system caused by different bus message types and different load lengths.
An embodiment of the present disclosure provides a method for storing a message, including: converting a received bus message into a preset structure message according to the type of the received bus message by executing a writing task, and storing the preset structure message into a cache array as an array element; and reading a preset structure message from the cache array by executing a reading task, and saving the message.
An embodiment of the present disclosure further provides a message storage system, including: a memory and a processor; the memory is used for storing a program for storing the message; the processor is configured to read the program for storing a message, and execute the method for storing a message according to any embodiment of the disclosure.
An embodiment of the present disclosure also provides a transitory computer readable storage medium storing a computer program capable of implementing a message storage method according to any embodiment of the present disclosure when executed by a processor.
The message storage method, the system and the storage medium define a preset structure message, and the method, the system and the storage medium convert the bus message into the preset structure message according to the type of the received bus message by executing a writing task, and store the preset structure message into a cache array as an array element; by executing the reading task, the message with the preset structure is read from the cache array and converted into the bus message storage disk with the corresponding type, so that a brand new message storage scheme is realized. According to the scheme, only the reading and writing of the array elements are needed to be concerned, and the types, the load lengths and the total lengths of the bus messages are not needed to be concerned, so that on one hand, the problem of complex memory management and data structure design caused by different load lengths and total lengths of the bus messages can be avoided, no additional performance cost is caused, and the design is simple and is not easy to make mistakes; on the other hand, when the method is used for reading, only whether the array elements are empty is judged, so that the problem of resource access conflict is solved.
Additional features and advantages of embodiments of the application will be set forth in the description which follows, and in part will be apparent from the description, or may be learned by practice of embodiments of the application. The objectives and other advantages of embodiments of the application may be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
Drawings
The accompanying drawings are included to provide an understanding of the technical aspects of the present disclosure, and are incorporated in and constitute a part of this specification, illustrate the technical aspects of the present disclosure and together with the embodiments of the disclosure, not to limit the technical aspects of the present disclosure.
FIG. 1 is a flow chart of a message storage method according to an embodiment of the disclosure;
FIG. 2is a schematic diagram of a preset structure message according to an embodiment of the disclosure;
FIG. 3a is a flowchart illustrating a method for storing a message according to an embodiment of the present disclosure;
FIG. 3b is a flow chart illustrating the execution of the write task of FIG. 3 a;
FIG. 3c is a flow chart illustrating the execution of the read task of FIG. 3 a;
FIG. 4a is a schematic diagram of a read pointer and a write pointer pointing to the same element according to an embodiment of the present disclosure;
FIG. 4b is a schematic diagram of a read pointer and a write pointer pointing to different elements according to an embodiment of the present disclosure;
fig. 5 is a schematic diagram of a message storage system according to an embodiment of the disclosure.
Detailed Description
The present disclosure describes several embodiments, but the description is illustrative and not limiting, and it will be apparent to those of ordinary skill in the art that many more embodiments and implementations are possible within the scope of the embodiments described in the present disclosure. Although many possible combinations of features are shown in the drawings and discussed in the detailed description, many other combinations of the disclosed features are possible. Any feature or element of any embodiment may be used in combination with or in place of any other feature or element of any other embodiment unless specifically limited.
The present disclosure includes and contemplates combinations of features and elements known to those of ordinary skill in the art. The embodiments, features and elements of the present disclosure that have been disclosed may also be combined with any conventional features or elements to form a unique inventive arrangement as defined by the claims. Any feature or element of any embodiment may also be combined with features or elements from other inventive arrangements to form another unique inventive arrangement as defined in the claims. Thus, it should be understood that any of the features shown and/or discussed in this disclosure may be implemented alone or in any suitable combination. Accordingly, the embodiments are not to be restricted except in light of the attached claims and their equivalents. Further, various modifications and changes may be made within the scope of the appended claims.
An embodiment of the present disclosure provides a method for storing a message, as shown in fig. 1, which may include the following steps:
step S110: converting a received bus message into a preset structure message (also called R message) according to the type of the received bus message by executing a writing task, and storing the preset structure message into a cache array by taking the preset structure message as an array element;
Step S120: and reading a preset structure message from the cache array by executing a reading task, and saving the message.
The message storage method of the embodiment defines a preset structure message, converts different types of bus messages into the preset structure message, and writes and reads the preset structure message in the form of array elements through a writing task and a reading task. Writing and reading of the messages with the preset structure are carried out in the form of array elements, only reading and writing of the array elements are needed to be concerned, and the load length and the total length of the messages of the bus are not needed to be concerned, so that on one hand, the problem of complex memory management and data structure design caused by different load lengths and total lengths of the bus can be avoided, and the problems of no extra performance cost, simple design and low possibility of mistakes are avoided; on the other hand, when the method is used for reading, only whether the array elements are empty is judged, so that the problem of resource access conflict is solved.
It should be noted that, in the above embodiment, after the preset structure message is read from the cache array, the preset structure message is directly stored, but may be converted into the corresponding type of bus message and then stored, or may be converted into another form that is desired to be stored, which is not limited, and may be selected according to practical situations.
In an exemplary embodiment of the present disclosure, before storing the preset structure packet as an array element in the cache array, the method may further include:
Initializing the cache array, and a write pointer and a read pointer corresponding to the cache array, and pointing the write pointer and the read pointer to the first element of the cache array; illustratively, initializing a cache array may refer to allocating a contiguous piece of space in a global address area as a cache area in the form of an array for storing R packets.
The writing task and the reading task are established, wherein the writing task and the reading task are executed in parallel, the writing task is used for storing the preset structure message into a cache array according to the writing pointer, and the reading task is used for reading the preset structure message from the cache array according to the reading pointer. In other words, the element pointed to by the write pointer can only be modified by the write task, and the element pointed to by the read pointer can only be modified by the read task.
According to the message storage method, the bus message is converted into the preset structure message and stored in the form of the array elements, then corresponding write pointers and read pointers can be respectively allocated corresponding to the write tasks and the read tasks, storage and reading of the preset structure message are controlled, parallel execution of the write tasks and the read tasks can be simply and conveniently realized without any synchronous measures, and the message storage efficiency is improved.
In an exemplary embodiment of the present disclosure, the storing the preset structure packet to a cache array according to the write pointer includes:
writing the preset structure message into the element pointed by the writing pointer;
updating the element pointed by the write pointer after the writing is completed, including: updating the write pointer to point to the first element of the cache array when the write pointer points to the last element of the cache array; and updating the write pointer to point to the next element of the current element when the write pointer does not point to the last element of the cache array.
According to the message storage method, the message with the preset structure is controlled to be written into the cache array by updating the pointed element of the write pointer, and when the write pointer points to the last element of the cache array, the write pointer is updated to point to the first element of the cache array, so that the cyclic utilization of the cache array is realized.
In an example of this embodiment, before writing the preset structure packet into the element pointed by the write pointer, the method further includes:
Judging whether the cache array contains writable idle elements according to the elements pointed by the read pointer and the write pointer respectively, wherein the method comprises the following steps: when the write pointer points to the last element of the elements pointed by the read pointer, judging that the cache array has no writable idle element; when the write pointer does not point to the last element of the element pointed by the read pointer, judging that the cache array has a writable idle element;
writing the message with the preset structure into the cache array under the condition that the cache array contains writable idle elements;
Under the condition that the cache array does not contain writable idle elements, setting the writing task to be circulation waiting until the writable idle elements exist, and recovering the execution of the writing task; for example, if the element pointed by the read pointer is updated when a new element is read, there will be a writable free element, at which time execution of the writing task may resume;
wherein the writable free element refers to an element located between an element pointed to by the write pointer and an element pointed to by the read pointer when the element pointed to by the read pointer is shifted forward by two element bits (including an element pointed to by the write pointer and an element pointed to by the read pointer when the element pointed to by the read pointer is shifted forward by two element bits); for example, if the cache array has 50 elements in total, the write pointer points to the 30 th element, the read pointer points to the 20 th element, then the writable free elements refer to the 30 th-49 and 0-18 th elements in the cache array.
According to the message storage method of the embodiment, whether the buffer array has the writable idle element can be judged through the elements pointed by the write pointer and the read pointer, and when the writable idle element exists, the message with the preset structure is written into the element pointed by the write pointer; when there is no writable free element, the write task is set to loop waiting. Therefore, on one hand, the read pointer and the write pointer can not point to the same element, so that whether the cache array is empty or not can be conveniently judged through whether the read pointer and the write pointer point to the same element or not, and data can be read safely when the cache array is not empty, namely, a foundation is laid for simple and efficient data reading; on the other hand, it is possible to avoid that the written but unread array elements are overwritten, resulting in lost data.
It should be noted that, as long as the size of the cache array is appropriate, during efficient reading and writing, the cache array is theoretically always in a substantially empty state, and there is no case where the writing task is set to wait for a loop (i.e., no free element can be written).
In an exemplary embodiment of the present disclosure, the reading, according to the read pointer, a preset structure packet from the cache array includes:
judging whether the cache array is empty or not according to the elements pointed by the read pointer and the write pointer respectively;
reading the element pointed by the read pointer from the cache array under the condition that the cache array is not empty;
updating the element pointed by the read pointer after the reading is completed, including: updating the read pointer to point to the first element of the cache array when the read pointer points to the last element of the cache array; and updating the read pointer to point to the next element of the current element when the read pointer does not point to the last element of the cache array.
In an example of this embodiment, the determining, according to the elements pointed to by the read pointer and the write pointer, whether the cache array is empty may include:
In the case that the read pointer and the write pointer point to the same element, the cache array is empty; in case the read pointer and the write pointer point to different elements, the cache array is not empty.
According to the message storage method, only whether the write pointer and the read pointer point to the same element is judged, the cache array is empty as long as the write pointer and the read pointer point to the same element, and the cache array is not empty as long as the write pointer and the read pointer point to different elements, so that the judging process is simple and efficient, and the message storage method is simple in design, high in storage and reading efficiency and not prone to error.
In an example of this embodiment, the number of elements to be read and the number of writable free elements may also be determined according to the elements pointed by the write pointer and the read pointer. For example, the array can store 50 elements in total, the write pointer points to the 30 th element and the read pointer points to the 20 th element, and then the number of elements to be read is 10 (the 20 th element to the 29 th element, 10 total) and the number of writable free elements is 39 (the 30 th to 49 th elements and the 0 th to 18 th elements).
According to the message storage method, the number of the array elements to be read and the number of the writable idle array elements can be calculated quickly according to the write pointer and the read pointer, and the method is simple and quick.
In an exemplary embodiment of the present disclosure, the preset structure message includes the following fields: the message unique identification, the time stamp, the hardware channel number from which the message originates, the message type identification, the message type key field (also can be called as the key field content of various message types), the message load length and the message load data;
the timestamp may be a received or arrived timestamp, the message payload length may be a number of bytes of the message payload length, and the message type key field may include one or more.
Illustratively, the message unique identification may be generated incrementally by the write task based on some initial value.
In an example of this embodiment, as shown in fig. 2, the unique message identifier may be represented by "id", the timestamp may be represented by "ts", the hardware channel number from which the message originates may be represented by "channel", the message type identifier may be represented by "type", the message type key field may include a.1, a.2, b.1, x.1, x.2, x.3, the message load length (or the number of bytes of the message load length) may be represented by "bytes", and the message load data may be represented by "payload".
It should be noted that fig. 2 is only an example, and the structure of the preset structure message is not limited to fig. 2. For example, the key field of the message may also include only "a.1, a.2", or only "x.1, x.2, x.3", or "a.1, a.2, b.1"; of course, new types such as "d.1, d.2" may also be included.
For example, when a certain type of bus message includes A, B, X message types, the a message type includes key fields "1" and "2", the B message type includes key field "1", the X message type includes key fields "1", "2" and "3", the message type key field corresponding to the type of bus message may include a.1, a.2, b.1, x.1, x.2 and x.3.
In an exemplary embodiment of the present disclosure, the converting the bus message into a preset structure message according to the type of the received bus message includes:
Confirming the message type identification field and the message type key field according to the message type of the bus message;
Confirming the key field of the message type according to the value of the key field of the bus message;
confirming a message load length field of the preset structure message according to the load length of the bus message;
confirming a message load data field of the preset structure message according to the load data of the bus message;
the message load data field is in an array form, the capacity of the message load data array is set according to the maximum length of the load data of the bus message, and the key field can be one or more.
For example, if the above three message types include A, B, X, the a message type includes the key fields "1" and "2", the B message type includes the key field "1", the X message type includes the bus messages of the key fields "1", "2" and "3", the type, a.1, a.2 or b.1 or x.1, x.2, x.3, bytes, payload, and the corresponding id are extracted to obtain the type of the bus message, and then the type, a.1, a.2 or b.1 or x.1, x.2, x.3, bytes, payload, and the like are packaged into the preset structure message (i.e., the R message).
In this embodiment, the capacity of the packet load data array is set according to the maximum length of the load data of the bus packet, so that the packet load data array can necessarily accommodate the load data of the bus packet, and thus, the data can be prevented from being lost due to insufficient capacity when writing data.
In an exemplary embodiment of the present disclosure, the method may further include restoring the bus message according to the preset structure message; the restoring the bus message according to the preset structure message includes:
restoring the message type of the bus message according to the message type identification field of the preset structure message;
Restoring the value of the key field of the bus message according to the key field of the message type;
restoring the load length of the bus message according to the message load length field of the message with the preset structure;
and restoring the load data of the bus message according to the message load data field of the message with the preset structure.
For example, for a type a message, according to the type value of the preset structure message being "a", the message type "a" of the bus message is restored; restoring the values of key fields of the bus message according to the values of A.1 and A.2; reducing the load length of the bus message according to bytes; and restoring the load data of the bus message according to the payload.
Similarly, for the B type message, according to the preset structure message type value of B, restoring the message type B of the bus message; restoring the value of the key field of the bus message according to the value of B.1; reducing the load length of the bus message according to bytes; and restoring the load data of the bus message according to the payload.
The message storage method of the embodiment defines a structured and deterministic data unit (namely a preset structure message) and a set of writing and reading rules of the cache array, so that a brand new storage method is realized, and the method is suitable for various messages with various bus types and different load lengths. According to the scheme, the load length and the total length of the bus messages are not required to be concerned, the data can be read and written only by sequentially and circularly accessing the array, the problem that memory management and data structure design are complex due to different load lengths and total lengths of the bus messages can be avoided, extra performance cost is avoided, the design is simple, errors are not easy to occur, and efficient disk storage and convenient access of various types of bus messages can be realized. On the other hand, the problem of resource access conflict is also avoided.
The following is a complete example of the method for storing a message of the present disclosure, as shown in fig. 3a, and may include the following steps:
Step S310: initializing a cache array, a write pointer and a read pointer. Illustratively, this step may include steps S311-S313:
Step S311: and allocating a continuous space in the global address area as a buffer area, wherein the buffer area is in the form of an array, and the array is used for storing R messages.
Step S312: the write pointer is initialized and pointed to the first element of the cache array.
Step S313: the read pointer is initialized and pointed to the first element of the cache array.
Step S320: two tasks, a write task and a read task, are created. The writing task is used for writing the message data into the cache array, the reading task is used for reading the data in the cache array and storing the data, and the writing task and the reading task can be executed in parallel.
By way of example, as shown in FIG. 3b, the write task may include the following steps S3211-S3213:
Step S3211: each collected message is converted into a preset structure message (also called as R message) in turn.
For example, the structure of the preset structure message may refer to fig. 2, which may include the following attributes: the message unique identification id, the time stamp ts, the hardware channel number channel from which the message originates, the message type identification type, the message type key field, the message load length byte number and the message load data payload. For example, when a certain type of bus message includes A, B, X message types, the a message type includes key fields "1" and "2", the B message type includes key field "1", the X message type includes key fields "1", "2" and "3", the message type key field corresponding to the type of bus message may include a.1, a.2, b.1, x.1, x.2 and x.3.
Step S3212: judging whether the cache array has writable idle elements according to the elements pointed by the write pointer and the elements pointed by the read pointer, and writing the current R message into the cache array when the writable idle elements exist; when there is no writable free element, the write task is set to loop waiting.
Step S3213: updating the element pointed by the write pointer after the writing is completed comprises: updating the write pointer to point to the first element of the cache array when the write pointer points to the last element of the cache array; when the write pointer does not point to the last element of the cache array, the write pointer is updated to point to the next element of the current element.
For example, as shown in fig. 3c, the read task may include the following steps S3221-S3223:
Step S3221: and judging whether the cache array is empty according to the elements pointed by the read pointer and the write pointer, and reading the element pointed by the read pointer (namely R message) when the cache array is not empty.
Illustratively, the determining whether the cache array is empty according to the elements pointed to by the read pointer and the write pointer respectively includes: when the read pointer and the write pointer point to the same element, the cache array is empty; when the read pointer and the write pointer point to different elements, the cache array is not empty. As shown in fig. 4a, the write pointer and the read pointer point to the same array element at this time, and the cache array is empty at this time; as shown in fig. 4b, the write pointer and the read pointer point to different array elements when the cache array is not empty.
Step S3222: updating the element pointed by the read pointer after the reading is completed, including: updating the read pointer to point to the first element of the cache array when the read pointer points to the last element of the cache array; when the read pointer does not point to the last element of the cache array, the read pointer is updated to point to the next element of the current element.
Step S3223: and (5) saving the read element (R message).
In this embodiment, a new storage method is realized by defining a data structure "R structure" (i.e., the structure of an R packet), and by using the data structure, a writing task is responsible for receiving a packet, preprocessing and storing a packet with a preset structure into a cache array (local memory cache area), and a reading task is responsible for reading a packet with a preset structure from the cache array (local memory cache area) and storing the packet. By the storage scheme, efficient disk storage and convenient access of the bus message are realized.
An embodiment of the present disclosure further provides a message storage system, referring to fig. 5, including: a memory and a processor;
the memory is used for storing a program for storing the message;
The processor is configured to read the program for storing a message, and execute the method for storing a message according to any embodiment of the disclosure.
The processor of the above embodiment of the present disclosure may be a general-purpose processor, including a Central Processing Unit (CPU), a network processor (Network Processor, NP for short), a microprocessor, etc., or may be other conventional processors, etc.; the processor may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf programmable gate array (FPGA), a discrete logic or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, or other equivalent integrated or discrete logic circuit, or a combination thereof. That is, the processor of the above-described embodiments may be any processing device or combination of devices that implement the methods, steps, and logic blocks disclosed in the embodiments of the present disclosure. If the disclosed embodiments are implemented, in part, in software, the instructions for the software may be stored in a suitable non-volatile computer-readable storage medium and executed in hardware using one or more processors to implement the methods of the disclosed embodiments. The term "processor" as used herein may refer to the above-described structure or any other structure suitable for implementation of the techniques described herein.
An embodiment of the present disclosure further provides a non-transitory computer readable storage medium storing a computer program, where the computer program when executed by a processor can implement a method for storing a message according to any embodiment of the present disclosure.
In summary, the present disclosure provides a method, a system, and a storage medium for storing a message, where the scheme implements a brand new storage scheme by defining a "structured and deterministic" data unit (i.e., a preset structure message) and a set of local memory buffer usage rules (i.e., write and read rules of a buffer array), which is applicable to various messages with various bus types and different load lengths. The scheme has the following advantages:
(1) Judging the state of the buffer area (whether the buffer array is empty) is simple: when the elements pointed by the write pointer and the read pointer are the same, the cache array is empty, and when the elements pointed by the write pointer and the read pointer are different, the cache array is not empty.
(2) The number of free array elements is simple to calculate.
(3) The buffer area is accessed in an array mode, no additional performance cost is caused, and errors can be avoided.
(4) The writing task and the reading task can run at full speed without any synchronous measures, and no error occurs.
(5) And subsequent processing (such as loading and analysis) after the R message is stored is also simple.
Those of ordinary skill in the art will appreciate that all or some of the steps, systems, functional modules/units in the apparatus, and methods disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof. In a hardware implementation, the division between the functional modules/units mentioned in the above description does not necessarily correspond to the division of physical components; for example, one physical component may have multiple functions, or one function or step may be performed cooperatively by several physical components. Some or all of the components may be implemented as software executed by a processor, such as a digital signal processor or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on computer readable media, which may include computer storage media (or non-transitory media) and communication media (or transitory media). The term "computer storage media" includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data, as known to those skilled in the art. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital Versatile Disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by a computer. Furthermore, as is well known to those of ordinary skill in the art, communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media.
Claims (10)
1. A method for storing messages, comprising:
Converting a received bus message into a preset structure message according to the type of the received bus message by executing a writing task, and storing the preset structure message into a cache array as an array element;
And reading a preset structure message from the cache array by executing a reading task, and saving the message.
2. The method for storing a message according to claim 1, wherein the storing the preset structure message as an array element in the cache array further comprises:
Initializing the cache array, and a write pointer and a read pointer corresponding to the cache array, and pointing the write pointer and the read pointer to the first element of the cache array;
The writing task and the reading task are established, wherein the writing task and the reading task are executed in parallel, the writing task is used for storing the preset structure message into a cache array according to the writing pointer, and the reading task is used for reading the preset structure message from the cache array according to the reading pointer.
3. The method for storing a message according to claim 2, wherein storing the message with the preset structure in the cache array according to the write pointer comprises:
writing the preset structure message into the element pointed by the writing pointer;
updating the element pointed by the write pointer after the writing is completed, including: updating the write pointer to point to the first element of the cache array when the write pointer points to the last element of the cache array; and updating the write pointer to point to the next element of the current element when the write pointer does not point to the last element of the cache array.
4. The method for storing a message according to claim 3, wherein before writing the preset structure message into the element pointed by the write pointer, the method further comprises:
Judging whether the cache array contains writable idle elements according to the elements pointed by the read pointer and the write pointer respectively, wherein the method comprises the following steps: when the write pointer points to the last element of the elements pointed by the read pointer, judging that the cache array has no writable idle element; when the write pointer does not point to the last element of the element pointed by the read pointer, judging that the cache array has a writable idle element;
Writing the preset structure message into the element pointed by the write pointer under the condition that the cache array contains the writable idle element;
And under the condition that the cache array does not contain the writable idle element, setting the writing task as circulation waiting.
5. The method for storing a message according to claim 2, wherein the reading the preset structure message from the cache array according to the read pointer includes:
judging whether the cache array is empty or not according to the elements pointed by the read pointer and the write pointer respectively;
reading the element pointed by the read pointer from the cache array under the condition that the cache array is not empty;
updating the element pointed by the read pointer after the reading is completed, including: updating the read pointer to point to the first element of the cache array when the read pointer points to the last element of the cache array; and updating the read pointer to point to the next element of the current element when the read pointer does not point to the last element of the cache array.
6. The method according to claim 5, wherein the determining whether the cache array is empty according to the elements pointed to by the read pointer and the write pointer respectively includes:
In the case that the read pointer and the write pointer point to the same element, the cache array is empty; in case the read pointer and the write pointer point to different elements, the cache array is not empty.
7. The method for storing a message according to claim 1, wherein the preset structure message includes the following fields: the method comprises the steps of a message unique identifier, a time stamp, a hardware channel number from which the message originates, a message type identifier, a message type key field, a message load length and message load data; the step of converting the bus message into a preset structure message according to the type of the received bus message comprises the following steps:
Confirming the message type identification field and the message type key field according to the message type of the bus message;
Confirming the key field of the message type according to the value of the key field of the bus message;
confirming a message load length field of the preset structure message according to the load length of the bus message;
confirming a message load data field of the preset structure message according to the load data of the bus message;
the message load data field is in an array form, and the capacity of the message load data array is set according to the maximum length of the load data of the bus message.
8. The method for storing messages according to claim 7, further comprising:
restoring the message type of the bus message according to the message type identification field of the preset structure message;
Restoring the value of the key field of the bus message according to the key field of the message type;
restoring the load length of the bus message according to the message load length field of the message with the preset structure;
and restoring the load data of the bus message according to the message load data field of the message with the preset structure.
9. A message storage system comprising: a memory and a processor; the method is characterized in that:
the memory is used for storing a program for storing the message;
The processor is configured to read the program for storing a message, and execute the method for storing a message according to any one of claims 1 to 8.
10. A non-transitory computer readable storage medium storing a computer program, wherein the computer program when executed by a processor is capable of implementing the message storage method of any one of claims 1 to 8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410455242.3A CN118316987A (en) | 2024-04-16 | 2024-04-16 | Message storage method, system and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410455242.3A CN118316987A (en) | 2024-04-16 | 2024-04-16 | Message storage method, system and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN118316987A true CN118316987A (en) | 2024-07-09 |
Family
ID=91729605
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202410455242.3A Pending CN118316987A (en) | 2024-04-16 | 2024-04-16 | Message storage method, system and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN118316987A (en) |
-
2024
- 2024-04-16 CN CN202410455242.3A patent/CN118316987A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110113420B (en) | NVM-based distributed message queue management system | |
US7111092B1 (en) | Buffer management technique for a hypertransport data path protocol | |
EP3260971A1 (en) | Data processing method and nvme storage | |
CN111949568B (en) | Message processing method, device and network chip | |
KR20200028477A (en) | Traffic measurement methods, devices, and systems | |
US20060069869A1 (en) | Enqueueing entries in a packet queue referencing packets | |
CN110119304B (en) | Interrupt processing method and device and server | |
EP2830269A1 (en) | Message processing method and device | |
US7111289B2 (en) | Method for implementing dual link list structure to enable fast link-list pointer updates | |
CN105573711B (en) | A kind of data cache method and device | |
CN108062235B (en) | Data processing method and device | |
US20040047361A1 (en) | Method and system for TCP/IP using generic buffers for non-posting TCP applications | |
US6738796B1 (en) | Optimization of memory requirements for multi-threaded operating systems | |
CN113836184A (en) | Service persistence method and device | |
US20060101172A1 (en) | System method structure in network processor that indicates last data buffer of frame packet by last flag bit that is either in first or second position | |
CN116955247B (en) | Cache descriptor management device and method, medium and chip thereof | |
US8094552B1 (en) | Adaptive buffer for frame based storage communications protocols | |
CN111797497B (en) | Communication method and system for electromagnetic transient parallel simulation | |
US8407444B2 (en) | Hardware off-load garbage collection acceleration for languages with finalizers | |
US8363653B2 (en) | Packet forwarding method and device | |
US8473579B2 (en) | Data reception management apparatus, systems, and methods | |
CN115002052B (en) | Layered cache controller, control method and control equipment | |
CN118316987A (en) | Message storage method, system and storage medium | |
US9338219B2 (en) | Direct push operations and gather operations | |
CN114024844B (en) | Data scheduling method, data scheduling device and electronic equipment |
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 |