CN108509257A - A kind of message treatment method and device based on multithreading - Google Patents

A kind of message treatment method and device based on multithreading Download PDF

Info

Publication number
CN108509257A
CN108509257A CN201710112550.6A CN201710112550A CN108509257A CN 108509257 A CN108509257 A CN 108509257A CN 201710112550 A CN201710112550 A CN 201710112550A CN 108509257 A CN108509257 A CN 108509257A
Authority
CN
China
Prior art keywords
thread
message
queues
safe queues
handling result
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201710112550.6A
Other languages
Chinese (zh)
Other versions
CN108509257B (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.)
Suning Commerce Group Co Ltd
Original Assignee
Suning Commerce Group 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 Suning Commerce Group Co Ltd filed Critical Suning Commerce Group Co Ltd
Priority to CN201710112550.6A priority Critical patent/CN108509257B/en
Publication of CN108509257A publication Critical patent/CN108509257A/en
Application granted granted Critical
Publication of CN108509257B publication Critical patent/CN108509257B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/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
    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/08Logistics, e.g. warehousing, loading or distribution; Inventory or stock management
    • G06Q10/087Inventory or stock management, e.g. order filling, procurement or balancing against orders

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Economics (AREA)
  • General Engineering & Computer Science (AREA)
  • Marketing (AREA)
  • Development Economics (AREA)
  • Finance (AREA)
  • Entrepreneurship & Innovation (AREA)
  • Human Resources & Organizations (AREA)
  • Accounting & Taxation (AREA)
  • Operations Research (AREA)
  • Quality & Reliability (AREA)
  • Strategic Management (AREA)
  • Tourism & Hospitality (AREA)
  • General Business, Economics & Management (AREA)
  • Computer And Data Communications (AREA)

Abstract

The embodiment of the invention discloses a kind of message treatment method and device based on multithreading is related to digitizing logistlcs technology field, can alleviate the problem of being caused in the prior art due to cross-thread communication.The present invention includes:The message that embedded system is sent is received, according to the analysis result to the message, generates message, wherein the message generated corresponds to pending affairs, and the pending affairs of step include at least one step;Thread safe queues are added in the message generated, wherein the thread safe queues include the data public visit area of specified size, for the data in thread safe queues described in each thread accesses;Message is extracted from the thread safe queues, and the thread that current idle is added is handled, wherein a thread is for handling the step that the pending office of the step includes;Obtained handling result is sent to the embedded system.The present invention is suitable for the Message Processing of the high concurrent for embedded system.

Description

