CN115643538B - 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
CN115643538B
CN115643538B CN202211323388.XA CN202211323388A CN115643538B CN 115643538 B CN115643538 B CN 115643538B CN 202211323388 A CN202211323388 A CN 202211323388A CN 115643538 B CN115643538 B CN 115643538B
Authority
CN
China
Prior art keywords
message
messages
loading
class
time
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.)
Active
Application number
CN202211323388.XA
Other languages
Chinese (zh)
Other versions
CN115643538A (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

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, the message content and the message equipment address 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, 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 to send feedback obtained from the first device to a second device having 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 technology, and in particular, to a method and apparatus for scheduling message operations.
Background
In order to make the surrounding environment feel more realistic, more devices are needed to achieve the effect. As the number of devices increases, the timeliness and stability of the communication between devices is particularly important.
In the traditional application, the devices are isolated from each other, the application is simpler, and only one piece of software is specially customized for one effect or one function, so that the self-sufficiency is met. But the use scene is limited, the method is not suitable for matching of multiple devices, and the flexibility is low. The cost of post-maintenance is also greatly increased, and as technology advances, system ease and maintainability are increasingly being considered.
There is an urgent need in software to build a set of multi-device message management mechanisms to meet the increasing demands. The method is mainly used for ensuring that data are exchanged with an upper computer, updating firmware at a far end and updating configuration, and ensuring that messages react to the outside correctly at 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 interaction of a first device with at least one second device, the method comprising the steps of: constructing a message linked list based on a message structure body based on the 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, 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 to send feedback obtained from the first device to a second device having the message equipment address.
In some embodiments, the message structure includes a message status, a message real-time, a message start time, a message end time, a length of a message, a message device address, a message content, wherein the priority of the message is determined according to the message status.
In some embodiments, the priority information includes emergency information indicating a highest priority, second-class information indicating a medium priority, and third-class information indicating a lowest priority; an urgent message structure for urgent information, a second-class message structure for second-class information, and/or a third-class message structure for third-class information is constructed.
In some embodiments, loading messages to the message queue is looped in fixed time slices, wherein a first loading rule is used for loading messages in a first time slice, a second loading rule is used for loading messages in a second time slice that is time-sequential to the first time slice, and a third loading rule is used for loading messages in a third time slice that is time-sequential to the second time slice.
In some embodiments, the first loading rule includes loading urgent messages preferentially, the second loading rule includes loading second class messages and third class messages in a first number proportion of the first second class messages in addition to loading urgent messages preferentially, and the third loading rule includes loading second class messages and third class messages in a second number proportion of the first second class messages in addition to loading urgent messages preferentially, wherein the first number proportion is greater than the second number proportion.
In some embodiments, the wait time for the poll and the number of second devices that need to poll are dynamically calculated as the actual number of messages in the message queue.
In some embodiments, the method includes feeding back, by the first device, data verification information to the second device.
In some embodiments, including loading a message actively transmitted by the second device into the message queue as a second-class message.
Further embodiments of the present application provide a message scheduling apparatus based on priority information, which includes a program module for constructing 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, message content, and message device address of the messages for each of the messages; program modules for loading messages in a message chain table into a message queue based on the priority information, the message content and the message equipment address, and program modules for 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 to send feedback obtained from the first device to a second device having 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 the priority information based message scheduling method of any of the above.
The method and apparatus of embodiments of the present application can provide visual advantages including, but not limited to, 1) the message management layer and the message execution layer transmitting data via mailboxes, and achieving high concurrency low coupling of the message receiving layer and the message sending layer. 2) It is ensured that a maximum number of devices in a queue can receive different control messages within a processing cycle, e.g. a time slice. 3) And for the dynamic polling of the mounted equipment, the polling data of the equipment in use is ensured, the unused equipment is silent, and the real-time efficiency is improved. 4) Message priority ensures that urgent messages can be executed preferentially, and second-class messages and third-class messages are executed according to dynamic proportion. 5) And combining Real-Time-Thread operation system threads to ensure the stability and Real-Time of the message. 8) By means of fixed time slice scheduling, high-priority messages in the message queue can be ensured to be processed urgently, and the problem that the message queue is blocked and the message queue is not processed timely is solved. 9) The problem that if the message execution is lost, the alarm can be timely given is solved through a polling mechanism with priority.
Drawings
Fig. 1 is a flow chart of serial port 2 data reception of a message transmission method according to an embodiment of the present application.
Fig. 2 is a flow chart of serial port 3 data reception of a method according to an embodiment of the present application.
Fig. 3 is a flow chart of serial port 2 data processing of a method according to an embodiment of the present application.
Fig. 4 is a flow chart of serial port 2 data processing of a method according to an embodiment of the present application.
Fig. 5 is a flow chart of time slice scheduling for a method according to an embodiment of the present application.
Fig. 6 is a flow chart of a lower computer device message feedback process of a method according to an embodiment of the present application.
Fig. 7 is a flow chart of polling a message queue according to a method of an embodiment of the present application.
Fig. 8 is a main function flow chart of a method according to an embodiment of the present application.
Fig. 9 is a schematic hardware architecture 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 present application.
Fig. 12 is a schematic diagram of message queue polling according to an embodiment of the present application.
Detailed Description
When processing the message, the traditional mode adopts a first-in first-out mode, so that the timeliness of message processing can be influenced, and the situation that the message with high priority is preempted by the low priority can occur, so that the message scheduling method and device based on the priority information in the application are designed.
The methods and apparatus presented in embodiments of the present application may be applied to, but are not limited to, the following hardware environments:
the embedded control system shown in fig. 9 comprises a core board 100, wherein a processor and a memory are provided on the core board 100 to provide processing functions and control functions, and is responsible for global overall and bottom logic processing. The network board 200 is responsible for network connection and data forwarding, and is connected with the internet through a network cable, and the network board 200 can realize serial port connection with the communication core board 100 through a flat cable. The communication board 300 is responsible for distributing the instruction forwarded by the network board 200 from the core board 100 to each office point through good algorithm polling, and an embedded real-time multithreading operating system is installed in the communication board, so that the overall stability and expandability of the device can be greatly improved through reasonably distributing the functions of each module.
Here, the communication board 300 may be an embedded communication system, with a processor, a memory, and a communication module, where the communication module may include a first communication port, for example, a first serial port, and a second communication port, for example, a second serial port, where the communication board 300 is configured to receive an instruction of the core board 100 forwarded by the network board 200 from the network board 200, and interact information with one or more lower computer devices 400 systems, for example, the communication board 300 may connect more than two lower computer devices through one RS-422 full duplex serial communication interface, abbreviated as serial port 2, and the communication board 300 may also connect to the network board 200 through another RS-422 full duplex serial communication interface, abbreviated as serial port 3, so as to form a communication system. Although only three lower computer devices 400 are shown, it should be understood that the present invention is applicable to systems including other numbers of lower computer devices, such as 4, 8, 16, 32, 62, etc.
Each lower computer device is an independent device and can be provided with a processor, a memory, a communication module and the like, the lower computer device can be connected with a communication board through an RS-422 full duplex communication interface to perform cascade connection and interaction of multiple devices, and main logic can be automatically operated according to internal configuration under the condition of no external intervention. The advantages of centralized control and decentralized control are well combined. The network board can adopt Message Queue Telemetry Transmission (MQTT) protocol and/or hypertext transmission protocol (HTTP) protocol to transmit data, and the core board receives the data transmitted by the network board, processes the data and distributes the data to the communication board to control the communication board to carry out polling control of the lower computer.
In some embodiments of the present application, the methods and apparatus herein may be developed based on an embedded real-time multithreading operating system, and data transfer in messaging may be described in a lightweight data exchange format, such as JavaScript Object Notation, JSON. A computer program may be written in the standard C language for use. It should be understood that the implementation of the methods and apparatus in this application 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. 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 LCD display service), a UART_DEAL service and an APP service; the bottom layer is a combination of real-time multithreading with component and service layers.
The main function and the flow of the various threads according to some embodiments of the present application are shown below.
Initializing a main function:
as shown in fig. 1, the main function initialization includes creating and starting seven threads of thread 1 to thread 7, and creating a mailbox of a message queue corresponding to each thread, step S001; then, a request, for example, JSON format 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:
thread 1, a first serial port data receiving thread, is configured to receive data from serial port 2. As shown in fig. 2, the following processing is performed in the process 1, firstly, waiting for data from the serial port 2, step S101, starting 5ms timing after receiving the 1 st byte, and clearing 5ms and re-timing after completing the reception of the 1 st byte until the 5ms timing is full, step S102; then, a semaphore notification is sent to thread 3 to process the data received by serial port 2, step S103.
Thread 2, a second serial port data receiving thread, for receiving data from serial port 3. Waiting for data from the serial port 3, determining whether a data header frame is received, if yes, starting 5ms timing, emptying 5ms after receiving one byte, and re-timing until the 5ms timing is full, and step S202; then, a semaphore notification is sent to the thread 4 to process the data received by the serial port 3, step S203.
Thread 3, a first serial port data processing thread, is used for processing the data received from serial port 2. As shown in fig. 3, the thread includes first waiting for a semaphore notification from thread 1, step S301; if yes, starting to receive data, analyzing the received data by using CJOSN, analyzing the read addresses of key words such as CMD, LIST and the like to obtain message classification, loading the analyzed data into a linked LIST of corresponding urgent messages, second class messages, third class messages and the like in a message structure according to the message classification, and setting a state bit in the linked LIST according to the definition of the message structure, wherein step S302 is performed; thereafter 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 a semaphore notification of the thread 2, a step S401, and if there is the semaphore notification, packaging HEX format data from the serial port 3 into JSON data to send, and sending a mailbox notification to the thread 7, a step S402.
Thread 5, time slice schedule thread. Referring to fig. 5, after starting the fixed time slice scheduling step S500, scanning whether the status of the urgent message structure, the second message structure, or the third message structure in the message linked list is set, if so, opening the first 100 ms time slice schedule, loading the data in the corresponding message linked list into the polling message queue, if not, continuing waiting, if so, opening the first 100 ms time slice schedule, and if not; the loading the data into the polling message queue includes using a first loading rule, i.e. loading the urgent message in the message list preferentially and determining whether the queue is full, i.e. step S503, if so, sending a signal to notify the message to poll the thread 7, step S505, suspending the current thread, and waiting for 100 ms until the polling thread 7 is completed, step S504; starting the second time slice scheduling when the 100 ms time is up, and then starting the third time slice scheduling, wherein the step S506 is that; if it is judged that the message queue is not full, the message queue is continued to be loaded with the second message 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 message queue is loaded with the third message 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 follow the following rules, and the second loading rule is adopted when the message is loaded in the second 100 ms time slice: i.e. to load urgent messages preferentially, when the message queue is not full and no urgent messages are loadable, then according to 5: the proportion of 1 loads the second and third messages in the message chain table. Such a rule may essentially ensure that a second-order message can be responded to once within 200 milliseconds. At the time of the third 100 millisecond time slice loading message, a third loading rule is employed: i.e. to load emergency messages preferentially, when the message queue is not full and no emergency messages are loadable, then according to 2: the proportion of 1 loads the second and third messages in the message chain table. This essentially ensures that three messages can be responded to once in 300 milliseconds. The above rule is adopted to 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 the notification is provided, whether the address is correct is judged, step S602, if the address is correct, the data in the message linked list is cleared according to the priority parameter of the message, step S603.
Thread 7, message queue polls thread. As shown in fig. 7, the thread 7 is configured to poll the message queue, first wait for a time slice semaphore, step S701, and if there is a signal in the time slice, send the 1/N th message in the message queue out of the serial port 3 according to a protocol, where the protocol format is shown in table 1, and herein, it is assumed that there are N messages in the message queue, for example, 5 messages shown in fig. 7, step S702; waiting for the mailbox notification of the thread 4 or suspending the thread for 5ms, step S703, when it is time to continue to poll the next message or if the mailbox notification from the thread 4 is received, notifying the thread 6 through the mailbox of the thread and releasing the corresponding data in the message linked list, and then continuing to poll the next message, wherein the next message refers to the 2/N message, step S703; if there is no mailbox notification from thread 4, an alarm message is generated and presented, for example, the alarm message is presented on a display device and/or the alarm message is presented acoustically and optically, and the next message in the message queue, i.e., 2/N, is continuously polled, step S704.
Table 1:
header frame 1 Header frame 2 Length of High address Address low Control commands Specific data 1 Specific data 2 Specific data 3
FF AA len ADDR_H ADDR_L 1 1 1 1
Message structure:
the created message structure may include multiple message structures of different priorities. Each message structure may include the following elements therein: message status, message real-time, message start time, message end time, length of message, device address of message, specific content data in message. For example, a message structure corresponding to the highest priority urgent message, a message structure corresponding to the middle priority second class message, and a message structure corresponding to the lowest priority third class message may be created. Message structures of different priorities can be distinguished by a message structure element "message status". For example, a message state of "1" may be set as a message structure corresponding to an urgent message, a message state of "2" may be set as a message structure corresponding to a second class message, and a message state of "3" may be set as a message structure corresponding to a third class message.
Message linked list:
a message linked list is created that stores data in the form of the message structure described above, which can be a dynamic linked list or a static linked list. After the interactive message comes in, the received messages are stored in the form of an urgent message structure body, a second-class message structure body or a third-class message structure body one by one in the established message linked list according to the message state.
Message queue loading:
creating a polling message queue, and then loading data in a linked list into the polling message queue, wherein the loading mode of the polling message queue comprises loading the data in the message linked list in a fixed time slice.
The length of the time slices may be determined according to system requirements, for example, loading the polling message queue with messages in fixed time slices of 100 milliseconds (ms) may be: at the first 100 ms, i.e. the first time slice, the message is loaded, a first loading rule is applied: i.e. preferentially load urgent messages in urgent message structures in the message link list, reload second class messages in second class message structures in the message link list if the polling message queue is not full during the first time slice, and reload third class messages in third class message structures in the message link list if the polling message queue is not full during the time slice. This ensures that each time an urgent message is processed first.
The second loading rule may be employed when loading messages into the polling message queue during a second time slice that is consecutive to the first time slice, i.e., a second 100 ms time slice, different from the first loading rule for the first time slice: i.e. to load urgent messages preferentially, when the message queue is not full and no urgent messages are loadable, then according to 5: the proportion of 1 loads the second and third messages in the message chain table. 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.
And so on, at the time of loading the message for the third 100 ms time slice, a third loading rule is employed: i.e. to load emergency messages preferentially, when the message queue is not full and no emergency messages are loadable, then according to 2: the proportion of 1 loads the second and third messages in the message chain table. This basically ensures that three messages can be responded to once within three time slice lengths, i.e. 300 ms.
In some embodiments, when loading the second and third messages: the method calculates the most urgent of the second-class message and the third-class message according to the three factors of the starting time, the real-time and the ending time in the structure body, and loads the most urgent message into the polling message queue according to the degree of tightness. After the most urgent message of the second class message and the third class message is responded, the most urgent message of the no response message is reloaded. In some embodiments, the 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 normally received, so as to ensure that the messages are correctly sent. Compared with the traditional broadcasting mode, the method has the advantages that the message correctness is ensured.
In addition, when it is determined that a device needs to actively upload a message, the actively uploaded message may be stored in a message chain table in a second-class message structure, and then added to a polling message queue in a second-class message priority, where the second-class message participates in polling, and in this process, data from the device actively uploading the message may be extracted in the second-class message structure until a state in the second-class message structure is actively set, and no polling is performed.
Polling of message queues
Conventional polling generally uses a fixed polling time, so that the device can be more stressed in processing data. Whereas in the embodiments of the present application the polling of a message queue dynamically calculates the polling latency in terms of 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 polling frequency according to the amount of actual data in the queue, giving the device more time to process other tasks.
Each message to be polled contains the address of the device and the command of the device, the device to be polled is determined according to the specific device address, and the specific time to be polled is determined according to the length of the message queue.
When the feedback is given by the lower computer device or the waiting time is reached, the next frame of data is continuously polled, and the process is repeated.
Prioritizing messages can improve timeliness of information interaction. The polling mechanism is dynamically adjusted, so that the device can have more time to complete other tasks.
According to the embodiment of the application, the polling device is dynamically adjusted by adopting the priority division of the messages, so that the bandwidth utilization rate of the data bus can be effectively improved, and the response speed of the device is improved. For example: a total of 30 devices were mounted, of which only 3 were active at the same time, each device took 5ms and the device polling efficiency was compared as shown in table 2 below:
table 2:
10-station equipment 20-station equipment 30-station equipment
Dynamic polling of 3 devices 15ms 15ms 15ms
Polling all devices 50ms 100ms 150ms
A messaging appliance in accordance with embodiments of the present application may include a first mode and a second mode, namely a command mode and a file mode. The above-described messaging method may be performed in a command mode, while in a second mode, a file mode: waiting to receive a file transfer command, suspending current polling. And dividing the file into a plurality of packets according to the size, and transmitting the packets to the lower computer equipment with the corresponding address, wherein each packet of data can obtain an ACK feedback, and waiting for polling before the recovery of the read context after the data transmission is finished.
One specific example of the method of the present application includes:
initializing, including creating an urgent message structure corresponding to the urgent message, a second message structure corresponding to the second message, a third message structure corresponding to the third message, a message linked list and a message queue.
Each message structure includes elements therein: status of the message, message real-time, message start time, message end time, length of the message, device address of the message, specific data in the message.
The code to create 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;// Emergency MESSAGE Structure
MODU_USER_MESSAGE second_class_msg;// Second class MESSAGE structure
MODU_USER_MESSAGE Third_class_msg;// three MESSAGE Structure
After the initialization is completed, the JSON data transmission is packed through the CJSON library to request the address of each lower computer device. And receiving the returned data of each lower computer Device, analyzing the read addresses of the keywords such as cmd, ads, list and the like in the data according to the CJSON library, storing the analyzed addresses of each lower computer Device into a device_addr array, and storing the Number of the lower computer devices into a device_number variable.
All addresses in the device_addr array are cached in a second-class message structure body, polling is started for searching whether all the devices are online, and if the devices are not online, the lower computer Device alarms in the LCD of the Device and requests to check whether the hardware link is normal.
Waiting for the JSON format data received by the serial port 2, analyzing the data according to the CJSON library, dividing the message into an emergency message, a second-class message, a third-class message and the like, and storing the effective data into corresponding message structures.
The manner of loading data in the message structure is: for emergency messages: the state of the message structure body is set to be 1, the message structure body represents an emergency message, 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 ending time is 100+rt_tick_get (), the starting time is rt_tick_get (), and the specific data is the received effective data. Where rt_tick_get () is a function of the current time of the extraction system.
For a message of two degrees: setting the state of a message structure body to be 2, representing a second-class message, wherein the data length is 6, the address is the address in the device_addr array, the message real-time is 200, the ending time is 200+rt_tick_get (), and the starting time is rt_tick_get (); specific data are 0xFF, 0XAA, 0X06, addr_H, addr_L, 0X01.
For three messages: setting the state of a message structure body to be 3, setting the data length according to the effective data of the message, setting the address to be the address in the device_addr array, setting the message real-time to be 300, setting the ending time to be 300+rt_tick_get (), and setting the starting time to be 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, the first 100 ms scheduling is performed, the data of the urgent message structure is cached in the polling message queue, and then the number of the remaining empty spaces of the message queue is judged, for example, as shown in fig. 11, in this embodiment, the message queue is constructed to be a maximum of 20 messages, if there is a remaining space, the second-class message structure is read again, the caching is continued to the polling message queue, whether the polling message queue is full is judged, if the message queue is not fully loaded, the third-class message is continued to be cached until the polling message queue is fully loaded or all the messages are already in the polling message queue, and thereafter, a signal quantity is sent to inform the polling thread to start polling data, and the self thread is suspended.
And scheduling for the second time of 100 milliseconds, preferentially caching data in the emergency message structure into a polling message queue, judging the number of the remaining gaps of the message queue, and if the remaining gaps exist, then, according to the second-class message and the third-class message number 5:1, caching second-class messages and/or third-class messages into a polling message queue in a mode of 1; the priority rules of the second class message and the third class message cache are as follows: equal priority first-in first-out order. Thereafter, a semaphore is sent informing the polling thread to begin polling data and the self-thread is suspended.
And dispatching for the third time of 100 milliseconds, preferentially caching data in an emergency message structure into a polling message queue, judging the number of the remaining gaps of the message queue, and if the number of the remaining gaps is still the same as that of the second-class message and the third-class message, wherein the number of the remaining gaps is 2:1 to buffer second class messages and/or third class messages into a polling message queue. The priority rules of the second class message and the third class message cache are as follows: equal priority first-in first-out order. And sending a signal quantity to inform a polling thread to start polling data, and suspending the self thread.
Specific polling modes:
also, as shown in FIG. 12, the polling thread waits for a semaphore for the slice scheduling thread, and the packetized HEX data is sent to the lower computer device. The polling thread is suspended until the mailbox feedback information "mb" of the polling acknowledge thread is received, or the time of waiting 100/the number of actual polling devices is a minimum of 5 milliseconds.
Wherein, because the baud rate sent to the lower computer is 115200, the maximum data size sent does not exceed 10 bytes, including 1 start bit, 1 stop bit and 8 data bits; the transmission time is: 1000/115200×10×10 (data length) milliseconds. The reception time coincides with the transmission time.
After the polling confirmation thread receives the data fed back by the polling thread, judging whether the length of the data and the JSON data need to be packed or not, and transmitting the JSON data 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 to feed back the thread to empty the data in the corresponding structure body in the message linked list, wherein the message structure body is not added into the time slice scheduling at the next time. If the thread suspension time is up, alarm information is generated and sent to the LCD for alarm display if mailbox feedback is not received, and next time slice scheduling is circulated again.
And finally, finishing polling until the states in the message structure body are all 0, and waiting for a new message.
It should be appreciated that while embodiments of the present application have 100 milliseconds as a parameter for the time slices, it should be appreciated 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 other lengths of the message queues, shorter or longer, may be reasonably determined according to the number of lower computer devices, such as 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 device as the at least one second device, it should be understood that the method of the present application may be adapted for use in a system having the same structure for transmission of messages without adjustment or with little adjustment. For example, the communication board may not receive instructions from other control systems, such as a core board, but may generate instructions directly itself, in which case serial port 3 is not required to communicate with other devices to receive instructions. In other embodiments, other suitable communication means may be employed in addition to the inter-thread communication means described in the embodiments, such as one of a semaphore, a message queue, a mailbox, etc.
Embodiments of the present application may also include an apparatus corresponding to the method, where the apparatus may include computer program modules corresponding to each of the flows of the method as described above.
In some example embodiments, the functions of any of the methods, processes, signaling diagrams, algorithms, or flowcharts described herein may be implemented by software and/or computer program code or code portions stored in a memory or other computer readable or tangible medium 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 a program or portion 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, can be stored in any apparatus-readable data storage medium and can include program instructions for performing particular tasks.
A sequence is a unit of data structure that may include strings, lists, tuples, etc.
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. The modification and configuration for implementing the functions of the example embodiments may be performed as routines that may be implemented as added or updated software routines. In one example, software routines may be downloaded into the apparatus.
By way of example, software or computer program code, or a portion of code, may be in source code form, object code form, or in some intermediate form, and may be stored on some carrier, distribution medium, or computer readable medium, which may be any entity or device capable of carrying the program. Such carriers may include, for example, recording media, computer memory, read-only memory, electro-optical and/or electronic carrier signals, telecommunications signals, and/or software distribution packages. Depending on the processing power required, the computer program may be executed in a single electronic digital computer or may be distributed among multiple 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 circuit, such as through the use of 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 a non-tangible 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 responsive element may be configured as a circuit, a computer or microprocessor (such as a single chip computer element) or a chipset, which may include 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, whether the language used to describe certain embodiments is in the singular or the plural. For example, embodiments describing the operation of a single computing device are equally applicable to embodiments that include multiple instances of a computing device, and vice versa.
Those of ordinary skill in the art will readily appreciate that the example embodiments described above may be implemented in a different order of operation and/or in hardware elements in a different configuration than that disclosed. Thus, while some embodiments have been described based on these example embodiments, it will be apparent to those of ordinary skill in the art that certain modifications, variations and alternative constructions will be apparent, while remaining within the spirit and scope of the example embodiments.

