CN110554924A - Message processing method and device - Google Patents

Message processing method and device Download PDF

Info

Publication number
CN110554924A
CN110554924A CN201910696222.4A CN201910696222A CN110554924A CN 110554924 A CN110554924 A CN 110554924A CN 201910696222 A CN201910696222 A CN 201910696222A CN 110554924 A CN110554924 A CN 110554924A
Authority
CN
China
Prior art keywords
flag bit
bit value
writing
reading
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910696222.4A
Other languages
Chinese (zh)
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.)
Visionvera Information Technology Co Ltd
Original Assignee
Visionvera Information Technology 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 Visionvera Information Technology Co Ltd filed Critical Visionvera Information Technology Co Ltd
Priority to CN201910696222.4A priority Critical patent/CN110554924A/en
Publication of CN110554924A publication Critical patent/CN110554924A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • G06F9/524Deadlock detection or avoidance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/40Support for services or applications
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/06Notations for structuring of protocol data, e.g. abstract syntax notation one [ASN.1]

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Multimedia (AREA)
  • Computer Security & Cryptography (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

the embodiment of the invention provides a message processing method and a device, wherein the method is applied to a video network and comprises the following steps: receiving a write instruction sent by a first thread, and judging the magnitude of a write flag bit value and a read flag bit value; if the writing flag bit value is larger than the reading flag bit value, writing the video network message data into a lock-free container, and modifying the writing flag bit value according to the length information of the video network message data; receiving a reading instruction sent by a second thread, and judging the magnitude of the writing flag bit value and the magnitude of the reading flag bit value; if the number value of the writing flag bit is larger than the number value of the reading flag bit, the reading flag bit is modified according to the length information of the video networking message data to be read, the message data is read from the container without lock, and in the thread synchronization process, locking is not needed, so that blocking cannot be triggered, the thread is safe, and the defect that the blue screen of an operating system is caused by blocking due to the fact that the video networking message is written into the container with the lock in the driving mode is overcome.

Description

Message processing method and device
Technical Field
The present invention relates to the field of video networking technologies, and in particular, to a method and an apparatus for processing a packet.
Background
with the rapid development of network technologies, bidirectional communications such as video conferences and video teaching are widely popularized in the aspects of life, work, learning and the like of users.
In the process of video data communication, the received video networking message needs to be cached, and then data is read according to requirements, so that the cooperative work among threads is needed.
Specifically, the RIP Agent (i.e., i2v protocol client) processing an internet protocol packet requires two threads to work in cooperation: thread 1: writing the video network message acquired from the network card into a container with a lock; thread 2: and reading the video network message from the container with the lock and processing the video network message.
In the process, the RIP Agent runs in the driver layer, and the thread runs at a Level where IRQL (Interrupt ReQuest Level) is less than or equal to 2, which is not allowed to block, and writing the video networking packet into a container with a lock triggers blocking, which may result in a blue screen of the operating system.
disclosure of Invention
In view of the above, embodiments of the present invention are proposed to provide a message processing method and apparatus that overcome the above problems or at least partially solve the above problems.
In a first aspect, an embodiment of the present invention provides a method for processing a packet, where the method is applied in a video network, and includes:
receiving a write instruction sent by a first thread, and judging the magnitude of a write flag bit value and a read flag bit value;
If the writing flag bit value is larger than the reading flag bit value, writing the video network message data into a lock-free container, and modifying the writing flag bit value according to the length information of the video network message data;
receiving a reading instruction sent by a second thread, and judging the magnitude of the writing flag bit value and the magnitude of the reading flag bit value;
And if the writing zone bit value is greater than the reading zone bit value, modifying the reading zone bit according to the length information of the message data of the video network to be read, and reading the message data from the lock-free container.
Optionally, after receiving a write instruction sent by the first thread, the method further includes:
And if the writing flag bit value is equal to the reading flag bit value, stopping writing the video networking message data into the lock-free container.
Optionally, after receiving the read instruction sent by the second thread, the method further includes:
And if the writing flag bit value is equal to the reading flag bit value, the video networking message data does not exist in the lock-free container for the second thread to read.
optionally, the modifying the value of the writing flag bit according to the length information of the packet data of the video networking includes:
and modifying the value of the writing flag bit according to the length of the byte number of the video network message data.
optionally, the lockless container is an annular container connected end to end.
In a second aspect, an embodiment of the present invention provides a packet processing apparatus, where the apparatus is applied in a video network, and includes:
The first receiving module is used for receiving a writing instruction sent by a first thread and judging the values of a writing flag bit and a reading flag bit;
The write-in data module is used for writing the video networking message data into a lock-free container if the write flag bit value is larger than the read flag bit value, and modifying the write flag bit value according to the length information of the video networking message data;
The second receiving module is used for receiving a reading instruction sent by a second thread and judging the values of the writing flag bits and the reading flag bits;
And the data reading module is used for modifying the reading zone bit according to the length information of the video network message data to be read and reading the message data from the lock-free container if the writing zone bit value is greater than the reading zone bit value.
Optionally, the write data module is further configured to:
and if the writing flag bit value is equal to the reading flag bit value, stopping writing the video networking message data into the lock-free container.
Optionally, the read data module is further configured to:
And if the writing flag bit value is equal to the reading flag bit value, the video networking message data is not read in the lock-free container.
Optionally, the write data module is specifically configured to:
and modifying the value of the writing flag bit according to the length of the byte number of the video network message data.
Optionally, the lockless container is an annular container connected end to end.
in a third aspect, an embodiment of the present invention provides an electronic device, including: a memory, a processor and a computer program stored on the memory and executable on the processor, the computer program when executed by the processor implementing the steps of any of the above.
In a fourth aspect, the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program is used to implement the steps of any one of the above items when executed by a processor.
The embodiment of the invention has the following advantages:
The embodiment of the invention applies the characteristics of video networking, provides a lock-free container, is used for accessing video networking messages, determines whether the lock-free container has space for writing data or not by judging the values of a writing flag bit and a reading flag bit of the lock-free container after receiving an instruction of a first thread or a second thread, and further determines whether the lock-free container can read data or not.
Drawings
FIG. 1 is a schematic networking diagram of a video network of the present invention;
FIG. 2 is a schematic diagram of a hardware architecture of a node server according to the present invention;
Fig. 3 is a schematic diagram of a hardware structure of an access switch of the present invention;
Fig. 4 is a schematic diagram of a hardware structure of an ethernet protocol conversion gateway according to the present invention;
FIG. 5 is a flowchart illustrating steps of a message processing method according to an embodiment of the present invention;
FIG. 6 is a diagram illustrating an exemplary structure of a message process according to the present invention;
FIG. 7 is a diagram illustrating steps of another embodiment of a message processing method;
FIG. 8 is a block diagram of a message processing apparatus according to an embodiment of the present invention;
Fig. 9 is a schematic structural diagram of an electronic device of the present invention.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
the video networking is an important milestone for network development, is a real-time network, can realize high-definition video real-time transmission, and pushes a plurality of internet applications to high-definition video, and high-definition faces each other.
the video networking adopts a real-time high-definition video exchange technology, can integrate required services such as dozens of services of video, voice, pictures, characters, communication, data and the like on a system platform on a network platform, such as high-definition video conference, video monitoring, intelligent monitoring analysis, emergency command, digital broadcast television, delayed television, network teaching, live broadcast, VOD on demand, television mail, Personal Video Recorder (PVR), intranet (self-office) channels, intelligent video broadcast control, information distribution and the like, and realizes high-definition quality video broadcast through a television or a computer.
to better understand the embodiments of the present invention, the following description refers to the internet of view:
Some of the technologies applied in the video networking are as follows:
Network Technology (Network Technology)
network technology innovation in video networking has improved over traditional Ethernet (Ethernet) to face the potentially enormous video traffic on the network. Unlike pure network Packet Switching (Packet Switching) or network circuit Switching (circuit Switching), the Packet Switching is adopted by the technology of the video networking to meet the Streaming requirement. The video networking technology has the advantages of flexibility, simplicity and low price of packet switching, and simultaneously has the quality and safety guarantee of circuit switching, thereby realizing the seamless connection of the whole network switching type virtual circuit and the data format.
switching Technology (Switching Technology)
The video network adopts two advantages of asynchronism and packet switching of the Ethernet, eliminates the defects of the Ethernet on the premise of full compatibility, has end-to-end seamless connection of the whole network, is directly communicated with a user terminal, and directly bears an IP data packet. The user data does not require any format conversion across the entire network. The video networking is a higher-level form of the Ethernet, is a real-time exchange platform, can realize the real-time transmission of the whole-network large-scale high-definition video which cannot be realized by the existing Internet, and pushes a plurality of network video applications to high-definition and unification.
server Technology (Server Technology)
The server technology on the video networking and unified video platform is different from the traditional server, the streaming media transmission of the video networking and unified video platform is established on the basis of connection orientation, the data processing capacity of the video networking and unified video platform is independent of flow and communication time, and a single network layer can contain signaling and data transmission. For voice and video services, the complexity of video networking and unified video platform streaming media processing is much simpler than that of data processing, and the efficiency is greatly improved by more than one hundred times compared with that of a traditional server.
Storage Technology (Storage Technology)
the super-high speed storage technology of the unified video platform adopts the most advanced real-time operating system in order to adapt to the media content with super-large capacity and super-large flow, the program information in the server instruction is mapped to the specific hard disk space, the media content is not passed through the server any more, and is directly sent to the user terminal instantly, and the general waiting time of the user is less than 0.2 second. The optimized sector distribution greatly reduces the mechanical motion of the magnetic head track seeking of the hard disk, the resource consumption only accounts for 20% of that of the IP internet of the same grade, but concurrent flow which is 3 times larger than that of the traditional hard disk array is generated, and the comprehensive efficiency is improved by more than 10 times.
network Security Technology (Network Security Technology)
The structural design of the video network completely eliminates the network security problem troubling the internet structurally by the modes of independent service permission control each time, complete isolation of equipment and user data and the like, generally does not need antivirus programs and firewalls, avoids the attack of hackers and viruses, and provides a structural carefree security network for users.
Service Innovation Technology (Service Innovation Technology)
The unified video platform integrates services and transmission, and is not only automatically connected once whether a single user, a private network user or a network aggregate. The user terminal, the set-top box or the PC are directly connected to the unified video platform to obtain various multimedia video services in various forms. The unified video platform adopts a menu type configuration table mode to replace the traditional complex application programming, can realize complex application by using very few codes, and realizes infinite new service innovation.
Networking of the video network is as follows:
The video network is a centralized control network structure, and the network can be a tree network, a star network, a ring network and the like, but on the basis of the centralized control node, the whole network is controlled by the centralized control node in the network.
As shown in fig. 1, the video network is divided into an access network and a metropolitan network.
The devices of the access network part can be mainly classified into 3 types: node server, access switch, terminal (including various set-top boxes, coding boards, memories, etc.). The node server is connected to an access switch, which may be connected to a plurality of terminals and may be connected to an ethernet network.
The node server is a node which plays a centralized control function in the access network and can control the access switch and the terminal. The node server can be directly connected with the access switch or directly connected with the terminal.
Similarly, devices of the metropolitan network portion may also be classified into 3 types: a metropolitan area server, a node switch and a node server. The metro server is connected to a node switch, which may be connected to a plurality of node servers.
The node server is a node server of the access network part, namely the node server belongs to both the access network part and the metropolitan area network part.
the metropolitan area server is a node which plays a centralized control function in the metropolitan area network and can control a node switch and a node server. The metropolitan area server can be directly connected with the node switch or directly connected with the node server.
Therefore, the whole video network is a network structure with layered centralized control, and the network controlled by the node server and the metropolitan area server can be in various structures such as tree, star and ring.
The access network part can form a unified video platform (the part in the dotted circle), and a plurality of unified video platforms can form a video network; each unified video platform may be interconnected via metropolitan area and wide area video networking.
video networking device classification
1.1 devices in the video network of the embodiment of the present invention can be mainly classified into 3 types: servers, switches (including ethernet gateways), terminals (including various set-top boxes, code boards, memories, etc.). The video network as a whole can be divided into a metropolitan area network (or national network, global network, etc.) and an access network.
1.2 wherein the devices of the access network part can be mainly classified into 3 types: node servers, access switches (including ethernet gateways), terminals (including various set-top boxes, code boards, memories, etc.).
The specific hardware structure of each access network device is as follows:
A node server:
as shown in fig. 2, the system mainly includes a network interface module 201, a switching engine module 202, a CPU module 203, and a disk array module 204;
The network interface module 201, the CPU module 203, and the disk array module 204 all enter the switching engine module 202; the switching engine module 202 performs an operation of looking up the address table 205 on the incoming packet, thereby obtaining the direction information of the packet; and stores the packet in a queue of the corresponding packet buffer 206 based on the packet's steering information; if the queue of the packet buffer 206 is nearly full, it is discarded; the switching engine module 202 polls all packet buffer queues for forwarding if the following conditions are met: 1) the port send buffer is not full; 2) the queue packet counter is greater than zero. The disk array module 204 mainly implements control over the hard disk, including initialization, read-write, and other operations on the hard disk; the CPU module 203 is mainly responsible for protocol processing with an access switch and a terminal (not shown in the figure), configuring an address table 205 (including a downlink protocol packet address table, an uplink protocol packet address table, and a data packet address table), and configuring the disk array module 204.
the access switch:
As shown in fig. 3, the network interface module mainly includes a network interface module (a downlink network interface module 301 and an uplink network interface module 302), a switching engine module 303 and a CPU module 304;
wherein, the packet (uplink data) coming from the downlink network interface module 301 enters the packet detection module 305; the packet detection module 305 detects whether the Destination Address (DA), the Source Address (SA), the packet type, and the packet length of the packet meet the requirements, and if so, allocates a corresponding stream identifier (stream-id) and enters the switching engine module 303, otherwise, discards the stream identifier; the packet (downstream data) coming from the upstream network interface module 302 enters the switching engine module 303; the data packet coming from the CPU module 204 enters the switching engine module 303; the switching engine module 303 performs an operation of looking up the address table 306 on the incoming packet, thereby obtaining the direction information of the packet; if the packet entering the switching engine module 303 is from the downstream network interface to the upstream network interface, the packet is stored in the queue of the corresponding packet buffer 307 in association with the stream-id; if the queue of the packet buffer 307 is nearly full, it is discarded; if the packet entering the switching engine module 303 is not from the downlink network interface to the uplink network interface, the data packet is stored in the queue of the corresponding packet buffer 307 according to the guiding information of the packet; if the queue of the packet buffer 307 is nearly full, it is discarded.
The switching engine module 303 polls all packet buffer queues, which in this embodiment of the present invention is divided into two cases:
If the queue is from the downlink network interface to the uplink network interface, the following conditions are met for forwarding: 1) the port send buffer is not full; 2) the queued packet counter is greater than zero; 3) obtaining a token generated by a code rate control module;
if the queue is not from the downlink network interface to the uplink network interface, the following conditions are met for forwarding: 1) the port send buffer is not full; 2) the queue packet counter is greater than zero.
The rate control module 208 is configured by the CPU module 204, and generates tokens for packet buffer queues from all downstream network interfaces to upstream network interfaces at programmable intervals to control the rate of upstream forwarding.
the CPU module 304 is mainly responsible for protocol processing with the node server, configuration of the address table 306, and configuration of the code rate control module 308.
ethernet protocol conversion gateway
as shown in fig. 4, the apparatus mainly includes a network interface module (a downlink network interface module 401 and an uplink network interface module 402), a switching engine module 403, a CPU module 404, a packet detection module 405, a rate control module 408, an address table 406, a packet buffer 407, a MAC adding module 409, and a MAC deleting module 410.
Wherein, the data packet coming from the downlink network interface module 401 enters the packet detection module 405; the packet detection module 405 detects whether the ethernet MAC DA, the ethernet MAC SA, the ethernet length or frame type, the video network destination address DA, the video network source address SA, the video network packet type and the packet length of the packet meet the requirements, and if so, allocates a corresponding stream identifier (stream-id); then, the MAC deletion module 410 subtracts MAC DA, MAC SA, length or frame type (2byte) and enters the corresponding receiving buffer, otherwise, discards it;
The downlink network interface module 401 detects the sending buffer of the port, and if there is a packet, acquires the ethernet MAC DA of the corresponding terminal according to the video networking destination address DA of the packet, adds the ethernet MAC DA of the terminal, the MACSA of the ethernet coordination gateway, and the ethernet length or frame type, and sends the packet.
The other modules in the ethernet protocol gateway function similarly to the access switch.
A terminal:
The system mainly comprises a network interface module, a service processing module and a CPU module; for example, the set-top box mainly comprises a network interface module, a video and audio coding and decoding engine module and a CPU module; the coding board mainly comprises a network interface module, a video and audio coding engine module and a CPU module; the memory mainly comprises a network interface module, a CPU module and a disk array module.
1.3 devices of the metropolitan area network part can be mainly classified into 2 types: node server, node exchanger, metropolitan area server. The node switch mainly comprises a network interface module, a switching engine module and a CPU module; the metropolitan area server mainly comprises a network interface module, a switching engine module and a CPU module.
2. video networking message packet definition
2.1 Access network packet definition
the data packet of the access network mainly comprises the following parts: destination Address (DA), Source Address (SA), reserved bytes, payload (pdu), CRC.
As shown in the following table, the data packet of the access network mainly includes the following parts:
DA SA Reserved Payload CRC
Wherein:
the Destination Address (DA) is composed of 8 bytes (byte), the first byte represents the type of the data packet (such as various protocol packets, multicast data packets, unicast data packets, etc.), there are 256 possibilities at most, the second byte to the sixth byte are metropolitan area network addresses, and the seventh byte and the eighth byte are access network addresses;
The Source Address (SA) is also composed of 8 bytes (byte), defined as the same as the Destination Address (DA);
The reserved byte consists of 2 bytes;
The payload part has different lengths according to different types of datagrams, and is 64 bytes if the datagram is various types of protocol packets, and is 32+1024 or 1056 bytes if the datagram is a unicast packet, of course, the length is not limited to the above 2 types;
The CRC consists of 4 bytes and is calculated in accordance with the standard ethernet CRC algorithm.
2.2 metropolitan area network packet definition
The topology of a metropolitan area network is a graph and there may be 2, or even more than 2, connections between two devices, i.e., there may be more than 2 connections between a node switch and a node server, a node switch and a node switch, and a node switch and a node server. However, the metro network address of the metro network device is unique, and in order to accurately describe the connection relationship between the metro network devices, parameters are introduced in the embodiment of the present invention: a label to uniquely describe a metropolitan area network device.
in this specification, the definition of the Label is similar to that of the Label of MPLS (Multi-Protocol Label Switch), and assuming that there are two connections between the device a and the device B, there are 2 labels for the packet from the device a to the device B, and 2 labels for the packet from the device B to the device a. The label is classified into an incoming label and an outgoing label, and assuming that the label (incoming label) of the packet entering the device a is 0x0000, the label (outgoing label) of the packet leaving the device a may become 0x 0001. The network access process of the metro network is a network access process under centralized control, that is, address allocation and label allocation of the metro network are both dominated by the metro server, and the node switch and the node server are both passively executed, which is different from label allocation of MPLS, and label allocation of MPLS is a result of mutual negotiation between the switch and the server.
As shown in table 1 below, the data packet of the metropolitan area network mainly includes the following parts:
TABLE 1
DA SA Reserved label (R) Payload CRC
namely Destination Address (DA), Source Address (SA), Reserved byte (Reserved), tag, payload (pdu), CRC. The format of the tag may be defined by reference to the following: the tag is 32 bits with the upper 16 bits reserved and only the lower 16 bits used, and its position is between the reserved bytes and payload of the packet.
a driving mode: particularly, running programs on a driving layer;
thread: the minimum unit in which the operating system can perform operation scheduling;
Thread synchronization: synchronization is a coordinated pace, running in a predetermined sequence. When one thread operates the memory, other threads can not operate the memory address until the thread finishes the operation, and the other threads can not operate the memory address and are in a waiting state;
IRQL: interrupt ReQuest Level, a concept virtualized by windows;
Asynchronization: the method particularly refers to the asynchronous processing of computer multithreading, and the asynchronous processing does not block the current thread.
based on the characteristics of the video network, one of the core concepts of the embodiments of the present invention is provided, a non-lock container is adopted to access a video network message, after an instruction of a first thread or a second thread is received, whether the non-lock container has a space for writing data is determined by judging the magnitude of a writing flag bit value and a reading flag bit value of the non-lock container, and further whether the non-lock container can read data is determined, in the process of thread synchronization, locking is not required, blocking cannot be triggered, thread safety is achieved, and the defect that the blue screen of an operating system is caused by blocking due to the fact that the video network message is written into a locked container in a driving mode is overcome.
An embodiment of the present invention provides a message processing method, which is used for performing container-lock-free caching on acquired video networking message data. The execution main body of the embodiment is a message processing device, and the device may be disposed in an RIP Agent (i.e., an i2v protocol client), and the RIP Agent is disposed in an electronic device, where the electronic device may be a PC, a tablet computer, a mobile phone terminal, or the like.
fig. 5 is a flowchart of steps of an embodiment of a message processing method according to the present invention, and as shown in fig. 5, the method is applied to a video network, and the method includes:
s501, receiving a writing instruction sent by a first thread, and judging the magnitude of a writing flag bit value and a reading flag bit value;
S502, if the writing flag bit value is larger than the reading flag bit value, writing the video network message data into a lock-free container, and modifying the writing flag bit value according to the length information of the video network message data;
S503, receiving a reading instruction sent by a second thread, and judging the magnitude of the writing flag bit value and the magnitude of the reading flag bit value;
S504, if the writing flag bit value is larger than the reading flag bit value, modifying the reading flag bit according to the length information of the message data of the video network to be read, and reading the message data from the container without lock.
specifically, the above scheme may be used in the following scenarios:
if the two PCs communicate with each other through the video network, the PC 1 sends the video network message data to the PC 2 through the video network, firstly, the PC 1 firstly sends the video network message data to the network card of the PC 2, the PC 2 firstly caches the video network message data, and then, the video network message data is converted into other data for replacing other programs or PC terminals. The message processing method provided by the embodiment of the invention is mainly applied to the process of caching the message data of the video network.
Fig. 6 is a diagram illustrating a structure of message processing according to an embodiment of the present invention, as shown in fig. 6, where a thread 1 in the diagram is a first thread, a thread 2 is a second thread, and a video networking message is video networking message data, and in a process of caching the video networking message data, the process includes two processes of data writing and data reading, where the video networking message data is written into a lock-free container first, and then the data is read from the lock-free container, specifically:
And the thread 1 writes the video networking message into the lock-free container ring _ buf:
The thread 1 reads video networking message data from a video networking network card and sends a writing instruction to the unlocking container ring _ buf, after the unlocking container receives the writing instruction, the values of a writing zone bit and a reading zone bit are judged, and whether the ring _ buf has an available space or not can be judged according to the values of the reading zone bit and the writing zone bit; if the writing flag bit value is larger than the reading flag bit value, indicating that the ring _ buf has available space, writing the video networking message data into the ring _ buf, and modifying the writing flag bit value according to the length information of the video networking message data after the video networking message data is written;
Thread 2: reading the video network message data from the lock-free container ring _ buf, and processing the video network message data by other functional modules;
After receiving a read instruction sent by a thread 2, the non-lock container firstly judges the values of the write flag bits and the read flag bits, and determines whether the non-lock container has readable data or not by judging the values of the write flag bits and the read flag bits;
And if the value of the writing zone bit is greater than the value of the reading zone bit, modifying the reading zone bit according to the length information of the message data of the video network to be read, and reading the message data from the container without the lock.
illustratively, in an initial state of the lock-free container, the values of the write flag bit and the read flag bit are both 0, when the thread 1 writes the view networking message data into the lock-free container, assuming that the view networking message data is 8 bytes of data, after the 8 bytes of data are written into the lock-free container, the value of the write flag bit is changed to 8, and the value of the read flag bit is 0; at this time, the value of the writing flag bit is greater than that of the reading flag bit, and the data can be continuously written;
When the thread 2 reads data from the lock-free container, the values of the read flag bit and the write flag bit are determined first, for example, the value of the write flag bit is 8, and data of 6 bytes needs to be read from the lock-free container, the value of the read flag bit is modified to 6, at this time, the value of the write flag bit is greater than the value of the read flag bit, which indicates that there is readable data in the lock-free container, and the data is taken out.
It should be noted that, in the above steps, the execution order of the first thread and the second thread is not specifically limited in the embodiment of the present invention, and the first thread and the second thread may be executed simultaneously, or the first thread and the second thread may be executed first, where the first thread and the second thread are only used to distinguish different threads.
according to the message processing method provided by the embodiment, after the instruction of the first thread or the second thread is received, whether the lock-free container has a space for writing data is determined by judging the values of the writing flag bits and the reading flag bits of the lock-free container, and then whether the data can be read from the lock-free container is determined.
the method provided by the above embodiment is further described in an additional embodiment of the present invention.
on the basis of the foregoing embodiment, optionally, after receiving the write instruction sent by the first thread, the method further includes:
and if the writing flag bit value is equal to the reading flag bit value, stopping writing the video networking message data into the lock-free container.
Fig. 7 is a diagram illustrating a step of another embodiment of a message processing method according to the present invention, as shown in fig. 7, since the lockless container is a container that is closed end to end and can be accessed circularly, after receiving a write instruction sent by the first thread, when the value of the write flag bit is greater than the value of the read flag bit, data is written into the lockless container until it is detected that the value of the write flag bit is equal to the value of the read flag bit again, writing of the packet data in the lockless container is stopped, and the packet data in the packet is discarded.
On the basis of the foregoing embodiment, optionally, after receiving the read instruction sent by the second thread, the method further includes:
And if the writing flag bit value is equal to the reading flag bit value, the video networking message data does not exist in the lock-free container for the second thread to read.
specifically, after receiving a read instruction sent by a thread 2, the non-lock container firstly judges the values of a write flag bit and a read flag bit, and determines whether readable data exists in the non-lock container by judging the values of the write flag bit and the read flag bit;
if the value of the writing zone bit is larger than that of the reading zone bit, modifying the reading zone bit according to the length information of the message data of the video network to be read, and reading the message data from the container without lock;
if the value of the write flag bit is equal to the value of the read flag bit, it indicates that the video networking message data is not read in the lock-free container, and the data can be read only when the thread writes the data again.
Optionally, the modifying the value of the writing flag bit according to the length information of the video networking message data specifically includes:
And modifying the value of the writing flag bit according to the length of the byte number of the video network message data.
optionally, the lockless container is an annular container connected end to end.
the lockless container provided by the embodiment of the invention is a closed container which is connected end to end and can be cyclically accessed, and can be in any shape, and in the embodiment of the invention, a ring-shaped container which is connected end to end is preferred, as shown in fig. 7.
It should be noted that the respective implementable modes in the present embodiment may be implemented individually, or may be implemented in combination in any combination without conflict, and the present application is not limited thereto.
according to the message processing method provided by the embodiment, after the instruction of the first thread or the second thread is received, whether the lock-free container has a space for writing data is determined by judging the values of the writing flag bits and the reading flag bits of the lock-free container, and then whether the data can be read from the lock-free container is determined.
It should be noted that, for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the illustrated order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments of the present invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
another embodiment of the present invention provides a message processing apparatus, configured to execute the method provided in the foregoing embodiment.
Fig. 8 is a block diagram of an embodiment of a message processing apparatus according to the present invention, as shown in fig. 8, the message processing apparatus is applied in a video network, and the message processing apparatus includes a first receiving module 80, a write data module 81, a second receiving module 82, and a read data module 83;
The first receiving module 80 is configured to receive a write instruction sent by a first thread, and determine the values of a write flag bit and a read flag bit;
the write-in data module 81 is configured to write the video networking message data into the lock-free container if the write flag bit value is greater than the read flag bit value, and modify the write flag bit value according to length information of the video networking message data;
the second receiving module 82 is configured to receive a read instruction sent by a second thread, and determine the values of the write flag bits and the read flag bits;
the data reading module 83 is configured to modify the read flag bit according to length information of the packet data of the video network to be read if the value of the write flag bit is greater than the value of the read flag bit, and read the packet data from the lock-free container.
The specific manner in which the respective modules perform operations has been described in detail in relation to the apparatus in this embodiment, and will not be elaborated upon here.
the message processing apparatus provided in this embodiment determines whether there is space in which data can be written in the unlocked container and further determines whether data can be read from the unlocked container by judging the values of the write flag bits and the read flag bits of the unlocked container after receiving the instruction of the first thread or the second thread.
The device provided by the above embodiment is further described in an additional embodiment of the present invention.
On the basis of the foregoing embodiment, optionally, the write data module is further configured to:
and if the writing flag bit value is equal to the reading flag bit value, stopping writing the video networking message data into the lock-free container.
On the basis of the foregoing embodiment, optionally, the data reading module is further configured to:
And if the writing flag bit value is equal to the reading flag bit value, the video networking message data is not read in the lock-free container.
optionally, the write data module is specifically configured to:
And modifying the value of the writing flag bit according to the length of the byte number of the video network message data.
optionally, the lockless container is an annular container connected end to end.
The specific manner in which the respective modules perform operations has been described in detail in relation to the apparatus in this embodiment, and will not be elaborated upon here.
It should be noted that the respective implementable modes in the present embodiment may be implemented individually, or may be implemented in combination in any combination without conflict, and the present application is not limited thereto.
The message processing apparatus provided in this embodiment determines whether there is space in which data can be written in the unlocked container and further determines whether data can be read from the unlocked container by judging the values of the write flag bits and the read flag bits of the unlocked container after receiving the instruction of the first thread or the second thread.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
Still another embodiment of the present invention provides an electronic device, configured to perform the method provided by the foregoing embodiment.
fig. 9 is a schematic structural diagram of an electronic device according to the present invention, and as shown in fig. 9, the electronic device has a RIP Agent installed thereon, and includes: at least one processor 91 and memory 92;
the memory stores a computer program; the at least one processor executes the computer program stored by the memory to implement the methods provided by the above-described embodiments.
The electronic device provided by this embodiment determines whether there is space in the unlocked container to write data by judging the values of the write flag bits and the read flag bits of the unlocked container after receiving the instruction of the first thread or the second thread, and further determines whether data can be read from the unlocked container.
Yet another embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored, and the computer program is executed to implement the method provided in any one of the above embodiments.
According to the computer-readable storage medium of the embodiment, after receiving the instruction of the first thread or the second thread, by judging the values of the write flag bits and the read flag bits of the lock-free container, whether the lock-free container has a space for writing data or not is determined, and further whether the data can be read from the lock-free container or not is determined.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
as will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the embodiments of the invention.
finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.
the above detailed description is given to a message processing method and apparatus provided by the present invention, and a specific example is applied in the text to explain the principle and the implementation of the present invention, and the description of the above embodiment is only used to help understanding the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (10)