A kind of message treatment method and device based on multithreading
Technical field
The present invention relates to digitlization logistlcs technology field more particularly to a kind of message treatment methods and dress based on multithreading It sets.
Background technology
Currently, in the digital management of logistics warehouse, system, message management system are all distributed using task automatically substantially Equal digital management systems distribute the operations such as restocking, undercarriage, sorting, packing and sorting for warehouseman, it is therefore intended that The details of operation of each employee is included in digital management, to improve the efficiency of management of logistics warehouse.
Also, as the gradually foundation of large-scale logistics warehouse and the degree of automation are higher and higher, used number It is in explosive growth to change the required task amount for handling, distributing of management system, this just needs to improve the parallel of digital management system Handle the ability of multiple tasks.In the scheme of currently used parallel processing multiple tasks, generally by either synchronously or asynchronously grasping The mode of work transmits message, and since the timeliness of each task processing needs preferential guarantee, it is distributed for each task more A thread, to improve the treatment effeciency of each task, and as task amount gradually increases, to increase digital management system Parallel processing capability, then need to increase more CPU and memory for the hardware device of system, in order to expand computing resource More processing threads are established, to increase the concurrency of task processing.
This just needs the hardware configuration level of raising system and the capacity of computing resource, that is, needs the operator of logistics warehouse More hardware devices are purchased, the construction of logistics warehouse, operation cost steeply rise;And when the hardware device scale of system expands After big, the communication of the cross-thread due to needing to manage magnanimity, instead resulted in task delay, exceeded the time limit, interrupt etc. it is abnormal take place frequently, times The timeliness of business processing will be difficult to ensure.Therefore the digital management ability of logistics warehouse receives certain limitation, logistics storehouse The scale in library is difficult to further expand.
Invention content
The embodiment of the present invention provides a kind of message treatment method and device based on multithreading, can alleviate the prior art In due to cross-thread communication cause the problem of.
In order to achieve the above objectives, the embodiment of the present invention adopts the following technical scheme that:
In a first aspect, the method that the embodiment of the present invention provides, including:
The message that embedded system is sent is received, according to the analysis result to the message, generates message, wherein give birth to At message correspond to pending affairs, the pending affairs of step include at least one step;
Thread safe queues are added in the message generated, wherein the thread safe queues include the number of specified size According to public visit area, for the data in thread safe queues described in each thread accesses;
Message is extracted from the thread safe queues, and the thread that current idle is added is handled, wherein a line Journey is for handling the step that the pending office of the step includes;
Obtained handling result is sent to the embedded system.
With reference to first aspect, in the first possible realization method of first aspect, the quantity of thread waits locating to be described The integral multiple of the step quantity of director's business, a step is by least one thread process.
The possible realization method of with reference to first aspect the first further includes in second of possible realization method:
Receive at least 2 message that the embedded system is concurrently sent;
Message, and the step of generated message will be corresponded to are generated for the message that each receives, is separately added into each The processing queue of thread.
The possible realization method of with reference to first aspect the first further includes in the third possible realization method:
Message is generated for the message that each receives, after a step is by thread process, by this step Handling result be stored in the thread safe queues.
With reference to first aspect or the third possible realization method of first aspect, in the 4th kind of possible realization method In, further include:
The message received for each generates message, if needing to read another when the one of step of thread process The handling result of step then inquires the handling result with the presence or absence of another step from the thread safe queues;
If then reading the handling result of another step from the thread safe queues.
With reference to first aspect or the 4th kind of possible realization method of first aspect, in the 5th kind of possible realization method In, further include:
If can not currently read the handling result of another step in the thread safe queues, described in processing The thread suspension of one of step, until successfully reading the processing knot of another step from the thread safe queues Fruit.
Second aspect, the device that the embodiment of the present invention provides, including:
Receiving module, the message for receiving embedded system transmission generate report according to the analysis result to the message Text, wherein the message generated corresponds to pending affairs, and the pending affairs of step include at least one step;
Queue module, for thread safe queues to be added in the message generated, wherein the thread safe queues include The data public visit area of specified size, for the data in thread safe queues described in each thread accesses;
Processing module for extracting message from the thread safe queues, and is added at the thread of current idle Reason a, wherein thread is for handling the step that the pending office of the step includes;
Sending module, for sending obtained handling result to the embedded system.
In conjunction with second aspect, in the first possible realization method of second aspect, the receiving module is specifically used for Receive at least 2 message that the embedded system is concurrently sent;
The processing module generates message specifically for the message received for each, and correspondence is generated report The step of text, is separately added into the processing queue of each thread;
Wherein, the quantity of thread is the integral multiple of the step quantity of the pending affairs, and a step is by least one Thread process.
In conjunction with second aspect, in second of possible realization method of second aspect, the processing module is additionally operable to needle Message is generated to the message that each receives, after a step is by thread process, by the handling result of this step It is stored in the thread safe queues.
In conjunction with the first possible realization method of second aspect, in the third possible realization method, the processing Module is additionally operable to
The message received for each generates message, if needing to read another when the one of step of thread process The handling result of step is then inquired by the Queue module from the thread safe queues with the presence or absence of another described step Rapid handling result;
If then reading the handling result of another step from the thread safe queues;If currently in the line The handling result that another step can not be read in Cheng Anquan queues, the then thread for handling one of step are hung It rises, until successfully reading the handling result of another step from the thread safe queues.
Message treatment method and device provided in an embodiment of the present invention based on multithreading, for possible step having the same Suddenly, the dependence but between step and possible different task, can be by the line in later step in dependence Journey inquires the implementing result for the thread for whether having previous step in thread safe queues.And the step of without dependence, can be with Directly execute.The present embodiment can be applied in terms of plc communication, transmit/receive what thread was distinguished with worker thread.By opening up public affairs Total memory headroom (thread safe queues) reduces cross-thread communication, improves the efficiency of Message Processing, also alleviate the prior art In due to cross-thread communication cause the problem of.
Description of the drawings
It to describe the technical solutions in the embodiments of the present invention more clearly, below will be to needed in the embodiment Attached drawing is briefly described, it should be apparent that, drawings in the following description are only some embodiments of the invention, for ability For the those of ordinary skill of domain, without creative efforts, it can also be obtained according to these attached drawings other attached Figure.
Fig. 1 is possible system architecture schematic diagram provided in an embodiment of the present invention;
Fig. 2 is the flow diagram of method provided in an embodiment of the present invention;
Fig. 3,4 for the data transmission procedure in possible specific example provided in an embodiment of the present invention schematic diagram;
Fig. 5 is the structural schematic diagram of device provided in an embodiment of the present invention.
Specific implementation mode
To make those skilled in the art more fully understand technical scheme of the present invention, below in conjunction with the accompanying drawings and specific embodiment party Present invention is further described in detail for formula.Embodiments of the present invention are described in more detail below, the embodiment is shown Example is shown in the accompanying drawings, and in which the same or similar labels are throughly indicated same or similar element or has identical or class Like the element of function.It is exemplary below with reference to the embodiment of attached drawing description, is only used for explaining the present invention, and cannot It is construed to limitation of the present invention.Those skilled in the art of the present technique are appreciated that unless expressly stated, odd number shape used herein Formula " one ", "one", " described " and "the" may also comprise plural form.It is to be further understood that the specification of the present invention The middle wording " comprising " used refers to that there are the feature, integer, step, operation, element and/or component, but it is not excluded that Other one or more features of presence or addition, integer, step, operation, element, component and/or their group.It should be understood that When we say that an element is " connected " or " coupled " to another element, it can be directly connected or coupled to other elements, or There may also be intermediary elements.In addition, " connection " used herein or " coupling " may include being wirelessly connected or coupling.Here make Wording "and/or" includes any cell of one or more associated list items and all combines.The art Technical staff is appreciated that unless otherwise defined all terms (including technical terms and scientific terms) used herein have Meaning identical with the general understanding of the those of ordinary skill in fields of the present invention.It should also be understood that such as general Term, which should be understood that, those of defined in dictionary has a meaning that is consistent with the meaning in the context of the prior art, and Unless being defined as here, will not be explained with the meaning of idealization or too formal.
Method flow in the present embodiment can specifically execute in a kind of system as shown in Figure 1, including:Clothes Business device, the embedded system that is connect with server, for example (Programmable Logic Controller, can compile PLC system Journey logic controller).
Wherein, in hardware view:Server can also specifically be embodied as a server apparatus, can also be by multiple A kind of server cluster system for data processing of server composition.And PLC system may be used currently used PLC and set It is standby to set up.
Thread described in the present embodiment specifically depends in the process for operating in server, such as:In server apparatus In, the minimum calculation unit run in operating system is thread, and the perfoming block of one individualism of a process on behalf, one Process may include multiple threads, and the number of threads included by a process can be expanded according to practical application scene, Such as:Thread operates in the wcs program process in server apparatus.
The embodiment of the present invention provides a kind of message treatment method based on multithreading, as shown in Fig. 2, including:
S1, the message that embedded system is sent is received, according to the analysis result to the message, generates message.
In the present embodiment, embedded system can be specifically PLC system as shown in Figure 1, what embedded system was sent Message can be specifically socket message, can be specifically to operate in clothes as shown in Figure 1 for executing the present embodiment flow WCS (Warehouse Control System, the warehouse control system) system being engaged on device is established by WCS systems with PLC's Sokcet connects and obtains the message of PLC system transmission, then by WCS system analysis message, generates message.Wherein, it is generated Message corresponds to pending affairs, and the pending affairs of step include at least one step.
S2, thread safe queues are added in the message generated.
Wherein, the thread safe queues include the data public visit area of specified size, are used for each thread accesses institute The data in thread safe queues are stated, and the data public visit area of specified size can be specifically server as shown in Figure 1 The partial memory space of equipment, in order to which the thread run on the server can directly read the thread-safe from memory Data in queue.
S3, message is extracted from the thread safe queues, and the thread that current idle is added is handled.
Wherein, a thread is for handling the step that the pending office of the step includes.Institute in the present embodiment The affairs stated may include:In storehouse management scene, warehouse entry, export, shifting storehouse for being undertaken in PLC system etc. are based on operation The affairs of instruction interaction, server can confirm that pending affairs are specifically any thing therein according to the message received Business.
Message described in the present embodiment can be specifically a kind of triggering message, start to execute for triggering a certain affairs; Alternatively, the message described in the present embodiment, includes data to be treated.And data to be treated are imported into corresponding thing It is handled in business, obtains the handling result for the data in message.
The step of described in the present embodiment, specifically can be understood as the links of the process flow of affairs, such as:It can be with Preset affairs are stored in the server, these preset affairs can be specifically the program write according to specific operation flow Code, each step for forming affairs actually appears one section of code segment, and is had recorded in code segment and need to execute the generation The cognizance code of the thread of code section, for extracting the code segment that thread carrys out operating procedure from thread according to cognizance code.Specifically , receiving thread can be configured and send thread, wherein receiving thread is used to parse received message, and determination is received The specific corresponding affairs of the message arrived.If the code segment for forming a step of affairs includes for triggering the generation for sending thread Implementing result is imported then after this step is finished and sends thread, and exported outward by sending thread by code.
In the present embodiment, the data in thread safe queues include:Pending affairs are corresponded to from the message generated In the step of middle marked off, some steps are by the intermediate result after corresponding thread process, these intermediate results, such as:Thing Business A needs worker thread 1,2,3, wherein thread 1,2,3 is respectively used to the step 1 of processing affairs A, 2,3.Thread 2 executes The result (wherein, the result of step 1 can be understood as " intermediate result ") of thread 1 is needed, then thread 2 can be hung when execution It rises and has handled until 1 corresponding data of thread, and thread 2 is after the intermediate result for reading thread 1 in thread safe queues, then according to It is executed according to the intermediate result of thread 1.
Wherein, the intermediate data transmitted is needed between storing step-step in thread safe queues, without thread Between the affairs that communicate, thread safe queues can not used in the process of implementation, such as:Step 1 is for triggering log recording The step of flow, step 2 is for triggering message forwarding process, it is likely that step 2, which first carries out, to be finished, and will by sending thread Message exports, and then etc. thread to be allocated executes step 1.
In the present embodiment, as shown in Figure 3, thread safe queues are added in message by WCS systems, and by each step quilt The intermediate result obtained after processing is stored to the static memory of server, to by thread safe queues, realize a thread Another thread is transferred to the handling result of a step.
S4, obtained handling result is sent to the embedded system.
In the present embodiment, for possible step having the same, but the dependence between step again may not phase Same task, can be by the thread in later step in dependence, and whether inquired in thread safe queues has back The implementing result of rapid thread.And the step of without dependence, can directly execute.The present embodiment can be applied in plc communication side Face transmits/receives what thread was distinguished with worker thread.By opening up public memory headroom (thread safe queues), cross-line is reduced Cheng Tongxin, improves the efficiency of Message Processing, also alleviates the problem of being caused in the prior art due to cross-thread communication.
In the present embodiment, the quantity of thread be the pending affairs step quantity integral multiple, a step by At least one thread process.For the parallel process of more message, include specifically:
Receive at least 2 message that the embedded system is concurrently sent.
Message, and the step of generated message will be corresponded to are generated for the message that each receives, is separately added into each The processing queue of thread.
Wherein, message is generated for the message that each receives:After a step is by thread process, by this The handling result of a step is stored in the thread safe queues.Such as:As shown in Figure 4, by the host process run in WCS systems Middle receiving thread obtains program request of data to be treated (can be described as affairs), each affairs is made of multiple steps, and It is not identical.By the way of the step that a worker thread is handled in affairs, the operating mode of similar assembly line. Worker thread sum is the integer of the step quantity of the sum or pending affairs of different step in all different affairs Times.To in each transaction process, according to the difference of step, queuing is handled in each worker thread.Later, thread from Message is obtained in safe queue, and handles message and result addition is waited for into feedback queue.Feedback thread is sent to obtain in transmit queue Message, be sent to the embedded systems such as p l c.A task is splitted into multiple threads to realize, a thread is only run The task step of one type so that multitask multithreading can be handled simultaneously.The case where especially for a large amount of, iterative task Under, it ensure that per thread has task to do, without being held again using after the medium previous task execution of existing scheme The processing mode of row next task.
Specifically, further including:The message received for each generates message, if when the one of step of thread process Need to read the handling result of another step, then from the thread safe queues inquiry with the presence or absence of another described step Handling result.
If then reading the handling result of another step from the thread safe queues.
If can not currently read the handling result of another step in the thread safe queues, described in processing The thread suspension of one of step, until successfully reading the processing knot of another step from the thread safe queues Fruit.
Wherein, thread suspension refers to:The passive saving scene of thread, partial memory are swapped out, do not access, passively open It opens, is similar to and interrupts, while the step of thread of hang-up can continue with next message.When from the thread safe queues After the handling result of another step is read in success, the step of thread is continued in suspended state.To each In a transaction process, according to the difference of step, queuing is handled in each worker thread, improves the utilization rate of worker thread, So that each worker thread is not the state in waiting so that affairs can quickly finish.Such as:In the present embodiment, each Actual data interaction and internal communication are not present between worker thread, wherein all data interactions all pass through thread safe queues Data in (referred to as queue) are realized, it can be understood as public data access area, such as:Affairs A needs worker thread 1,2,3, then after host process receives affairs A, while thread 1,2,3 is issued a command to, and place data into end in queue; Following thread 1,2,3 starts to execute respectively, as thread 2 execute need thread 1 as a result, meeting when so thread 2 executes It hangs up and handle until 1 corresponding data of thread, thread suspension rather than obstruction, so thread 2 can continue to execute other numbers According to processing, which improves the utilization rates of execution efficiency and cpu.
For concrete example:Foreground system is issued to warehouse background system there are one order, the commodity in order need from Certain bin level in the warehouse areas A sorts, and then needs to go to bagging area packing, finally to arrive end and sort vanning transport.We Order is as an affairs, and after message enters wcs systems, system is just respectively added to a line to sort, being packaged, sort thread Cheng Zuoye so that sorting has distributed packing working position while be operated in progress for it, and the thread being packaged in this way is just not Which which need just to know pack in station after cargo sorts and completes to reach bagging area, similarly in off-sorting station into luggage Case operates, and sometimes even can bring up which vehicle determined, the order of such a continuous productive process can reach after being decomposed It is carried out to synchronous, greatly improves efficiency.
In currently existing scheme, solves the problems, such as high concurrent and timely respond to, it is common practice to asynchronous multiple threads Or the mode of thread pool handles message, since operating system is to the limitation of thread-safe and thread process, such as:Between cross-thread Data access, can be waited for by thread is influenced, and so as to cause inter-thread access exception, cross-thread transmission message is inconsistent, nothing Method detects the problems such as Message Processing progress, the serious danger that process exception can be caused even to collapse.Cross-thread can be used on and The mode of communication, such thread occupies memory block always to be discharged, if the task of waiting is more, for high concurrent System requirements cpu that operating system can be caused instantaneous and EMS memory occupation it is very high, for long working system, there are poles High security risk.Such as:In the system using the prior art, the data processing between wcs systems is in certainly by each system Reason mechanism limitation (such as:The response time of moral agate wcs is generally in 500ms or so at present, once network oscillation occur will make The request timed out for obtaining moment, influences the operation exception of the next system).
And in the present embodiment, for possible step having the same, but the dependence between step again may not Identical task, can by dependence be in later step thread, inquired in thread safe queues whether have it is previous The implementing result of the thread of step.And the step of without dependence, can directly execute.The present embodiment can be applied in plc communication Aspect transmits/receives what thread was distinguished with worker thread.By opening up public memory headroom (thread safe queues), reduce across Thread communication, improves the efficiency of Message Processing, also alleviates the problem of being caused in the prior art due to cross-thread communication.Such as: By actual motion, the present embodiment can will run timeliness and be increased to the level of Millisecond so that automation equipment no longer by To the restriction of Inter-Process Communication so that the level of second grade can only be rested on by handling the timeliness of data between system.
The embodiment of the present invention provides a kind of message processing apparatus based on multithreading, may operate in clothes as shown in Figure 1 It is engaged on device, for example operates in WCS systems.As shown in figure 5, described device includes:
Receiving module, the message for receiving embedded system transmission generate report according to the analysis result to the message Text, wherein the message generated corresponds to pending affairs, and the pending affairs of step include at least one step;
Queue module, for thread safe queues to be added in the message generated, wherein the thread safe queues include The data public visit area of specified size, for the data in thread safe queues described in each thread accesses;
Processing module for extracting message from the thread safe queues, and is added at the thread of current idle Reason a, wherein thread is for handling the step that the pending office of the step includes;
Sending module, for sending obtained handling result to the embedded system.
Wherein, the receiving module, at least 2 message concurrently sent specifically for receiving the embedded system;
The processing module generates message specifically for the message received for each, and correspondence is generated report The step of text, is separately added into the processing queue of each thread;
Wherein, the quantity of thread is the integral multiple of the step quantity of the pending affairs, and a step is by least one Thread process.
Specifically, the processing module, the message for being additionally operable to receive for each generates message, and a step is by line After journey is disposed, the handling result of this step is stored in the thread safe queues.
Further, the processing module, the message for being additionally operable to receive for each generates message, if thread process Need to read the handling result of another step when one of step, then by the Queue module from the thread-safe team Handling result of the inquiry with the presence or absence of another step in row;
If then reading the handling result of another step from the thread safe queues;If currently in the line The handling result that another step can not be read in Cheng Anquan queues, the then thread for handling one of step are hung It rises, until successfully reading the handling result of another step from the thread safe queues.
In the present embodiment, for possible step having the same, but the dependence between step again may not phase Same task, can be by the thread in later step in dependence, and whether inquired in thread safe queues has back The implementing result of rapid thread.And the step of without dependence, can directly execute.The present embodiment can be applied in plc communication side Face transmits/receives what thread was distinguished with worker thread.By opening up public memory headroom (thread safe queues), cross-line is reduced Cheng Tongxin, improves the efficiency of Message Processing, also alleviates the problem of being caused in the prior art due to cross-thread communication.
Each embodiment in this specification is described in a progressive manner, identical similar portion between each embodiment Point just to refer each other, and each embodiment focuses on the differences from other embodiments.Especially for equipment reality For applying example, since it is substantially similar to the method embodiment, so describing fairly simple, related place is referring to embodiment of the method Part explanation.The above description is merely a specific embodiment, but protection scope of the present invention is not limited to This, any one skilled in the art in the technical scope disclosed by the present invention, the variation that can readily occur in or replaces It changes, should be covered by the protection scope of the present invention.Therefore, protection scope of the present invention should be with the protection model of claim Subject to enclosing.