Claims (8)

1. A message scheduling method 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 the 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 device address, 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 send feedback obtained from the first device to a second device having the message equipment address;
wherein the priority information includes emergency information indicating the highest priority, second-class information indicating the medium priority, and third-class information indicating the lowest priority; constructing an emergency message structure body for emergency information, a second-class message structure body for second-class information and/or a third-class message structure body for third-class information;
and circularly loading the messages to the message queue according to fixed time slices, wherein a first loading rule is adopted for loading the messages in a first time slice, a second loading rule is adopted for loading the messages in a second time slice which is time-continuous with the first time slice, and a third loading rule is adopted for loading the messages in a third time slice which is time-continuous with the second time slice.
2. The message scheduling method 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 message scheduling method based on priority information according to claim 1, wherein: the first loading rule comprises loading urgent messages preferentially, the second loading rule comprises loading second-class messages and third-class messages according to a first quantity proportion of the second-class messages except for loading urgent messages preferentially, and the third loading rule comprises loading second-class messages and third-class messages according to a second quantity proportion of the second-class messages except for loading urgent messages preferentially, wherein the first quantity proportion is larger than the second quantity proportion.
4. The message scheduling method based on priority information according to claim 1, wherein: dynamically calculating the waiting time of the polling and the number of second devices needing to poll according to the actual number of messages in the message queue.
5. The message scheduling method based on priority information according to claim 1, wherein: including feeding back data verification information by the first device to the second device.
6. The message scheduling method based on priority information according to claim 1, wherein: including loading a message actively transmitted by the second device as a second class message into the message queue.
7. Message scheduling device based on priority information, characterized in that: program modules comprising constructing a message structure based message linked list based on messages obtained from at least one second apparatus, wherein said message linked list stores priority information, message content and message device addresses of said messages for each of said messages; program modules for loading messages in a message chain table into a message queue based on the priority information, the message content and the message equipment address, and program modules for dynamically polling the message queue according to the number of messages in the message queue to send the message content to a first device and sending feedback obtained from the first device to a second device having the message equipment address;
wherein the priority information includes emergency information indicating the highest priority, second-class information indicating the medium priority, and third-class information indicating the lowest priority; constructing an emergency message structure body for emergency information, a second-class message structure body for second-class information and/or a third-class message structure body for third-class information;
and circularly loading the messages to the message queue according to fixed time slices, wherein a first loading rule is adopted for loading the messages in a first time slice, a second loading rule is adopted for loading the messages in a second time slice which is time-continuous with the first time slice, and a third loading rule is adopted for loading the messages in a third time slice which is time-continuous with the second time slice.
8. Message scheduling device based on priority information, characterized in that: comprising 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 the priority information based message scheduling method of any one of claims 1 to 6.
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 CN115643538A (en) 2023-01-24
CN115643538B true 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
CN115643538A (en) 2023-01-24

Similar Documents

Publication Publication Date Title
US11647099B2 (en) Method and apparatus for transmitting data in IoT system, and gateway device and storage medium thereof
EP3146401B1 (en) Efficient and reliable host distribution of totally ordered global state
US5327558A (en) Method for asynchronous application communication
CN101354664B (en) Method and apparatus for interrupting load equilibrium of multi-core processor
US6393026B1 (en) Data packet processing system and method for a router
US7076545B2 (en) Load balancing the servicing of received packets
KR100619720B1 (en) Communication apparatus for multi processor and method thereof
EP2755363B1 (en) Data-fast-distribution method and device
CN103199968A (en) Sending method of messages and system
CN109792442A (en) Communication device, control device and communication means
CN105794161A (en) Data communication network for aircraft
US20200210224A1 (en) Methods and apparatus for verifying completion of groups of data transactions between processors
CN113179227B (en) AT instruction control method based on queue
CN111478839B (en) Physical bus and operating system decoupled distributed aviation communication system
JP2008077266A (en) Service control unit, distributed service control system, service control method, and program
CN112000446A (en) Data transmission method and robot
CN101567873B (en) Multitask Parallel processing method and multitask parallel processing system
EP1895712A2 (en) System for monitoring the state of apparatuses in a communication network
CN115643538B (en) Message scheduling method and device based on priority information
CN103282888A (en) Data processing method, graphics processing unit (gpu) and first node device
US20050138197A1 (en) Queue state mirroring
CN109639545B (en) Lightweight bus arrangement method of multi-satellite measurement and control platform system
KR20120128013A (en) System and method for providing push service
KR102200590B1 (en) Apparatus and Method For Urgent Message Processing Based on Message Queueing Telemetry Transform Protocol
CN113497731B (en) Centralized control probe scheduling method and centralized control probe management system

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