1. a message processing method is applied to a video network, and comprises the following steps:
Receiving a write instruction sent by a first thread, and judging the magnitude of a write flag bit value and a read flag bit value;
if the writing flag bit value is larger than the reading flag bit value, writing the video network message data into a lock-free container, and modifying the writing flag bit value according to the length information of the video network message data;
Receiving a reading instruction sent by a second thread, and judging the magnitude of the writing flag bit value and the magnitude of the reading flag bit value;
And if the writing zone bit value is greater than the reading zone bit value, modifying the reading zone bit according to the length information of the message data of the video network to be read, and reading the message data from the lock-free container.
2. The method of claim 1, wherein after receiving the write instruction sent by the first thread, the method further comprises:
And if the writing flag bit value is equal to the reading flag bit value, stopping writing the video networking message data into the lock-free container.
3. The method of claim 1, wherein after receiving the read instruction sent by the second thread, the method further comprises:
And if the writing flag bit value is equal to the reading flag bit value, the video networking message data does not exist in the lock-free container for the second thread to read.
4. The method of claim 1, wherein modifying the value of the flag bit according to the length information of the packet data comprises:
And modifying the value of the writing flag bit according to the length of the byte number of the video network message data.
5. the method of any one of claims 1 to 4, wherein the lockless container is an endless ring container.
6. a message processing device, which is applied in video network, includes:
the first receiving module is used for receiving a writing instruction sent by a first thread and judging the values of a writing flag bit and a reading flag bit;
The write-in data module is used for writing the video networking message data into a lock-free container if the write flag bit value is larger than the read flag bit value, and modifying the write flag bit value according to the length information of the video networking message data;
the second receiving module is used for receiving a reading instruction sent by a second thread and judging the values of the writing flag bits and the reading flag bits;
and the data reading module is used for modifying the reading zone bit according to the length information of the video network message data to be read and reading the message data from the lock-free container if the writing zone bit value is greater than the reading zone bit value.
7. The apparatus of claim 6, wherein the write data module is further configured to:
and if the writing flag bit value is equal to the reading flag bit value, stopping writing the video networking message data into the lock-free container.
8. the apparatus of claim 6, wherein the read data module is further configured to:
and if the writing flag bit value is equal to the reading flag bit value, the video networking message data is not read in the lock-free container.
9. The apparatus of claim 6, wherein the write data module is specifically configured to:
And modifying the value of the writing flag bit according to the length of the byte number of the video network message data.
10. The apparatus of any one of claims 6 to 9, wherein the lockless container is an endless loop container.
CN201910696222.4A 2019-07-30 2019-07-30 Message processing method and device Pending CN110554924A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910696222.4A CN110554924A (en) 2019-07-30 2019-07-30 Message processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910696222.4A CN110554924A (en) 2019-07-30 2019-07-30 Message processing method and device