Claims (10)

1. a kind of message treatment method based on multithreading, which is characterized in that including:
The message that embedded system is sent is received, according to the analysis result to the message, generates message, wherein generated Message corresponds to pending affairs, and the pending affairs of step include at least one step;
Thread safe queues are added in the message generated, wherein the thread safe queues include that the data of specified size are public Access region altogether, for the data in thread safe queues described in each thread accesses;
Message is extracted from the thread safe queues, and the thread that current idle is added is handled, wherein a thread is used In the step that the processing pending office of step includes;
Obtained handling result is sent to the embedded system.
2. according to the method described in claim 1, it is characterized in that, the quantity of thread is the step quantity of the pending affairs Integral multiple, a step is by least one thread process.
3. according to the method described in claim 2, it is characterized in that, further including:
Receive at least 2 message that the embedded system is concurrently sent;
Message, and the step of generated message will be corresponded to are generated for the message that each receives, is separately added into each thread Processing queue.
4. according to the method described in claim 2, it is characterized in that, further including:
Message is generated for the message that each receives, after a step is by thread process, by the place of this step It manages result and is stored in the thread safe queues.
5. according to the method described in claim 4, it is characterized in that, further including:
The message received for each generates message, if needing to read another step when the one of step of thread process Handling result, then handling result of the inquiry with the presence or absence of another step from the thread safe queues;
If then reading the handling result of another step from the thread safe queues.
6. according to the method described in claim 5, it is characterized in that, further including:
If can not currently read the handling result of another step in the thread safe queues, described in processing wherein The thread suspension of one step, until successfully reading the handling result of another step from the thread safe queues.
7. a kind of message processing apparatus based on multithreading, which is characterized in that including:
Receiving module, the message for receiving embedded system transmission generate message according to the analysis result to the message, Wherein, the message generated corresponds to pending affairs, and the pending affairs of step include at least one step;
Queue module, for thread safe queues to be added in the message generated, wherein the thread safe queues include specified The data public visit area of size, for the data in thread safe queues described in each thread accesses;
Processing module, for extracting message from the thread safe queues, and the thread that current idle is added is handled, In, a thread is for handling the step that the pending office of the step includes;
Sending module, for sending obtained handling result to the embedded system.
8. device according to claim 7, which is characterized in that the receiving module is specifically used for receiving described embedded At least 2 message that system concurrency is sent;
The processing module generates message specifically for the message received for each, and will correspond to generated message Step is separately added into the processing queue of each thread;
Wherein, the quantity of thread is the integral multiple of the step quantity of the pending affairs, and a step is by least one thread Processing.
9. device according to claim 7, which is characterized in that the processing module is additionally operable to receive for each Message generate message, after a step is by thread process, the handling result of this step is stored in the thread and is pacified Whole team arranges.
10. device according to claim 9, which is characterized in that the processing module is additionally operable to
The message received for each generates message, if needing to read another step when the one of step of thread process Handling result, then inquired from the thread safe queues by the Queue module with the presence or absence of another step Handling result;
If then reading the handling result of another step from the thread safe queues;If currently pacifying in the thread The handling result that another step can not be read in whole team's row, then handle the thread suspension of one of step, directly To the handling result for successfully reading another step from the thread safe queues.
CN201710112550.6A 2017-02-28 2017-02-28 Message processing method and device based on multithreading Active CN108509257B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710112550.6A CN108509257B (en) 2017-02-28 2017-02-28 Message processing method and device based on multithreading

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710112550.6A CN108509257B (en) 2017-02-28 2017-02-28 Message processing method and device based on multithreading

