CN115643538A - Message scheduling method and device based on priority information - Google Patents

Message scheduling method and device based on priority information Download PDF

Info

Publication number
CN115643538A
CN115643538A CN202211323388.XA CN202211323388A CN115643538A CN 115643538 A CN115643538 A CN 115643538A CN 202211323388 A CN202211323388 A CN 202211323388A CN 115643538 A CN115643538 A CN 115643538A
Authority
CN
China
Prior art keywords
message
messages
class
priority information
loading
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.)
Granted
Application number
CN202211323388.XA
Other languages
Chinese (zh)
Other versions
CN115643538B (en
Inventor
刘鹏
王凡
刘宝龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Qingdao Yixiang Yichuang Technology Development Co ltd
Original Assignee
Qingdao Yixiang Yichuang Technology Development Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Qingdao Yixiang Yichuang Technology Development Co ltd filed Critical Qingdao Yixiang Yichuang Technology Development Co ltd
Priority to CN202211323388.XA priority Critical patent/CN115643538B/en
Priority to CN202311127703.6A priority patent/CN117241231A/en
Publication of CN115643538A publication Critical patent/CN115643538A/en
Application granted granted Critical
Publication of CN115643538B publication Critical patent/CN115643538B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The application discloses a message scheduling method and device based on priority information, which comprises the steps of constructing a message linked list based on a message structure body based on messages obtained from at least one second device, wherein the message linked list stores the priority information, message content and message equipment addresses of the messages corresponding to each message; loading the messages in the message linked list into a message queue based on the priority information, the message content and the message equipment address, carrying out dynamic polling on the message queue according to the number of the messages in the message queue so as to send the message content to the first device, and sending the feedback obtained from the first device to a second device with the message equipment address. The message priority in the method ensures that the emergency message can be executed preferentially, and the second-class message and the third-class message are executed according to the dynamic proportion.

Description

Message scheduling method and device based on priority information
Technical Field
The present application relates to mobile communication technologies, and in particular, to a method and an apparatus for scheduling message operations.
Background
In order to make the surrounding environment have more realistic substitution feeling, more devices are needed to complete the effect. As the number of devices increases, the timeliness and stability of communication between devices becomes important.
In the traditional application, the devices are mutually isolated, the application is simple, only one piece of software needs to be specially customized for one effect or one function, and the self-sufficiency is met. But the use scene is more limited, is not suitable for the cooperation of multiple devices and has lower flexibility. The cost in terms of post-maintenance will also increase considerably, and system ease of use and maintainability are increasingly being considered as technology advances.
In software aspect, a set of multi-device message management mechanism is urgently needed to meet the increasing demand. The method is mainly used for ensuring data exchange with an upper computer, updating firmware and configuration at a far end and ensuring that messages correctly react to the outside in fixed time.
Disclosure of Invention
One of the problems addressed by the present application is the timeliness and stability of message processing in the case of multiple devices.
To this end, some embodiments of the present application provide a message scheduling method based on priority information for an interaction of a first apparatus with at least one second apparatus, the method comprising the steps of: constructing a message linked list based on a message structure based on messages obtained from at least one second device, wherein the message linked list stores priority information, message content and message equipment addresses of the messages corresponding to each message; loading messages in a message chain table into a message queue based on the priority information, the message content and the message equipment address, dynamically polling the message queue according to the number of the messages in the message queue to send the message content to the first device, and sending feedback obtained from the first device to a second device with the message equipment address.
In some embodiments, the message structure comprises a message status, a message real-time, a message start time, a message end time, a length of a message, a message device address, and a message content, wherein the message is prioritized according to the message status.
In some embodiments, the priority information includes urgent information indicating the highest priority, second-class information indicating a medium priority, and third-class information indicating the lowest priority; and constructing an emergency message structural body aiming at the emergency information, a second-class message structural body aiming at the second-class information and/or a third-class message structural body aiming at the third-class information.
In some embodiments, messages are cyclically loaded into the message queue in fixed time slices, wherein messages are loaded using a first loading rule in a first time slice, messages are loaded using a second loading rule in a second time slice that is temporally consecutive to the first time slice, and messages are loaded using a third loading rule in a third time slice that is temporally consecutive to the second time slice.
In some embodiments, the first loading rule comprises a priority loading of the urgent message, the second loading rule comprises a first quantity proportion of the priority second-class message and a third-class message, except the priority loading of the urgent message, and the third loading rule comprises a second quantity proportion of the priority second-class message and a third-class message, except the priority loading of the urgent message, wherein the first quantity proportion is greater than the second quantity proportion.
In some embodiments, the polling latency and the number of second devices that need to poll are dynamically calculated as a function of the actual number of messages in the message queue.
In some embodiments, feedback of data verification information by the first device to the second device is included.
In some embodiments, the method includes loading the message actively transmitted by the second device into the message queue as a second-class message.
Yet other embodiments of the present application provide a message scheduling apparatus based on priority information, which includes a program module that constructs a message linked list based on a message structure based on messages obtained from at least one of the second apparatuses, wherein the message linked list stores priority information of the messages, message contents, and message device addresses corresponding to each of the messages; the program module loads the messages in the message chain table into the message queue based on the priority information, the message content and the message equipment address, and dynamically polls the message queue according to the number of the messages in the message queue to send the message content to the first device and send the feedback obtained from the first device to the program module of the second device with the message equipment address.
Still further embodiments of the present application include at least one processor and at least one memory including computer program code, wherein the at least one memory and the computer program code are configured to, with the at least one processor, cause the apparatus at least to perform any of the above-described priority information based message scheduling methods.
Advantages seen by the method and apparatus in embodiments of the present application include, but are not limited to, 1) the message management layer and the message execution layer communicate data through mailboxes, making high concurrency low coupling of the message receiving layer and the message sending layer. 2) It is ensured that the devices with the largest capacity of the queue can receive different control messages during one processing cycle, e.g. within one time slice. 3) For the dynamic polling of the mounted equipment, the polling data of the equipment in use is ensured, and the unused equipment is silent, so that the real-time efficiency is improved. 4) The message priority ensures that urgent messages can be executed preferentially, and second-class messages and third-class messages are executed according to a dynamic proportion. 5) And the Real-Time property double-layer of the Thread of the Real-Time-Thread operating system is combined to ensure the stability and Real-Time property of the message. 8) By means of fixed time slice scheduling, high-priority messages in the message queue can be processed emergently, and the problem that the messages are blocked and cannot be processed timely is solved. 9) Through a polling mechanism with priority, the problem that if the execution of the message is lost, the alarm can be given in time is solved.
Drawings
Fig. 1 is a flowchart of serial port 2 data reception according to the message transmission method in the embodiment of the present application.
Fig. 2 is a flowchart of serial port 3 data reception according to a method of an embodiment of the present application.
Fig. 3 is a flowchart of serial port 2 data processing according to a method of an embodiment of the present application.
Fig. 4 is a flowchart of serial port 2 data processing according to a method of an embodiment of the present application.
Fig. 5 is a flow diagram of time slice scheduling according to a method of an embodiment of the present application.
Fig. 6 is a flowchart of a lower computer device message feedback process according to a method of an embodiment of the present application.
Fig. 7 is a flow diagram of polling a message queue according to a method of an embodiment of the present application.
FIG. 8 is a flow diagram of a main function of a method according to an embodiment of the present application.
Fig. 9 is a hardware configuration diagram of an applicable environment of a method according to an embodiment of the present application.
Fig. 10 is a software architecture diagram of a transmitting device according to an embodiment of the present application.
Fig. 11 is a schematic diagram of message queue construction according to an embodiment of the application.
Fig. 12 is a diagram illustrating polling of a message queue according to an embodiment of the application.
Detailed Description
When processing messages, the traditional mode adopts a first-in first-out mode, which affects the timeliness of message processing and causes the situation that messages with high priority are preempted by low priority, so that the message scheduling method and device based on priority information in the application are designed.
The method and apparatus proposed in the embodiments of the present application can be applied to, but are not limited to, the following hardware environments:
the embedded control system shown in fig. 9 includes a core board 100, and a processor and a memory are provided on the core board 100 to provide a processing function and a control function, which are responsible for global orchestration and underlying logical processing. The network board 200 is responsible for network connection and data forwarding, and is connected to the internet through a network cable, and the network board 200 may implement serial connection to the communication core board 100 through a flat cable. The communication board 300 is responsible for polling and distributing the instructions from the core board 100 forwarded by the network board 200 to various organization points through a good algorithm, an embedded real-time multithreading operating system is installed in the communication board, and the overall stability and expandability of the equipment can be greatly improved by reasonably distributing the functions of various modules.
Here, the communication board 300 itself may be an embedded communication system, and has a processor, a memory, and a communication module, where the communication module may include a first communication port, such as a first serial port, and a second communication port, such as a second serial port, the communication board 300 is configured to receive, from the network board 200, an instruction of the core board 100 forwarded by the network board 200, and perform information interaction with one or more lower computer device 400 systems, for example, the communication board 300 may connect two or more lower computer devices through an RS-422 full-duplex serial communication interface, referred to as serial port 2, and the communication board 300 may further connect the network board 200 through another RS-422 full-duplex serial communication interface, referred to as serial port 3, so as to form a communication system. Although only three lower computer devices 400 are shown in the figure, it should be understood that it is also applicable to systems comprising other numbers of lower computer devices, such as 4, 8, 16, 32, 62, etc.
Each lower computer device is an independent device, can be provided with a processor, a memory, a communication module and the like, can be connected with a communication board through an RS-422 full-duplex communication interface to carry out cascade connection and interaction of multiple devices, and can automatically run main logic according to internal configuration under the condition of not carrying out external intervention. The advantages of centralized control and decentralized control are well combined. The network board can adopt a Message Queue Telemetry Transport (MQTT) protocol and/or a hypertext transfer protocol (HTTP) protocol to carry out data transmission, and the core board receives data sent by the network board, processes the data and distributes the data to the communication board, and controls the communication board to carry out polling control on a lower computer.
In some embodiments of the present application, the method and apparatus in the present application may be developed based on an embedded real-time multithread operating system, and the data transmission in the message delivery may be described by using a lightweight data exchange format, such as JavaScript Object notification, JSON. The computer program can be written for use using standard C language. It should be understood that the implementation of the methods and apparatus herein is not limited to the data formats, descriptions, and programming languages described above.
FIG. 10 is a software architecture of an application environment according to an embodiment of the present application. Wherein the software package comprises a CJSON library, an ITA library, a U8G2 library and a FAL library; the user service layer comprises a message management service, a display service (such as an LCD display service), a UART _ DEAL service and an APP service; the bottom layer is a combination of real-time multithreading and a component and service layer.
The flow of the main function and the respective threads according to some embodiments of the present application is as follows.
Initialization of a main function:
as shown in fig. 1, the main function initialization includes creating and starting seven threads, i.e., thread 1 to thread 7, and creating a mailbox with a message queue corresponding to each thread, step S001; then, a request, for example, JSON-formatted data, is sent to request one or more lower computer device addresses, step S002; the requested lower computer device address is then saved, step S003.
The seven threads created in this embodiment include:
and the thread 1 is a first serial port data receiving thread and is used for receiving data from the serial port 2. As shown in fig. 2, in the thread 1, the following processing is performed, first, data from the serial port 2 is waited, step S101, when the 1 st byte is received, 5ms timing is started, and when the 1 byte is received, 5ms is cleared and the timing is restarted until the 5ms timing is over, step S102; then, a semaphore notification is sent to the thread 3 to process the data received by the serial port 2, step S103.
And the thread 2 is a second serial port data receiving thread and is used for receiving data from the serial port 3. Waiting for data from the serial port 3, step S201, determining whether a data header frame is received, if so, starting timing for 5 milliseconds, emptying 5 milliseconds after receiving a byte, and timing again until the timing for 5 milliseconds is full, step S202; then, a semaphore notification is sent to the thread 4 to process the data received by the serial port 3, step S203.
And the thread 3 is a first serial port data processing thread and is used for processing the data received from the serial port 2. As shown in fig. 3, the thread includes first waiting for semaphore notification from thread 1, step S301; if yes, starting to receive data, analyzing read addresses of the keywords such as CMD, LIST and the like by using CJOSN analysis on the received data so as to obtain message classification, loading the analyzed data into a linked LIST of corresponding emergency messages, second-class messages, third-class messages and the like in a message structure form according to the message classification, setting state bits in the linked LIST according to the definition of the message structure, and S302; after which the received data is emptied, step S303.
And the thread 4 is a second serial port data processing thread and is used for processing the data received from the serial port 3. As shown in fig. 4, the thread includes a step of waiting for semaphore notification of the thread 2, step S401, if there is the semaphore notification, packing HEX format data from the serial port 3 into JSON data to be sent, and sending a mailbox notification to the thread 7, step S402.
Thread 5, the slice scheduling thread. Referring to fig. 5, after the fixed time slice scheduling step S500 is started, whether the states of the emergency message structure, the second-order message structure, or the third-order message structure in the message chain table are set is scanned, step S501, if set, the first 100-millisecond time slice scheduling is opened, and the data in the corresponding message chain table is loaded into the polling message queue step S502, and if not set, the process continues to wait; the loading of the data into the polling message queue includes adopting a first loading rule, that is, preferentially loading the urgent message in the message link list and determining whether the queue is full, that is, step S503, if the queue is full, sending a semaphore to notify the message polling thread 7, step S505, suspending the current thread, and waiting for 100 milliseconds to finish the execution of the polling thread 7, step S504; if the time is 100 milliseconds, starting the second time slice scheduling, and then starting the third time slice scheduling, step S506; if the message queue is judged not to be full, the second-class message is loaded preferentially and then whether the message queue is full is judged, step S507, if the queue is full, steps S504, S505 and S506 are executed, if the queue is not full, the third-class message is loaded preferentially and whether the queue is full is judged, step S508, and if the queue is full, steps S504, S505 and S506 are executed.
The scheduling of the second time slice and the scheduling of the third time slice, step S506, may then follow the following rules to apply the second loading rule when the second 100 ms time slice loads messages: i.e. emergency messages are loaded preferentially, when the message queue is not full and no emergency message can be loaded, then according to 5: the ratio of 1 loads the second-class message and the third-class message in the message linked list. Such a rule may basically guarantee that the second-order message can be responded to once within 200 milliseconds. At the time of loading the message for the third 100 millisecond timeslice, a third loading rule is employed: i.e. emergency messages are loaded preferentially, when the message queue is not full and no emergency message can be loaded, then according to 2: the ratio of 1 loads the second-class message and the third-class message in the message linked list. This basically ensures that three equal messages can be responded to once in 300 milliseconds. The above rules can basically ensure that messages sent by all connected devices are processed in time in three time slices.
Thread 6, message feedback processing thread. Referring to fig. 6, after the thread 6 is created, the mailbox notification from the thread 7 is always waited, step S601, if there is a notification, it is determined whether the address is correct, step S602, if the address is correct, the data in the message linked list is emptied according to the priority parameter of the message, step S603.
Thread 7, the message queue polling thread. As shown in fig. 7, the thread 7 is configured to poll the message queue, and first wait for a time slice semaphore, step S701, if there is a signal in a time slice, send a message from the serial port 3 according to a protocol, where the protocol format is shown in table 1, where it is assumed that there are N messages in the message queue, for example, 5 messages shown in fig. 7, step S702; waiting for mailbox notification of the thread 4 or suspending the thread for 5 milliseconds, step S703, continuing polling the next message when the time is up or if mailbox notification from the thread 4 is received, notifying the thread 6 through the mailbox of the thread, releasing corresponding data in the message chain table, and continuing polling the next message, wherein the next message is the 2/N message, step S703; if there is no mailbox notification from thread 4, an alert message is generated and presented, for example, the alert message is displayed on a display device and/or the alert novelty is displayed in an audible or light manner, and the next message in the message queue, i.e., 2/N, is polled, step S704.
Table 1:
header frame 1 Header frame 2 Length of High address Address low Control command Specific data 1 Specific data 2 Specific data 3
FF AA len ADDR_H ADDR_L 1 1 1 1
Message structure body:
the created message structure may include a plurality of message structures of different priorities. Each message structure may include the following elements: message status, message real-time, message start time, message end time, length of the message, device address of the message, specific content data in the message. For example, a message structure corresponding to the emergency message of the highest priority, a message structure corresponding to the second-class message of the intermediate priority, and a message structure corresponding to the third-class message of the lowest priority may be created. Message structures of different priorities can be distinguished by a message structure element of "message status". For example, a message structure corresponding to an urgent message may be set with a message state of "1", a message structure corresponding to a second-class message may be set with a message state of "2", and a message structure corresponding to a third-class message may be set with a message state of "3".
Message chain table:
and creating a message linked list, wherein the message linked list stores data in the form of the message structure body, and the linked list can be a dynamic linked list or a static linked list. After the interactive messages come in, the received messages are stored in the created message linked list one by one in the form of an emergency message structural body, a second-level message structural body or a third-level message structural body according to the message states.
Message queue loading:
and creating a polling message queue, and then loading the data in the linked list into the polling message queue, wherein the loading mode of the polling message queue comprises that the data in the message linked list is loaded in a fixed time slice.
The length of the time slice may be determined according to system requirements, and the manner of loading messages to the polling message queue in a fixed time slice of 100 milliseconds (ms) may be, for example: when loading a message in the first 100 milliseconds, i.e. first time slice, a first loading rule is applied: the first time slice is used for reloading the second-class message in the second-class message structure body in the message linked list if the polling message queue is not full, and the third-class message in the third-class message structure body in the message linked list is reloaded if the polling message queue is not full. This ensures that each urgent message can be processed first.
The second loading rule may be employed when loading messages into the polling message queue for a second time slice, i.e., a second 100 millisecond time slice, consecutive to the first time slice, different from the first loading rule for the first time slice: i.e. emergency messages are loaded preferentially, when the message queue is not full and no emergency message can be loaded, then according to 5: the second-class message and the third-class message in the message linked list are loaded in the proportion of 1. Such a rule may basically guarantee that a second-order message can be responded to once within two time slice lengths, i.e., 200 milliseconds.
By analogy, when the third 100 msec time slice loads a message, a third loading rule is employed: i.e. emergency messages are loaded preferentially, when the message queue is not full and no emergency message can be loaded, then according to 2: the ratio of 1 loads the second-class message and the third-class message in the message linked list. This basically ensures that three messages can be responded to once in three time slice lengths, i.e., 300 milliseconds.
In some embodiments, while loading the second-order message and the third-order message: and calculating out which of the second-class message and the third-class message is the most urgent according to the three elements of the starting time, the real-time and the ending time in the structure body, so that the messages are loaded to the polling message queue according to the degree of tightness. After the most urgent message in the second-class message and the third-class message is responded, the most urgent message in the no response message is loaded again. In some embodiments, messages may be loaded into the polling message queue according to priority, and after the messages in the message queue are sent out, feedback needs to be received normally to ensure that the messages arrive correctly. Compared with the traditional broadcasting mode, the method has the advantage that the message correctness is guaranteed.
In addition, when it is determined that a certain device needs to actively upload a message, the actively uploaded message can be stored in a message chain table in a second-class message structure, and then the message is added into a polling message queue in the priority of the second-class message, the second-class message participates in polling, in the process, data from the device actively uploading the message can be extracted in the form of the second-class message structure until the state in the second-class message structure is actively set, and the polling is not participated.
Polling of message queues
Conventional polling typically uses a fixed polling time, so that the pressure on the device to process data can be large. While polling of the message queue in the embodiments of the present application dynamically calculates the polling latency according to the actual number of messages in the message queue, unlike conventional polling. The dynamic polling in the embodiments of the present application will determine the frequency of polling according to the amount of actual data in the queue, giving the device more time to process other tasks.
Each message needing to be polled comprises the address of the equipment and the command of the equipment, the equipment needing to be polled is determined according to the specific equipment address, and the specific time needing to be polled is determined according to the length of the message queue.
And when the lower computer device gives feedback or the waiting time is reached, continuously polling the next frame data, and repeating the steps.
The timeliness of information interaction can be improved by dividing the messages according to the priority. The polling mechanism is dynamically adjusted, so that the equipment has more time to complete other tasks.
According to the embodiment of the application, the polling equipment is dynamically adjusted by the equipment through the priority division of the messages, so that the bandwidth utilization rate of a data bus can be effectively improved, and the response speed of the equipment is improved. For example: a total of 30 devices are mounted, wherein only 3 devices are active at the same time, each device takes 5ms, and the device polling efficiency is as shown in table 2 below:
table 2:
10 pieces of equipment 20 devices 30 devices
Dynamic polling 3 devices 15ms 15ms 15ms
Polling all devices 50ms 100ms 150ms
A messaging device according to embodiments of the present application may include a first mode and a second mode, namely a command mode and a file mode. In the command mode the above-mentioned messaging method can be performed, while in the second mode, i.e. the file mode: waiting for receipt of a file transfer command, the current poll is suspended. And dividing the file into a plurality of packets according to the size, sending the packets to the lower computer equipment of the corresponding address, wherein each packet of data can obtain an ACK feedback, and waiting for polling before the recovery of the reading context after the data transmission is finished.
One specific example of the method of the present application includes:
the method comprises the steps of initializing, wherein an emergency message structural body corresponding to emergency messages, a second-class message structural body corresponding to second-class messages, a third-class message structural body corresponding to third-class messages, a message linked list and a message queue are created.
Each message structure includes elements: the status of the message, the real-time of the message, the start time of the message, the end time of the message, the length of the message, the device address of the message, and the specific data in the message.
The code that creates the message structure may be:
# define MESSAGE _ LEN 100// MESSAGE body Length
typedef struct{
u8 sta[MESSAGE_LEN];
u32 time[MESSAGE_LEN];
u32 start_time[MESSAGE_LEN];
u32 end_time[MESSAGE_LEN];
u8 len[MESSAGE_LEN];
u16 addr[MESSAGE_LEN];
u8 buf[MESSAGE_LEN][10];
}MODU_USER_MESSAGE;
MODU _ USER _ MESSAGE Press _ msg// urgent MESSAGE structure
MODU _ USER _ MESSAGE Second _ class _ msg// Second-class MESSAGE structure
MODU _ USER _ MESSAGE Third _ class _ msg// Third etc. MESSAGE structure
After the initialization is completed, packaging JSON data transmission through a CJSON library to request the addresses of all the lower computer equipment. And receiving the returned data of each lower computer Device, storing the analyzed address of each lower computer Device into a Device _ Addr array according to the read addresses of keywords such as 'cmd', 'ads', 'list' and the like in the CJSON library analysis data, and storing the Number of the lower computer devices into a Device _ Number variable.
Caching all addresses in the Device _ Addr array into a second-class message structure body, starting one-time polling, searching whether the devices are all online, and alarming in an LCD of the devices if no online lower computer Device exists, and requesting to check whether a hardware link is normal.
And waiting for the JSON format data received by the serial port 2, analyzing the data according to the CJSON library, dividing the messages into an emergency message, a second-class message and a third-class message, and storing the effective data into corresponding message structure bodies.
The way of loading data in the message structure is: for an urgent message: setting the state of a message structure as 1 to represent an emergency message, wherein the data length is determined according to the effective content length of the message, the address is the address in the Device _ Addr array, the real-time of the message is 100, the end time is 100+ rt_tick_get (), the start time is rt _ tick _ get (), and the specific data is the received effective data. Where rt _ tick _ get () is a function that extracts the current time of the system.
For the second-class message: setting the state of a message structure as 2, representing a second-class message, wherein the data length is 6, the address is the address in a Device _ Addr array, the real-time of the message is 200, the end time is 200+ rt_tick \, and the start time is rt _ tick _ get (); specific data are 0xFF, 0XAA, 0X06, addr _ H, addr _ L, 0X01.
For the third-class messages: setting the state of a message structure as 3, determining the data length according to the valid data of the message, wherein the address is the address in a Device _ Addr array, the real-time of the message is 300, the end time is 300+ rt_tick \, and the start time is rt _ tick _ get (); the specific data depends on the message content.
The specific time slice scheduling mode is as follows:
in the time slice scheduling thread, when the state in the waiting structure is not 0, performing first 100 ms scheduling, buffering data of the emergency message structure into the polling message queue, and then determining the number of remaining empty spaces in the message queue, for example, as shown in fig. 11, in this embodiment, the message queue is configured to buffer 20 messages at maximum, if there is a remaining message, reading the second-order message structure, continuing to buffer into the polling message queue, determining whether the polling message queue is full, if the message queue is not full, continuing to buffer the third-order message until the polling message queue is full or all messages are in the polling message queue, and then sending a semaphore to notify the polling thread to start polling data, and suspending the self thread.
Scheduling for 100 milliseconds for the second time, preferentially caching data in the emergency message structure into the polling message queue, judging the number of the remaining vacant positions in the message queue, and if the remaining vacant positions exist, enabling the remaining vacant positions to be in accordance with the number 5 of second-class messages and third-class messages: the mode of 1 buffers the second-class message and/or the third-class message into a polling message queue; the priority rule of the second-class message and the third-class message is as follows: the same priority first-in first-out order. Thereafter, a semaphore is sent to notify the polling thread to start polling data, and the thread is suspended.
Scheduling for 100 milliseconds for the third time, preferentially caching data in the emergency message structure into a polling message queue, judging the number of the remaining vacant sites in the message queue, and if the vacant sites still exist, then enabling the remaining vacant sites to be according to the number 2 of second-class messages and third-class messages: the mode of 1 buffers the second-class message and/or the third-class message into the polling message queue. The priority rule of the second-class message and the third-class message is as follows: the same priority first-in first-out order. And sending a semaphore to inform the polling thread to start polling data, and suspending the self thread.
The specific polling method:
similarly, as shown in fig. 12, the polling thread waits for the semaphore of the slot scheduling thread and the packed HEX data is sent to the lower computer device. The polling thread is suspended until the mailbox feedback information "mb" of the polling confirmation thread is received, or the time of 100/number of actual polling devices is waited, which is unit of millisecond and is 5 milliseconds at minimum.
Because the baud rate sent to the lower computer is 115200, the maximum data volume sent does not exceed 10 bytes, wherein the maximum data volume comprises 1 starting bit, 1 stopping bit and 8 bit data bits; so the transmission time is: 1000/115200 x 10 (data length) milliseconds. The receiving time and the sending time are consistent.
And after the polling confirmation thread receives the data fed back from the polling thread, judging the length of the data, and judging whether the JSON data needs to be packaged and fed back to the upper computer, and finally sending a mailbox to inform the polling thread that the feedback is received.
And if the polling thread waits for the mailbox notification, sending a mailbox notification message feedback thread to empty the data in the corresponding structural body in the message linked list, wherein the message structural body does not add time slice scheduling any more next time. If the thread suspension time is up, and the mailbox feedback is not received, alarm information is generated and sent to an LCD for alarm display, and then the next time slice is circulated again for scheduling.
And finally, finishing polling until the states in the message structure body are all 0, and waiting for a new message.
It should be understood that although embodiments of the present application have 100 milliseconds as a parameter of the time slice, it should be understood that other lengths of time slices, shorter or longer, are possible, such as 10 milliseconds, 50 milliseconds, 200 milliseconds, 300 milliseconds. Although the embodiment of the present application uses 20 messages as the length of the message queue, it should be understood that message queues with other lengths, which are shorter or longer, may be reasonably determined according to the number of the lower computer devices, for example, 10, 30, 50, 100. Although the embodiments of the present application describe the method in the present application with the communication board as the first device and the at least one lower computer apparatus as the at least one second device, it should be understood that the method of the present application may be applied to a system having the same structure for transmission of messages without or with slight adjustment. For example, the communication board may not receive instructions from other control systems, such as a core board, but generate instructions directly by itself, in which case the serial port 3 is not required to communicate with other devices to receive instructions. In other embodiments, other appropriate communication methods may be used in addition to the inter-thread communication methods described in the embodiments, such as one of semaphores, message queues, mailboxes, and the like.
Embodiments of the present application may also include apparatuses corresponding to the methods, which may include computer program modules corresponding to the respective procedures of the methods described above.
In some example embodiments, the functions of any of the methods, processes, signaling diagrams, algorithms, or flow diagrams described herein may be implemented by software and/or computer program code or portions of code stored in memory or other computer-readable or tangible media, and executed by a processor.
In some example embodiments, an apparatus may be included or associated with at least one software application, module, unit or entity configured as arithmetic operations, or as programs or portions thereof (including added or updated software routines), executed by at least one operating processor. Programs, also referred to as program products or computer programs, including software routines, applets and macros, may be stored in any device-readable data storage medium and may include program instructions for performing particular tasks.
A sequence is a unit of a data structure that may include strings, lists, tuples, and the like.
A computer program product may include one or more computer-executable components configured to perform some example embodiments when the program is run. The one or more computer-executable components may be at least one software code or code portion. Changes and configurations to implement the functions of the example embodiments may be performed as routines, which may be implemented as added or updated software routines. In an example, a software routine may be downloaded into the device.
By way of example, the software or computer program code or portions of code may be in source code form, object code form, or in some intermediate form, and may be stored on some type of carrier, distribution medium, or computer-readable medium, which may be any entity or device capable of carrying the program. Such a carrier may comprise, for example, a record medium, computer memory, read-only memory, an opto-electrical and/or electrical carrier signal, a telecommunication signal and/or a software distribution package. Depending on the required processing power, the computer program may be executed in a single electronic digital computer or may be distributed over a plurality of computers. The computer-readable medium or computer-readable storage medium may be a non-transitory medium.
In other example embodiments, the functions may be performed by a router, for example, using an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (PGA), a Field Programmable Gate Array (FPGA), or any other hardware and software combination. In yet another example embodiment, the functionality may be implemented as a signal, such as an intangible means that may be carried by an electromagnetic signal downloaded from the Internet or other network.
According to example embodiments, an apparatus such as a node, device or response means may be configured as a circuit, a computer or a microprocessor (such as a single chip computer element) or a chipset, which may comprise at least a memory for providing storage capacity for arithmetic operations and/or an operation processor for performing arithmetic operations.
The example embodiments described herein are equally applicable to both singular and plural implementations, regardless of whether the language used to describe certain embodiments is in the singular or plural. For example, embodiments describing the operation of a single computing device are equally applicable to embodiments that include multiple instances of the computing device, and vice versa.
One of ordinary skill in the art will readily appreciate that the example embodiments as described above may be implemented with operations in a different order and/or with hardware elements in configurations different from those disclosed. Thus, while some embodiments have been described based upon these example embodiments, it would be apparent to those of ordinary skill in the art that certain modifications, variations, and alternative constructions would be apparent, while remaining within the spirit and scope of the example embodiments.