Publications (1)

Publication Number Publication Date
CN110554924A true CN110554924A (en) 2019-12-10

Family

ID=68737175

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910696222.4A Pending CN110554924A (en) 2019-07-30 2019-07-30 Message processing method and device

Country Status (1)

Country Link
CN (1) CN110554924A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116737281A (en) * 2023-01-12 2023-09-12 银河航天(北京)通信技术有限公司 File uploading method, device and storage medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090031306A1 (en) * 2007-07-23 2009-01-29 Redknee Inc. Method and apparatus for data processing using queuing
CN101800867A (en) * 2010-01-19 2010-08-11 深圳市同洲电子股份有限公司 Method, device and digital-television receiving terminal for realizing ring buffer
WO2010148985A1 (en) * 2009-11-24 2010-12-29 中兴通讯股份有限公司 Rfid reader and data storage method thereof
CN102075401A (en) * 2011-01-28 2011-05-25 成都市华为赛门铁克科技有限公司 Method, equipment and system for transmitting message on peripheral component interface express (PCIE) bus
CN102789458A (en) * 2011-05-18 2012-11-21 腾讯科技(深圳)有限公司 Image file processing method and system
CN105337898A (en) * 2015-12-03 2016-02-17 北京浩瀚深度信息技术股份有限公司 Double-cache message processing method with control information separated from data
CN109271242A (en) * 2018-08-28 2019-01-25 百度在线网络技术(北京)有限公司 Data processing method, device, equipment and medium based on queue
CN109586851A (en) * 2018-11-28 2019-04-05 视联动力信息技术股份有限公司 Data transmission method and device based on view networking

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090031306A1 (en) * 2007-07-23 2009-01-29 Redknee Inc. Method and apparatus for data processing using queuing
WO2010148985A1 (en) * 2009-11-24 2010-12-29 中兴通讯股份有限公司 Rfid reader and data storage method thereof
CN101800867A (en) * 2010-01-19 2010-08-11 深圳市同洲电子股份有限公司 Method, device and digital-television receiving terminal for realizing ring buffer
CN102075401A (en) * 2011-01-28 2011-05-25 成都市华为赛门铁克科技有限公司 Method, equipment and system for transmitting message on peripheral component interface express (PCIE) bus
CN102789458A (en) * 2011-05-18 2012-11-21 腾讯科技(深圳)有限公司 Image file processing method and system
CN105337898A (en) * 2015-12-03 2016-02-17 北京浩瀚深度信息技术股份有限公司 Double-cache message processing method with control information separated from data
CN109271242A (en) * 2018-08-28 2019-01-25 百度在线网络技术(北京)有限公司 Data processing method, device, equipment and medium based on queue
CN109586851A (en) * 2018-11-28 2019-04-05 视联动力信息技术股份有限公司 Data transmission method and device based on view networking

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
王超等: "异质存储系统中的高速缓存机制研究", 《电子学报》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116737281A (en) * 2023-01-12 2023-09-12 银河航天(北京)通信技术有限公司 File uploading method, device and storage medium
CN116737281B (en) * 2023-01-12 2024-01-09 银河航天(北京)通信技术有限公司 File uploading method, device and storage medium