Publications (2)

Publication Number Publication Date
CN108509257A true CN108509257A (en) 2018-09-07
CN108509257B CN108509257B (en) 2022-07-22

Family

ID=63374198

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710112550.6A Active CN108509257B (en) 2017-02-28 2017-02-28 Message processing method and device based on multithreading

Country Status (1)

Country Link
CN (1) CN108509257B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109634532A (en) * 2018-12-19 2019-04-16 湖南源科创新科技有限公司 The method of more VxWorks host share and access storage mediums
CN112596478A (en) * 2020-12-08 2021-04-02 苏州高科中维软件科技有限公司 WCS warehouse control system architecture and implementation method
CN115695432A (en) * 2023-01-04 2023-02-03 河北华通科技股份有限公司 Load balancing method and device, electronic equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1658162A (en) * 2005-03-25 2005-08-24 上海高智软件系统有限公司 Method for raising processing speed of interface system of attaching position register
CN102508716A (en) * 2011-09-29 2012-06-20 用友软件股份有限公司 Task control device and task control method
CN102981904A (en) * 2011-09-02 2013-03-20 阿里巴巴集团控股有限公司 Task scheduling method and system
CN104133724A (en) * 2014-04-03 2014-11-05 腾讯科技(深圳)有限公司 Concurrent task scheduling method and concurrent task scheduling device
US8954986B2 (en) * 2010-12-17 2015-02-10 Intel Corporation Systems and methods for data-parallel processing
CN104793996A (en) * 2015-04-29 2015-07-22 中芯睿智(北京)微电子科技有限公司 Task scheduling method and device of parallel computing equipment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1658162A (en) * 2005-03-25 2005-08-24 上海高智软件系统有限公司 Method for raising processing speed of interface system of attaching position register
US8954986B2 (en) * 2010-12-17 2015-02-10 Intel Corporation Systems and methods for data-parallel processing
CN102981904A (en) * 2011-09-02 2013-03-20 阿里巴巴集团控股有限公司 Task scheduling method and system
CN102508716A (en) * 2011-09-29 2012-06-20 用友软件股份有限公司 Task control device and task control method
CN104133724A (en) * 2014-04-03 2014-11-05 腾讯科技(深圳)有限公司 Concurrent task scheduling method and concurrent task scheduling device
CN104793996A (en) * 2015-04-29 2015-07-22 中芯睿智(北京)微电子科技有限公司 Task scheduling method and device of parallel computing equipment

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109634532A (en) * 2018-12-19 2019-04-16 湖南源科创新科技有限公司 The method of more VxWorks host share and access storage mediums
CN112596478A (en) * 2020-12-08 2021-04-02 苏州高科中维软件科技有限公司 WCS warehouse control system architecture and implementation method
CN115695432A (en) * 2023-01-04 2023-02-03 河北华通科技股份有限公司 Load balancing method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN108509257B (en) 2022-07-22