Claims (10)

1. A method for message scheduling based on priority information for interaction of a first device with at least one second device, characterized by: the method comprises the following steps:
constructing a message linked list based on a message structure body based on messages obtained from at least one second device, wherein the message linked list stores priority information, message content and message equipment addresses of the messages corresponding to each message;
loading messages in a message link list into a message queue based on the priority information, the message content, and the message device address, an
And dynamically polling the message queue according to the number of messages in the message queue to send the message content to the first device, and sending feedback obtained from the first device to a second device with the message equipment address.
2. The method for scheduling message based on priority information according to claim 1, wherein: the message structure body comprises a message state, a message real-time, a message starting time, a message ending time, a message length, a message equipment address and a message content, wherein the priority of the message is determined according to the message state.
3. The method of claim 2, wherein the message scheduling method based on the priority information comprises: the priority information comprises emergency information indicating the highest priority, second-class information indicating a medium priority and third-class information indicating the lowest priority; and constructing an emergency message structural body aiming at the emergency information, a second-class message structural body aiming at the second-class information and/or a third-class message structural body aiming at the third-class information.
4. The method of claim 3, wherein the message scheduling method based on the priority information comprises: and circularly loading the messages to the message queue according to the fixed time slices, wherein the messages are loaded by adopting a first loading rule in a first time slice, the messages are loaded by adopting a second loading rule in a second time slice which is continuous with the first time slice, and the messages are loaded by adopting a third loading rule in a third time slice which is continuous with the second time slice.
5. The method of claim 4, wherein the message scheduling method based on the priority information comprises: the first loading rule comprises a first quantity proportion loading second-class messages and third-class messages of first-class messages except the first-class loading emergency messages, and the third loading rule comprises a second quantity proportion loading second-class messages and third-class messages of first-class messages except the first-class loading emergency messages, wherein the first quantity proportion is larger than the second quantity proportion.
6. The method for scheduling message based on priority information according to claim 1, wherein: and dynamically calculating the polling waiting time and the number of second devices needing polling according to the actual number of messages in the message queue.
7. The method of claim 3, wherein the message scheduling method based on the priority information comprises: including feeding back data verification information by the first device to the second device.
8. The method of claim 3, wherein the message scheduling method based on the priority information comprises: including loading the message actively transmitted by the second device into the message queue as a second-class message.
9. Message scheduling device based on priority information, characterized by: the method comprises the steps of constructing a message linked list based on a message structure body based on messages obtained from at least one second device, wherein the message linked list stores priority information, message content and message equipment addresses of the messages corresponding to each message; the program module loads the messages in the message chain table into the message queue based on the priority information, the message content and the message equipment address, and dynamically polls the message queue according to the number of the messages in the message queue to send the message content to a first device and send the feedback obtained from the first device to a second device with the message equipment address.
10. Message scheduling device based on priority information, characterized by: at least one memory including computer program code and at least one processor, wherein the at least one memory and the computer program code are configured to, with the at least one processor, cause the apparatus at least to perform the priority information based message scheduling method of any of claims 1 to 8.
CN202211323388.XA 2022-10-27 2022-10-27 Message scheduling method and device based on priority information Active CN115643538B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202211323388.XA CN115643538B (en) 2022-10-27 2022-10-27 Message scheduling method and device based on priority information
CN202311127703.6A CN117241231A (en) 2022-10-27 2022-10-27 Message scheduling method and device based on priority information

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211323388.XA CN115643538B (en) 2022-10-27 2022-10-27 Message scheduling method and device based on priority information

Related Child Applications (1)

Application Number Title Priority Date Filing Date
CN202311127703.6A Division CN117241231A (en) 2022-10-27 2022-10-27 Message scheduling method and device based on priority information

Publications (2)

Publication Number Publication Date
CN115643538A true CN115643538A (en) 2023-01-24
CN115643538B CN115643538B (en) 2024-01-30

Family

ID=84947092

Family Applications (2)

Application Number Title Priority Date Filing Date
CN202211323388.XA Active CN115643538B (en) 2022-10-27 2022-10-27 Message scheduling method and device based on priority information
CN202311127703.6A Pending CN117241231A (en) 2022-10-27 2022-10-27 Message scheduling method and device based on priority information

Family Applications After (1)

Application Number Title Priority Date Filing Date
CN202311127703.6A Pending CN117241231A (en) 2022-10-27 2022-10-27 Message scheduling method and device based on priority information

Country Status (1)

Country Link
CN (2) CN115643538B (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101996099A (en) * 2010-11-17 2011-03-30 山东中创软件工程股份有限公司 Method and system for processing information
CN102487494A (en) * 2009-10-26 2012-06-06 中国电信股份有限公司 Short message flow control method and system
CN109639782A (en) * 2018-11-30 2019-04-16 中体彩科技发展有限公司 Message sends platform, method
CN110071879A (en) * 2019-03-15 2019-07-30 中科恒运股份有限公司 Method for message transmission, terminal device and storage medium
CN111245745A (en) * 2020-01-07 2020-06-05 腾讯科技(深圳)有限公司 Message sending method, device, node equipment and storage medium
CN111510395A (en) * 2020-06-16 2020-08-07 腾讯科技(深圳)有限公司 Service message reporting method, device, equipment and medium
CN111757280A (en) * 2019-03-27 2020-10-09 阿里巴巴集团控股有限公司 Perception base station in road traffic environment and message sending control method and device thereof
CN111866769A (en) * 2020-06-29 2020-10-30 湖南省梦网科技发展有限公司 Message sending method, device, server and medium
CN113010297A (en) * 2021-04-23 2021-06-22 北京秒针人工智能科技有限公司 Database write scheduler based on message queue, write method and storage medium

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102487494A (en) * 2009-10-26 2012-06-06 中国电信股份有限公司 Short message flow control method and system
CN101996099A (en) * 2010-11-17 2011-03-30 山东中创软件工程股份有限公司 Method and system for processing information
CN109639782A (en) * 2018-11-30 2019-04-16 中体彩科技发展有限公司 Message sends platform, method
CN110071879A (en) * 2019-03-15 2019-07-30 中科恒运股份有限公司 Method for message transmission, terminal device and storage medium
CN111757280A (en) * 2019-03-27 2020-10-09 阿里巴巴集团控股有限公司 Perception base station in road traffic environment and message sending control method and device thereof
CN111245745A (en) * 2020-01-07 2020-06-05 腾讯科技(深圳)有限公司 Message sending method, device, node equipment and storage medium
CN111510395A (en) * 2020-06-16 2020-08-07 腾讯科技(深圳)有限公司 Service message reporting method, device, equipment and medium
CN111866769A (en) * 2020-06-29 2020-10-30 湖南省梦网科技发展有限公司 Message sending method, device, server and medium
CN113010297A (en) * 2021-04-23 2021-06-22 北京秒针人工智能科技有限公司 Database write scheduler based on message queue, write method and storage medium

Also Published As

Publication number Publication date
CN117241231A (en) 2023-12-15
CN115643538B (en) 2024-01-30

Similar Documents

Publication Publication Date Title
US11757981B2 (en) Efficient and reliable host distribution of totally ordered global state
US6775707B1 (en) Deferred acknowledgment communications and alarm management
US7076545B2 (en) Load balancing the servicing of received packets
KR101006114B1 (en) Content push service
CN111818493B (en) Data transmission method, wireless network system, node, and readable storage medium
CN103199968A (en) Sending method of messages and system
CN105794161A (en) Data communication network for aircraft
CN111478839B (en) Physical bus and operating system decoupled distributed aviation communication system
CN114710571B (en) Data packet processing system
KR101663412B1 (en) Method for Defining Quality of Things based on DDS in Internet of Things
CN103282888A (en) Data processing method, graphics processing unit (gpu) and first node device
CN112000446A (en) Data transmission method and robot
CN113268446B (en) Information processing method and device for multiple airborne bus accesses
CN115643538B (en) Message scheduling method and device based on priority information
CN106302432B (en) A kind of communication device and control method based on car networking
CN114666285B (en) Method, system, storage medium and computing device for scheduling Ethernet transmission queue
Kaiser et al. COSMIC: A middleware for event-based interaction on CAN
KR102200590B1 (en) Apparatus and Method For Urgent Message Processing Based on Message Queueing Telemetry Transform Protocol
CN112835823B (en) Storage controller response sending method
US11784933B2 (en) Traffic shaping offload on a network interface controller
Stangaciu et al. PARSECS_RT: A real-time PARSECS-based communication protocol stack for critical sensing applications
US11671500B2 (en) Internet of things system
Puthiyidam et al. PR-MQTT: a novel approach for traffic reduction and message prioritisation in IoT applications
CN116016349A (en) Message scheduling method, device and system
CN110096374A (en) Communication middleware control system and method between internal multi-class computing unit

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
GR01 Patent grant
GR01 Patent grant