Similar Documents

Publication Publication Date Title
CN111193788A (en) Audio and video stream load balancing method and device
CN110730500B (en) Terminal network access method, server, terminal, electronic equipment and storage medium
CN110557319B (en) Message processing method and device based on video network
CN109151061B (en) Data storage method and device
CN110022500B (en) Packet loss processing method and device
CN110554924A (en) Message processing method and device
CN110166840B (en) Service processing method, system and device
CN110445701B (en) Business object processing method and device and storage medium
CN110267110B (en) Concurrent on-demand processing method and system based on video network
CN109522110B (en) Multitask management system and method based on video networking
CN110213533B (en) Method and device for acquiring video stream monitored by video network
CN110493311B (en) Service processing method and device
CN110266768B (en) Data transmission method and system
CN110096854B (en) Resource permission sharing method and device and readable storage medium
CN110225079B (en) Equipment control method and device and readable storage medium
CN109787993B (en) Method and device for multi-user to access private network
CN109474848B (en) Video processing method and device based on video network, electronic equipment and medium
CN110475088B (en) User login method and device
CN109640036B (en) Configuration modification method and device
CN109495709B (en) Video network management system and method
CN110365930B (en) Data processing method and device
CN110324286B (en) Conference control system and method
CN110784677A (en) Browsing method and device for monitoring resources and storage medium
CN110784683A (en) Management method, device and storage medium for monitoring resources
CN110556106A (en) monitoring service processing method and 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
RJ01 Rejection of invention patent application after publication

Application publication date: 20191210

RJ01 Rejection of invention patent application after publication