Similar Documents

Publication Publication Date Title
WO2016130873A1 (en) Extending a programmable logic controller with apps
CN103930875A (en) Software virtual machine for acceleration of transactional data processing
CN107526645B (en) A kind of communication optimization method and system
US8112559B2 (en) Increasing available FIFO space to prevent messaging queue deadlocks in a DMA environment
CN108647083A (en) Task executing method, device, system, electronic equipment and computer-readable medium
Leung et al. Resolving deadlocks in flexible manufacturing cells
CN107943577A (en) Method and apparatus for scheduler task
CN108509257A (en) A kind of message treatment method and device based on multithreading
CN103942178A (en) Communication method between real-time operating system and non-real-time operating system on multi-core processor
CN102752387B (en) Data storage processing system and data storage handling method
CN102185860A (en) Standardized bottom layer control driving system for integrated circuit manufacturing equipment
EP3000030A2 (en) Methods and apparatus for iterative nonspecific distributed runtime architecture and its application to cloud intelligence
CN102081554A (en) Cloud computing operating system as well as kernel control system and method thereof
CN111124392A (en) Method for improving high concurrency capability of Internet of things platform rule engine
CN110611707A (en) Task scheduling method and device
CN103412790A (en) Method and system for multicore concurrent scheduling of mobile safety middleware
CN108664520A (en) Safeguard method, apparatus, electronic equipment and the readable storage medium storing program for executing of data consistency
CN109144749A (en) A method of it is communicated between realizing multiprocessor using processor
CN104050193A (en) Message generating method and data processing system for realizing method
CN107528871A (en) Data analysis in storage system
CN109710679A (en) Data pick-up method and device
CN113364857A (en) Service data processing method and device and server
CN112541709A (en) Intelligent warehouse management and allocation system and management and allocation method thereof
CN110764472B (en) Workshop real-time scheduling method and device based on composite agent
CN110412947B (en) Industrial equipment control method and system and storage equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 210000, 1-5 story, Jinshan building, 8 Shanxi Road, Nanjing, Jiangsu.

Applicant after: SUNING.COM Co.,Ltd.

Address before: 210042 Suning Headquarters, No. 1 Suning Avenue, Xuanwu District, Nanjing City, Jiangsu Province

Applicant before: SUNING COMMERCE GROUP Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant