CN113242059B - Lock-free multi-coordination processing thread concurrent meter reading method based on double-ring queue - Google Patents

Lock-free multi-coordination processing thread concurrent meter reading method based on double-ring queue Download PDF

Info

Publication number
CN113242059B
CN113242059B CN202110643614.1A CN202110643614A CN113242059B CN 113242059 B CN113242059 B CN 113242059B CN 202110643614 A CN202110643614 A CN 202110643614A CN 113242059 B CN113242059 B CN 113242059B
Authority
CN
China
Prior art keywords
task
meter reading
queue
annular
index
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
CN202110643614.1A
Other languages
Chinese (zh)
Other versions
CN113242059A (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.)
Wuhan Zhongyuan Electronic Information Co ltd
Original Assignee
Wuhan Zhongyuan Electronic Information 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 Wuhan Zhongyuan Electronic Information Co ltd filed Critical Wuhan Zhongyuan Electronic Information Co ltd
Priority to CN202110643614.1A priority Critical patent/CN113242059B/en
Publication of CN113242059A publication Critical patent/CN113242059A/en
Application granted granted Critical
Publication of CN113242059B publication Critical patent/CN113242059B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04BTRANSMISSION
    • H04B3/00Line transmission systems
    • H04B3/54Systems for transmission via power distribution lines
    • H04B3/544Setting up communications; Call and signalling arrangements
    • 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/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Power Engineering (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Arrangements For Transmission Of Measured Signals (AREA)
  • Selective Calling Equipment (AREA)

Abstract

The invention provides a lock-free multi-coordination processing thread concurrent meter reading method based on a double-ring queue, which comprises the following steps: s100: the method comprises the steps that a concentrator, a router and a local carrier module, a polling thread module, a plurality of co-processing thread modules and a main thread module of a home-entry electric meter based on a power supply area are established; s200: in a meter reading period, an I/O port of the concentrator continuously sends out a plurality of meter reading tasks in parallel; s300; the local carrier module is used for constructing an annular task queue and an annular index queue; s400: reading a meter reading task of the concentrator by the main thread, and arranging an idle co-processing thread module to execute the meter reading task; s500: the household electricity meter generates confirmation information and sends the confirmation information to the concentrator for meter reading, and the household electricity meter generates a data uploading task; s600: executing a data uploading task; s700: and after the data uploading task is executed, verifying the confirmation information, and repeatedly executing or terminating the result which does not meet the requirement.

Description

Lock-free multi-coordination processing thread concurrent meter reading method based on double-ring queue
Technical Field
The invention relates to the technical field of intelligent meter reading of a power grid, in particular to a lock-free multi-coordination processing thread concurrent meter reading method based on a double-ring queue.
Background
The power line network is a network which is currently covered very widely, realizes a communication function by using a power cable as a transmission medium, and has the advantages of no need of repeated wiring, low installation and maintenance cost and the like. The method depends on a power line network to perform remote electric energy meter reading of electric power users in an analog or digital mode, remote control of voltage equipment and the like, and is very convenient and fast to apply. The intelligent power grid meter reading based on the power line mainly depends on the power line network to periodically read the electric energy of the household electric meters governed by the concentrators in the access areas so as to obtain the electric energy data of the household electric meters at corresponding moments, and is used for realizing functions of electric energy charging, power grid loss calculation, high-frequency 96-point daily load curve data acquisition and the like.
The traditional concentrator meter reading mode adopts a question-and-answer mode or a simple parallel processing mode, the processing time required for reading data of a certain household electricity meter is very long, the next task can be performed after the current task is successfully read or fails to be read beyond a specified delay time, the meter reading task efficiency is extremely low, and the timeliness of the meter reading task is poor.
Disclosure of Invention
In view of this, the invention provides a lock-free multi-coordination processing thread concurrent meter reading method based on a double-ring queue, which has high meter reading task efficiency.
The technical scheme of the invention is realized as follows: the invention provides a lock-free multi-coordination processing thread concurrent meter reading method based on a double-ring queue, which comprises the following steps:
s100: the method comprises the steps that a concentrator, a router and a local carrier module, a polling thread module, a plurality of co-processing thread modules and a main thread module of a home-entry electric meter based on a power supply area are established;
s200: in a meter reading period, an I/O port of the concentrator continuously sends out a plurality of meter reading tasks in parallel; when the I/O port of the concentrator reaches the upper limit of the concurrent meter reading task, the concentrator stops sending the meter reading task;
s300; the local carrier module is used for constructing an annular task queue and an annular index queue, and each task position in the annular task queue respectively corresponds to a meter reading task to be processed sent by an I/O port of the concentrator; each index position of the annular index queue corresponds to a thread index; the length of the annular task queue is the same as that of the annular index queue, and the task positions in the annular task queue and the index positions in the annular index queue are arranged in a one-to-one correspondence manner; when the annular task queue is full or the annular index queue is full, the local carrier module sends a queue full signal to the concentrator, and the concentrator stops sending a meter reading task after receiving the queue full signal; each thread index is associated with a co-processing thread module in a current idle state;
s400: the main thread reads the meter reading tasks at regular intervals from the I/O port of the concentrator, and when a plurality of legal meter reading tasks are read, the main thread module stores the meter reading tasks into the vacant queue position at the rear end of the annular task queue; polling each co-processing thread module by the polling thread module, when the co-processing thread module in an idle state exists, selecting a plurality of co-processing thread modules in the idle state by the polling thread module, making a correlation mark at a corresponding index position on the annular index queue, and executing the meter reading task by the co-processing thread module;
s500: after receiving the meter reading task, the household electricity meter generates a first confirmation message, sends the first confirmation message to the concentrator for meter reading, and generates a data uploading task; after the household electricity meter returns the primary confirmation information to the I/O port of the concentrator, the concentrator confirms that the household electricity meter receives the meter reading task, the co-processing thread module informs the local carrier module to release the task position of the annular task queue corresponding to the meter reading task and the index position of the annular index queue, the association relation between the co-processing thread module executing the meter reading task and the index position is released, and the co-processing thread module executing the meter reading task is in an idle state;
s600: the main thread module stores the data uploading task into an empty queue position at the rear end of the annular task queue when the I/O port of the household electricity meter is regularly read by the main thread and the legal data uploading task is read; polling each co-processing thread module by the polling thread module, when the co-processing thread module in the current idle state exists, selecting the co-processing thread module in the idle state by the polling thread module, making a correlation mark at a corresponding index position on the annular index queue, and executing the data uploading task by the idle co-processing thread module;
s700: after the data uploading task is executed, an I/O port of the concentrator receives meter reading uploading data containing primary confirmation information and generates secondary confirmation information; when the primary confirmation information and the secondary confirmation information meet the requirements, the meter reading task and the data uploading task are successful, the co-processing thread module informs the local carrier module to release the task position of the annular task queue corresponding to the data uploading task and the index position of the annular index queue, the association relation between the co-processing thread module executing the data uploading task and the index position of the annular index queue is released, the co-processing thread module executing the data uploading task is in an idle state, and the meter reading task or the data uploading task corresponding to the household electricity meter is not executed in the meter reading period; if the primary confirmation information or the secondary confirmation information does not meet the requirement, the meter reading task or the data uploading task is not successful, the steps S400-S700 are executed again after one or a plurality of fixed time delays, and different co-processing thread modules or routers are selected to execute the meter reading task and the data uploading task again according to the association marks made by the index positions of the annular index queues of the unsuccessful meter reading task or the data uploading task until the primary confirmation information and the secondary confirmation information meet the requirement, the upper limit of the retry times is up or the given deadline of the meter reading task is up.
On the basis of the above technical scheme, preferably, the annular task queue is a task queue with a fixed address space length of MAXSIZE, the address space, i.e., the task position, of each annular task queue corresponds to one meter reading task or data uploading task, the total number of the corresponding executable meter reading tasks or data uploading tasks is MAXSIZE, and the value range corresponding to the task position is (0, MAXSIZE-1); tasks added into the annular task queue are sequentially arranged from the head of the annular queue from small to large according to the value of the task position until the maximum value MAXSIZE of the executable tasks is reached, the annular task queue is updated according to a rolling updating mode, and when the tail of the annular task queue is full, a newly added meter reading task or a data uploading task is filled at the head end of the annular task queue.
Further preferably, the circular index queues are index queues with a fixed address space length of MAXSIZE, the address space, i.e. the index position, of each circular index queue corresponds to the index of one co-processing thread module, the total number of co-processing thread module indexes is MAXSIZE, and the value range of the index position is (0, MAXSIZE-1); the index positions of the annular index queue correspond to the task positions of the annular task queue one by one; the index position of the co-processing thread module is K, the task position of the corresponding annular task queue is also K, and K belongs to (0, MAXSIZE-1); the index positions added first are sequentially arranged from the head of the annular index queue according to the values of the index positions from small to large until the maximum value MAXSIZE of the executable index positions is reached.
More preferably, the rolling update mode of the annular task queue is to set a head pointer and a tail pointer in the annular task queue respectively; according to the first-in first-out sequence, when a new meter reading task or a data uploading task is added into the queue, the pointer at the tail of the queue points to move a blank address space backwards, the new meter reading task or the data uploading task is added into the address space after the movement backwards, and the address space is occupied; if the queue tail pointer is currently located at a task position with a task position of MAXSIZE-1, adding a new meter reading task or a data uploading task and moving back by one position, and then reaching an empty task position with a task position of 0 in the annular task queue; when a new meter reading task or a data uploading task is executed, the task position of the corresponding annular task queue is released, and the queue head pointer steps backwards by one task position; the rolling updating mode of the annular index queue is the same as that of the annular task queue.
Still further preferably, the meter reading task includes a meter reading message frame and a primary verification frame which need to be transmitted; the meter reading message frame comprises concentrator number information, downlink route router number information, target household electricity meter number information and target household electricity meter reading task execution deadline time; the primary verification frame is first digital signature information generated for the meter reading message frame according to an encryption algorithm; and after the meter reading task reaches the meter-to-home electricity meter, the meter-to-home electricity meter respectively confirms the concentrator number information and the target meter-to-home electricity meter number information in the meter reading message frame, and carries out the same encryption algorithm calculation again on the received meter reading message frame to obtain second digital signature information, and carries out character-by-character comparison on the first digital signature information and the second digital signature information corresponding to the primary verification frame, and the comparison result is used as primary confirmation information.
Further preferably, the data uploading task includes an uploading message frame, primary confirmation information, meter reading information and a secondary verification frame which need to be transmitted; the uploading message frame comprises target household electricity meter number information, uplink path router number information, concentrator number information and actual execution completion time of a target household electricity meter reading task; the meter reading information is the reading of the household electricity meter at the current time; the secondary verification frame is third digital signature information generated for the uploading message frame according to an encryption algorithm; after the data uploading task reaches the concentrator, the concentrator respectively confirms the number information of the target household electricity meter, the number information of the uplink route router and the number information of the concentrator in the uploading message frame, and calculates the uploading message frame by adopting an encryption algorithm to obtain fourth digital signature information; and comparing the third digital signature information and the fourth digital signature information corresponding to the secondary verification frame one by one, and taking the comparison result as secondary confirmation information.
Still further preferably, the encryption algorithm is a data digest algorithm.
On the basis of the above technical solution, preferably, when the primary confirmation information or the secondary confirmation information does not meet the requirement, the upper limit of the retry times within the meter reading period is constrained in the following manner: number of retries
Figure 68258DEST_PATH_IMAGE001
The square brackets are rounding operations; and accumulating the time of the meter reading task and the data uploading task once again, and summing up the accumulated time
Figure 932308DEST_PATH_IMAGE002
TThe time interval between two meter reading cycles.
Compared with the prior art, the lock-free multi-coordination processing thread concurrent meter reading method based on the double-ring queue has the following beneficial effects that:
(1) the invention adopts a parallel mode to carry out table look-up operation on the household electric meters, the concentrator starts to send a meter reading task by adopting the maximum concurrent number, the household electric meters execute the meter reading operation after receiving the meter reading task, and generate a data uploading task to return to the concentrator, and the concentrator can renewedly send a meter reading task according to the completed meter reading task no matter whether the meter reading result of the data uploading task is successful, and always maintain the maximum concurrent number of the concentrator until the meter reading tasks of all the household electric meters in a meter reading period are completely executed; the annular task queue and the annular index queue which are updated in a rolling mode are used for storing various tasks and corresponding indexes of the co-processing thread modules, so that meter reading tasks or data uploading tasks to be executed can correspond to the co-processing thread modules one by one, resources of the system are reasonably distributed, the complexity of the system is reduced, and the processing efficiency and the stability of the system are improved;
(2) the method adopts a double ring queue structure, one ring queue stores data transceiving tasks, the other ring queue stores indexes of co-processing threads, the co-processing thread module at the corresponding position, namely the tasks corresponding to the corresponding task position, is executed after initialization, the corresponding idle co-processing threads can be found only by little thread searching cost, and the space of the corresponding queue position is released for recycling after the execution is finished, so that the task execution efficiency is greatly improved compared with the traditional method for creating and destroying the threads of special tasks;
(3) the annular task queue and the annular index queue have the first-in first-out characteristic, one co-processing thread module corresponds to one meter reading task or data uploading task, the situation that a plurality of threads process one task is avoided, thread synchronous locks are not required to be designed, and the system overhead can be effectively reduced;
(4) the meter reading task and the data uploading task are respectively subjected to twice digital signature information verification, and after the meter reading process is completed, whether the execution of the meter reading task and the data uploading task is successful or not is evaluated according to the primary confirmation information or the secondary confirmation information so as to determine whether the re-attempt is needed in a meter reading period or not;
(5) the retry times and the accumulated time rule of the meter reading task or the data uploading task in the meter reading period are restrained, the retry of the route is attempted, if the meter reading task or the data uploading task cannot be completed in a plurality of continuous periods, the fact that the corresponding household electric meter, the concentrator I/O port or the router has faults is indicated, and the operation of the corresponding household electric meter needs to be stopped.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a flowchart of a lock-free multiprocessing thread concurrent meter reading method based on a double-ring queue according to the present invention;
FIG. 2 is a concurrent meter reading interaction flow chart of a lock-free multi-coordination processing thread concurrent meter reading method based on a double-ring queue according to the present invention;
FIG. 3 is a structural diagram of a circular task queue or a circular index queue of a lock-free multiprocessing thread concurrent meter reading method based on a double-ring queue according to the present invention;
FIG. 4 is a schematic diagram of a circular task queue and a circular index queue executing a meter reading task or a data uploading task in the lock-free multiprocessing thread concurrent meter reading method based on a double-ring queue according to the present invention;
fig. 5 is a schematic diagram of step-by-step shifting of a head pointer and a tail pointer of an annular task queue and an annular index queue of the lock-free multi-coordination processing thread concurrent meter reading method based on the double-ring queue.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention.
As shown in fig. 1, fig. 2 and fig. 3, the present invention provides a lock-free multi-coordination processing thread concurrent meter reading method based on a dual ring queue, including the following steps:
s100: the method comprises the steps that a concentrator, a router and a local carrier module, a polling thread module, a plurality of co-processing thread modules and a main thread module of a home-entry electric meter based on a power supply area are established;
s200: in a meter reading period, an I/O port of the concentrator continuously sends out a plurality of meter reading tasks in parallel; when the I/O port of the concentrator reaches the upper limit of the concurrent meter reading task, the concentrator stops sending the meter reading task; the diagram shows that only no more than MAXSIZE parallel meter reading tasks can be sent, and the number of the parallel meter reading tasks is adapted to the number of the corresponding executable co-processing thread modules;
s300; the local carrier module is used for constructing an annular task queue and an annular index queue, and each task position in the annular task queue respectively corresponds to a meter reading task to be processed sent by an I/O port of the concentrator; each index position of the annular index queue corresponds to a thread index; the length of the annular task queue is the same as that of the annular index queue, and the task positions in the annular task queue and the index positions in the annular index queue are arranged in a one-to-one correspondence manner; when the annular task queue is full or the annular index queue is full, the local carrier module sends a queue full signal to the concentrator, and the concentrator stops sending a meter reading task after receiving the queue full signal; each thread index is associated with a co-processing thread module in a current idle state; the step is used for establishing different types of tasks for caching data transmission and index information of a co-processing thread module for executing the corresponding tasks; so as to quickly associate the co-processing thread module with the corresponding data transfer task.
Specifically, as shown in fig. 3, the circular task queues are task queues with a fixed address space length of MAXSIZE, the address space, i.e., the task position, of each circular task queue corresponds to one meter reading task or data uploading task, the total number of the corresponding executable meter reading tasks or data uploading tasks is MAXSIZE, and the value range corresponding to the task position is (0, MAXSIZE-1); tasks added into the annular task queue are sequentially arranged from the head of the annular queue from small to large according to the value of the task position until the maximum value MAXSIZE of the executable tasks is reached, the annular task queue is updated according to a rolling updating mode, and when the tail of the annular task queue is full, a newly added meter reading task or a data uploading task is filled at the head end of the annular task queue.
As also shown in fig. 3, the circular index queue is an index queue with a fixed address space length MAXSIZE, and has substantially the same structure as the circular task queue. The address space, namely the index position, of each annular index queue corresponds to the index of one co-processing thread module, the total number of the co-processing thread module indexes is MAXSIZE, and the value range of the index position is (0, MAXSIZE-1); the index positions of the annular index queue and the task positions of the annular task queue are in one-to-one correspondence; the index position of the co-processing thread module is K, the task position of the corresponding annular task queue is also K, and K belongs to (0, MAXSIZE-1); the index positions added first are sequentially arranged from the head of the annular index queue according to the values of the index positions from small to large until the maximum value MAXSIZE of the executable index positions is reached. After the end of the queue is reached, the index of the newly-entered co-processing thread module automatically jumps to the index position of the head end of the circular index queue.
Fig. 4 and 5 show the stepping condition of the circular task queue and the circular index queue after a new meter reading task or a data uploading task. Because the two queues are fixed in length and synchronously stepped, the blank task position or the index position left by the task executed at the front end can be recycled, and only a small amount of overhead of searching the idle co-processing thread module is needed, actions such as establishment, cancellation and the like of a conventional thread can be avoided, so that the operating efficiency of the system is improved, and the complexity and the reliability of the system are also reduced. Because the distance or the execution time of the meter reading tasks at each household electric meter is different, when the concentrator receives the information returned by the household electric meters, the concentrator can successively release the positions in the corresponding annular task queue and the annular index queue and release the corresponding co-processing thread module, and the idle co-processing thread module can be immediately used for another new concurrent meter reading task.
The rolling updating mode of the annular task queue refers to that a head pointer and a tail pointer are respectively arranged in the annular task queue; according to the first-in first-out sequence, when a new meter reading task or a data uploading task is added into the queue, the pointer at the tail of the queue points to move a blank address space backwards, the new meter reading task or the data uploading task is added into the address space after the movement backwards, and the address space is occupied; if the queue tail pointer is currently located at a task position with a task position of MAXSIZE-1, adding a new meter reading task or a data uploading task and moving back by one position, and then reaching an empty task position with a task position of 0 in the annular task queue; when a new meter reading task or a data uploading task is executed, the task position of the corresponding annular task queue is released, and the queue head pointer steps backwards by one task position; the rolling updating mode of the annular index queue is the same as that of the annular task queue.
S400: the main thread reads the meter reading tasks at regular intervals from the I/O port of the concentrator, and when a plurality of legal meter reading tasks are read, the main thread module stores the meter reading tasks into the vacant queue position at the rear end of the annular task queue; and polling the assistant processing thread modules by the polling thread module, when the assistant processing thread modules in the idle state exist, selecting a plurality of assistant processing thread modules in the idle state by the polling thread module, making a relevant mark at a corresponding index position on the annular index queue, and executing meter reading tasks in one-to-one correspondence by the idle assistant processing thread modules.
S500: after receiving the meter reading task, the household electricity meter generates a first confirmation message, sends the first confirmation message to the concentrator for meter reading, and generates a data uploading task; after the household electricity meter returns the primary confirmation information to the I/O port of the concentrator, the concentrator confirms that the household electricity meter receives the meter reading task, the co-processing thread module informs the local carrier module to release the task position of the annular task queue corresponding to the meter reading task and the index position of the annular index queue, the association relation between the co-processing thread module executing the meter reading task and the index position is released, and the co-processing thread module executing the meter reading task is in an idle state.
Specifically, the meter reading task comprises a meter reading message frame and a primary verification frame which need to be transmitted; the meter reading message frame comprises concentrator number information, downlink route router number information, target household electricity meter number information and target household electricity meter reading task execution deadline time; the primary verification frame is first digital signature information generated for the meter reading message frame according to an encryption algorithm; and after the meter reading task reaches the meter-to-home electricity meter, the meter-to-home electricity meter respectively confirms the concentrator number information and the target meter-to-home electricity meter number information in the meter reading message frame, after the meter reading task is confirmed to be correct, the same encryption algorithm calculation is carried out again on the received meter reading message frame to obtain second digital signature information, the first digital signature information corresponding to the primary verification frame and the second digital signature information are compared one by one in a character mode, and the comparison result is used as primary confirmation information. The two times of digital signature information is the result obtained by carrying out the same encryption algorithm on the same meter reading message frame, and if the results are consistent, the content of the meter reading message frame is shown to be completely and accurately transmitted to the household ammeter; if the two frames are inconsistent, the content of the meter reading message frame does not completely reach the household electric meter, and the meter reading task may need to be executed again.
S600: the main thread module stores the data uploading task into an empty queue position at the rear end of the annular task queue when the I/O port of the household electricity meter is regularly read by the main thread and the legal data uploading task is read; polling each co-processing thread module by the polling thread module, when the co-processing thread module in the current idle state exists, selecting the co-processing thread module in the idle state by the polling thread module, making a correlation mark at a corresponding index position on the annular index queue, and executing the data uploading task by the idle co-processing thread module;
the data uploading task comprises an uploading message frame, primary confirmation information, meter reading information and a secondary verification frame which need to be transmitted; the uploading message frame comprises target household electricity meter number information, uplink path router number information, concentrator number information and actual execution completion time of a target household electricity meter reading task; the meter reading information is the reading of the household electricity meter at the current time; the secondary verification frame is third digital signature information generated for the uploading message frame according to an encryption algorithm; after the data uploading task reaches the concentrator, the concentrator respectively confirms the number information of the target household electricity meter, the number information of the uplink route router and the number information of the concentrator in the uploading message frame, and calculates the uploading message frame by adopting an encryption algorithm to obtain fourth digital signature information; and comparing the third digital signature information and the fourth digital signature information corresponding to the secondary verification frame one by one, and taking the comparison result as secondary confirmation information. Similarly, after the data uploading task is executed, the concentrator also performs an encryption algorithm on the uploading message frame to obtain a corresponding result, if the result corresponds to the third digital signature information corresponding to the secondary verification frame, it is indicated that the uploading message frame is completely and reliably transmitted to the concentrator in the data uploading task process, otherwise, it is indicated that the uploading message frame may be incomplete or the content does not meet the requirement, and the data uploading task may need to be executed again. The encryption algorithm in the present invention may employ a data digest algorithm such as the CRC or MD5 algorithm.
S700: after the data uploading task is executed, an I/O port of the concentrator receives meter reading uploading data containing primary confirmation information and generates secondary confirmation information; when the primary confirmation information and the secondary confirmation information meet the requirements, the meter reading task and the data uploading task are successful, the co-processing thread module informs the local carrier module to release the task position of the annular task queue corresponding to the data uploading task and the index position of the annular index queue, the association relation between the co-processing thread module executing the data uploading task and the index position of the annular index queue is released, the co-processing thread module executing the data uploading task is in an idle state, and the meter reading task or the data uploading task corresponding to the household electricity meter is not executed in the meter reading period; if the primary confirmation information or the secondary confirmation information does not meet the requirement, the meter reading task or the data uploading task is not successful, the steps S400-S700 are executed again after one or a plurality of fixed time delays, and different co-processing thread modules or routers are selected to execute the meter reading task and the data uploading task again according to the association marks made by the index positions of the annular index queues of the unsuccessful meter reading task or the data uploading task until the primary confirmation information and the secondary confirmation information meet the requirement, the upper limit of the retry times is up or the given deadline of the meter reading task is up.
When the first confirmation information and the second confirmation information both meet the requirements, the complete and reliable execution of the cyclic response meter reading process of the concentrator, the household electricity meter and the concentrator in the meter reading period is indicated, and the corresponding request of the meter reading task can not be sent again in the period. If the first confirmation information or the second confirmation information does not meet the requirement, re-trying until an expected result is obtained, re-trying to replace a transmission path of the meter reading task to judge whether a channel is unblocked, and carrying out association marking on parameters of failed trials; if the expected result cannot be obtained even after a plurality of attempts or a specified deadline is reached, the meter reading work of the household electric meter is possibly not finished, and when the meter reading task of the specific household electric meter cannot be smoothly realized in a plurality of continuous meter reading periods, the faults of the I/O port of the concentrator or the household electric meter are considered, and then the troubleshooting is carried out according to the signal transmission sequence.
Certainly, in order to save system resources, the number of times of trying to change the transmission path of the meter reading task again is limited, and the specific requirements are as follows: when the first confirmation information or the second confirmation information does not meet the requirement, the upper limit of the retry times in the meter reading period is restricted by adopting the following mode
Figure 215522DEST_PATH_IMAGE001
The square brackets are rounding operations; and accumulating the time of the meter reading task and the data uploading task once again, and summing up the accumulated time
Figure 756094DEST_PATH_IMAGE002
TThe time interval between two meter reading cycles.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.

Claims (8)

1. A lock-free multi-coordination processing thread concurrent meter reading method based on a double-ring queue is characterized by comprising the following steps: the method comprises the following steps:
s100: the method comprises the steps that a concentrator, a router and a local carrier module, a polling thread module, a plurality of co-processing thread modules and a main thread module of a home-entry electric meter based on a power supply area are established;
s200: in a meter reading period, an I/O port of the concentrator continuously sends out a plurality of meter reading tasks in parallel; when the I/O port of the concentrator reaches the upper limit of the concurrent meter reading task, the concentrator stops sending the meter reading task;
s300; the local carrier module is used for constructing an annular task queue and an annular index queue, and each task position in the annular task queue respectively corresponds to a meter reading task to be processed sent by an I/O port of the concentrator; each index position of the annular index queue corresponds to a thread index; the length of the annular task queue is the same as that of the annular index queue, and the task positions in the annular task queue and the index positions in the annular index queue are arranged in a one-to-one correspondence manner; when the annular task queue is full or the annular index queue is full, the local carrier module sends a queue full signal to the concentrator, and the concentrator stops sending a meter reading task after receiving the queue full signal; each thread index is associated with a co-processing thread module in a current idle state;
s400: the main thread reads the meter reading tasks at regular intervals from the I/O port of the concentrator, and when a plurality of legal meter reading tasks are read, the main thread module stores the meter reading tasks into the vacant queue position at the rear end of the annular task queue; polling each co-processing thread module by the polling thread module, when the co-processing thread module in an idle state exists, selecting a plurality of co-processing thread modules in the idle state by the polling thread module, making a correlation mark at a corresponding index position on the annular index queue, and executing the meter reading task by the co-processing thread module;
s500: after receiving the meter reading task, the household electricity meter generates a first confirmation message, sends the first confirmation message to the concentrator for meter reading, and generates a data uploading task; after the household electricity meter returns the primary confirmation information to the I/O port of the concentrator, the concentrator confirms that the household electricity meter receives the meter reading task, the co-processing thread module informs the local carrier module to release the task position of the annular task queue corresponding to the meter reading task and the index position of the annular index queue, the association relation between the co-processing thread module executing the meter reading task and the index position is released, and the co-processing thread module executing the meter reading task is in an idle state;
s600: the main thread module stores the data uploading task into an empty queue position at the rear end of the annular task queue when the I/O port of the household electricity meter is regularly read by the main thread and the legal data uploading task is read; polling each co-processing thread module by the polling thread module, when the co-processing thread module in the current idle state exists, selecting the co-processing thread module in the idle state by the polling thread module, making a correlation mark at a corresponding index position on the annular index queue, and executing the data uploading task by the idle co-processing thread module;
s700: after the data uploading task is executed, an I/O port of the concentrator receives meter reading uploading data containing primary confirmation information and generates secondary confirmation information; when the primary confirmation information and the secondary confirmation information both meet the requirements, the meter reading task and the data uploading task are both successful, the co-processing thread module informs the local carrier module to release the task position of the annular task queue corresponding to the data uploading task and the index position of the annular index queue, and the association relationship between the co-processing thread module executing the data uploading task and the index position of the annular index queue is released, so that the co-processing thread module executing the data uploading task is in an idle state, and the meter reading task or the data uploading task corresponding to the household electricity meter is not executed in the meter reading period; if the primary confirmation information or the secondary confirmation information does not meet the requirement, the meter reading task or the data uploading task is not successful, the steps S400-S700 are executed again after one or a plurality of fixed time delays, and different co-processing thread modules or routers are selected to execute the meter reading task and the data uploading task again according to the association marks made by the index positions of the annular index queues of the unsuccessful meter reading task or the data uploading task until the primary confirmation information and the secondary confirmation information are completely the same, the upper limit of the retry times is reached, or the given deadline of the meter reading task is reached.
2. The lock-free multi-coprocessing thread concurrent meter reading method based on the double ring queue of claim 1, wherein: the annular task queues are task queues with the fixed address space length of MAXSIZE, the address space (namely, the task position) of each annular task queue corresponds to a meter reading task or a data uploading task, the total number of the corresponding executable meter reading tasks or the data uploading tasks is MAXSIZE, and the value range corresponding to the task position is (0, MAXSIZE-1); tasks added into the annular task queue are sequentially arranged from the head of the annular queue from small to large according to the value of the task position until the maximum value MAXSIZE of the executable tasks is reached, the annular task queue is updated according to a rolling updating mode, and when the tail of the annular task queue is full, a newly added meter reading task or a data uploading task is filled at the head end of the annular task queue.
3. The lock-free multi-coprocessing thread concurrent meter reading method based on the double ring queue of claim 2, wherein: the circular index queues are index queues with the fixed address space length of MAXSIZE, the address space, namely the index position, of each circular index queue corresponds to the index of one co-processing thread module, the total number of indexes of the co-processing thread modules is MAXSIZE, and the value range of the index position is (0, MAXSIZE-1); the index positions of the annular index queue correspond to the task positions of the annular task queue one by one; the index position of the co-processing thread module is K, the task position of the corresponding annular task queue is also K, and K belongs to (0, MAXSIZE-1); the index positions added first are sequentially arranged from the head of the annular index queue according to the values of the index positions from small to large until the maximum value MAXSIZE of the executable index positions is reached.
4. The lock-free multi-coprocessing thread concurrent meter reading method based on the double ring queue of claim 3, wherein: the rolling updating mode of the annular task queue is that a head pointer and a tail pointer are respectively arranged in the annular task queue; according to the first-in first-out sequence, when a new meter reading task or a data uploading task is added into the queue, the pointer at the tail of the queue points to move a blank address space backwards, the new meter reading task or the data uploading task is added into the address space after the movement backwards, and the address space is occupied; if the queue tail pointer is currently located at a task position with a task position of MAXSIZE-1, adding a new meter reading task or a data uploading task and moving back by one position, and then reaching an empty task position with a task position of 0 in the annular task queue; when a new meter reading task or a data uploading task is executed, the task position of the corresponding annular task queue is released, and the queue head pointer steps backwards by one task position; the rolling updating mode of the annular index queue is the same as that of the annular task queue.
5. The lock-free multi-coprocessing thread concurrent meter reading method based on the double ring queue of claim 4, wherein: the meter reading task comprises a meter reading message frame and a primary verification frame which need to be transmitted; the meter reading message frame comprises concentrator number information, downlink route router number information, target household electricity meter number information and target household electricity meter reading task execution deadline time; the primary verification frame is first digital signature information generated for the meter reading message frame according to an encryption algorithm; and after the meter reading task reaches the meter-to-home electricity meter, the meter-to-home electricity meter respectively confirms the concentrator number information and the target meter-to-home electricity meter number information in the meter reading message frame, and carries out the same encryption algorithm calculation again on the received meter reading message frame to obtain second digital signature information, and carries out character-by-character comparison on the first digital signature information and the second digital signature information corresponding to the primary verification frame, and the comparison result is used as primary confirmation information.
6. The lock-free multi-coprocessing thread concurrent meter reading method based on the double ring queue of claim 5, wherein: the data uploading task comprises an uploading message frame needing to be transmitted, primary confirmation information, meter reading information and a secondary verification frame; the uploading message frame comprises target household electricity meter number information, uplink path router number information, concentrator number information and actual execution completion time of a target household electricity meter reading task; the meter reading information is the reading of the household electricity meter at the current time; the secondary verification frame is third digital signature information generated for the uploading message frame according to an encryption algorithm; after the data uploading task reaches the concentrator, the concentrator respectively confirms the number information of the target household electricity meter, the number information of the uplink route router and the number information of the concentrator in the uploading message frame, and calculates the uploading message frame by adopting an encryption algorithm to obtain fourth digital signature information; and comparing the third digital signature information and the fourth digital signature information corresponding to the secondary verification frame one by one, and taking the comparison result as secondary confirmation information.
7. The lock-free multi-coprocessing thread concurrent meter reading method based on the double ring queue according to claim 5 or 6, characterized in that: the encryption algorithm is a data summarization algorithm.
8. The lock-free multi-coprocessing thread concurrent meter reading method based on the double ring queue of claim 1, wherein: when the first confirmation information or the second confirmation information does not meet the requirement, the upper limit of the retry times in the meter reading period is restricted by adopting the following mode: number of retries
Figure 992565DEST_PATH_IMAGE001
The square brackets are rounding operations; and accumulating the time of the meter reading task and the data uploading task once again, and summing up the accumulated time
Figure 378547DEST_PATH_IMAGE002
TThe time interval between two meter reading cycles.
CN202110643614.1A 2021-06-09 2021-06-09 Lock-free multi-coordination processing thread concurrent meter reading method based on double-ring queue Active CN113242059B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110643614.1A CN113242059B (en) 2021-06-09 2021-06-09 Lock-free multi-coordination processing thread concurrent meter reading method based on double-ring queue

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110643614.1A CN113242059B (en) 2021-06-09 2021-06-09 Lock-free multi-coordination processing thread concurrent meter reading method based on double-ring queue

Publications (2)

Publication Number Publication Date
CN113242059A CN113242059A (en) 2021-08-10
CN113242059B true CN113242059B (en) 2022-04-12

Family

ID=77137452

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110643614.1A Active CN113242059B (en) 2021-06-09 2021-06-09 Lock-free multi-coordination processing thread concurrent meter reading method based on double-ring queue

Country Status (1)

Country Link
CN (1) CN113242059B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115134389B (en) * 2022-09-02 2022-12-27 施维智能计量系统服务(长沙)有限公司 Parallel meter reading method, device, equipment and computer readable storage medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN202353563U (en) * 2011-12-02 2012-07-25 李明 Intelligent power-distributing network optical fiber double-loop self-healing communication and measurement system
CN104035884A (en) * 2014-06-30 2014-09-10 河南百旺金赋电脑有限公司 Double-annular-array data storage method and intelligent gateway
CN104318750A (en) * 2014-10-20 2015-01-28 华为技术有限公司 Meter reading method, device and system
CN108880619A (en) * 2018-07-26 2018-11-23 航天亮丽电气有限责任公司 A kind of automatic meter reading method using bandwidth carrier communication module
CN109769016A (en) * 2018-12-26 2019-05-17 重庆世纪之光科技实业有限公司 A kind of the Multi-task Concurrency meter register method and device, system of intelligent meter data recording system
CN110853317A (en) * 2018-12-11 2020-02-28 沈畅 Remote meter reading method and system
CN111786941A (en) * 2019-10-17 2020-10-16 南方电网数字电网研究院有限公司 Automatic identification method and communication method for communication protocol
CN112614331A (en) * 2020-12-14 2021-04-06 杭州海兴电力科技股份有限公司 Method for reading electric energy meter event and electric energy meter event reading system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20080017017A (en) * 2005-04-26 2008-02-25 세미테크 이노베이션스 피티와이 엘티디. Communications method and device

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN202353563U (en) * 2011-12-02 2012-07-25 李明 Intelligent power-distributing network optical fiber double-loop self-healing communication and measurement system
CN104035884A (en) * 2014-06-30 2014-09-10 河南百旺金赋电脑有限公司 Double-annular-array data storage method and intelligent gateway
CN104318750A (en) * 2014-10-20 2015-01-28 华为技术有限公司 Meter reading method, device and system
CN108880619A (en) * 2018-07-26 2018-11-23 航天亮丽电气有限责任公司 A kind of automatic meter reading method using bandwidth carrier communication module
CN110853317A (en) * 2018-12-11 2020-02-28 沈畅 Remote meter reading method and system
CN109769016A (en) * 2018-12-26 2019-05-17 重庆世纪之光科技实业有限公司 A kind of the Multi-task Concurrency meter register method and device, system of intelligent meter data recording system
CN111786941A (en) * 2019-10-17 2020-10-16 南方电网数字电网研究院有限公司 Automatic identification method and communication method for communication protocol
CN112614331A (en) * 2020-12-14 2021-04-06 杭州海兴电力科技股份有限公司 Method for reading electric energy meter event and electric energy meter event reading system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
智能化配电网管理系统通信模式的研究;樊剑辉;《电力系统通信》;20091110(第11期);全文 *

Also Published As

Publication number Publication date
CN113242059A (en) 2021-08-10

Similar Documents

Publication Publication Date Title
Sun et al. Age of information: A new metric for information freshness
CN102087132B (en) Wireless communication processing method for water meter
CN109327323B (en) New energy grid-connected power communication network planning and optimizing method and system
CN102548038A (en) Micro-power wireless networking method
CN113242059B (en) Lock-free multi-coordination processing thread concurrent meter reading method based on double-ring queue
CN105208622B (en) A kind of route selection method and method for managing route table of the router-table structure that high-efficiency dynamic is safeguarded automatically
CN109039382B (en) Electric energy meter reading method and device
CN102811221B (en) Push mechanism-based scheduling method of peer-to-peer network live streaming media data package
US20200373761A1 (en) Photovoltaic power optimization system
CN103326925A (en) Message push method and device
CN109215326A (en) A kind of parallel meter register method and device
CN103326916B (en) Intelligent substation automatically divides and optimizes the system and method for VLAN
CN114154685A (en) Electric energy data scheduling method in smart power grid
CN103139865A (en) Method of networking and communicating in electric power internet of things
CN110086870A (en) The parallel method for reliable transmission of the multipath of data-oriented central site network
CN106056889A (en) Meter reading communication interface self-learning method of four-meter centralized collecting interface converter
CN104967123B (en) Under power distribution network, intermittent energy source is dissolved monitoring device and its monitoring method
CN114979829B (en) Low-power consumption meter reading method for dividing CSMA time slot
CN106067866A (en) A kind of rate long-range delivery method of electricity price based on power information acquisition system
CN115021399A (en) Topology identification method and device adaptive to park multi-energy power supply network
CN104065735A (en) Scheduling information data storage sharing method
Feng et al. Large file transmission using self-adaptive data fragmentation in opportunistic networks
CN106034347A (en) Wireless communication management method and device
Wu et al. Scheduling mechanism of FC-AE-1553 network based on credit ranking
Shi et al. Research on Information Convergence Processing and Transmission Method for Virtual Power Plant

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