CN104156261A - Method and device for processing tasks among multiple controllers - Google Patents

Method and device for processing tasks among multiple controllers Download PDF

Info

Publication number
CN104156261A
CN104156261A CN201410392321.0A CN201410392321A CN104156261A CN 104156261 A CN104156261 A CN 104156261A CN 201410392321 A CN201410392321 A CN 201410392321A CN 104156261 A CN104156261 A CN 104156261A
Authority
CN
China
Prior art keywords
thread
task
task order
order message
dispatch
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201410392321.0A
Other languages
Chinese (zh)
Inventor
李美欣
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur Beijing Electronic Information Industry Co Ltd
Original Assignee
Inspur Beijing Electronic Information Industry 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 Inspur Beijing Electronic Information Industry Co Ltd filed Critical Inspur Beijing Electronic Information Industry Co Ltd
Priority to CN201410392321.0A priority Critical patent/CN104156261A/en
Publication of CN104156261A publication Critical patent/CN104156261A/en
Pending legal-status Critical Current

Links

Landscapes

  • Programmable Controllers (AREA)

Abstract

The invention provides a method and device for processing tasks among multiple controllers. The method includes the steps of receiving task command information sent by other controllers with distributed threads, wherein the controllers comprise the distributed threads and thread pools, each thread pool comprises at least one working thread, and task command information queues are included between the distributed threads and the thread pools; setting the initial state of the working threads into the sleeping state through the adoption of conditional variables; adding the received task command information into the task command information queues with the distributed threads, and awakening the working threads with the adoption of the conditional variables; fetching a task command from the task command information queues with the working threads for task processing, wherein the working threads are switched to be in the sleeping state when the task command information queues are empty. By means of the method and device, contradictions between rapid task command communication and slow task processing can be eliminated, and performance of the device can be improved.

Description

The method and apparatus of task processing between multi-controller
Technical field
The present invention relates to field of computer technology, relate in particular to the method and apparatus of task processing between a kind of multi-controller.
Background technology
Equipment middle controller opertaing device parts normally move, for example, equipment has single controller or multi-controller controls the operation of this equipment, and wherein single controller is commonly referred to as centralized device or integrated system, and multi-controller is commonly referred to as distributed apparatus or distributed system.Along with the raising of computer industry to reliability control system requirement, distributed multi-control system is issued to multiple controllers the control of equipment, this control mode is built flexibly, and reliability that can lifting means, therefore, distributed multi controller systems is set up the competitive position of nucleus equipment gradually.
Between multi-controller, collaborative task processing is indispensable in distributed multi-control system, but be very consuming time compared with the communication of the processing speed of task and task order between controller, issue a task order to another controller from a controller, this communication process is very fast, relatively slow and mostly receive after task order that controller finishes dealing with task according to task order in situation, therefore, the contradiction of task order communication fast between processing with task at a slow speed can cause and between controller, cooperate slowly, and then affects the performance of equipment.
Summary of the invention
In order to solve the problems of the technologies described above, the invention provides the method and apparatus of task processing between a kind of multi-controller, can solve the contradiction of task order communication fast and task processing at a slow speed between multi-controller, improve the performance of equipment.
In order to reach the object of the invention, the invention provides the method for task processing between a kind of multi-controller, comprise: the dispatch thread of controller receives the task order message that other controllers send, its middle controller comprises dispatch thread and thread pool, thread pool comprises at least one worker thread, comprises task order message queue between dispatch thread and thread pool; The initial state of worker thread utilizes conditional-variable to be arranged to sleep state; Dispatch thread is added the task order message receiving in task order message queue to, and utilizes conditional-variable to wake worker thread up; Worker thread takes out task order from task order message queue and carries out task processing, and in the time that task order message queue is sky, worker thread is switched to sleep state.
Further, the method also comprises: controller sets in advance dispatch thread and thread pool; According to the duration of worker thread Processing tasks in the frequency of dispatch thread reception task order and thread pool, the quantity of worker thread in thread pool is set.
Further, the method also comprises: controller arranges sharable task order message queue in advance between dispatch thread and thread pool, and described task order message queue adopts chained list mode, the first in first out of task order message; Dispatch thread is added the task order message receiving in task order message queue to, comprising: dispatch thread is added the task order message receiving to the afterbody of task order message queue successively; Worker thread takes out task order from task order message queue and carries out task processing, comprising: worker thread takes out task order from the head of task order message queue successively and carries out task processing.
Further, the initial state of worker thread utilizes conditional-variable to be arranged to sleep state, comprising: the initial state of worker thread is called pthread_cond_wait message and is arranged to sleep state.
Further, dispatch thread utilizes conditional-variable to wake worker thread up, comprising: dispatch thread adopts broadcast mode, calls pthread_cond_signal message and wakes all working thread in thread pool up.
The device that the invention provides task processing between a kind of multi-controller, comprising: dispatch thread, the task order message of sending for receiving other controllers; Thread pool, comprises at least one worker thread, makes thread for task processing; Task order message queue, between dispatch thread and thread pool, for the transmission of task order message; The initial state of worker thread utilizes conditional-variable to be arranged to sleep state; Dispatch thread is added the task order message receiving in task order message queue to, and utilizes conditional-variable to wake worker thread up; Worker thread takes out task order from task order message queue and carries out task processing, and in the time that task order message queue is sky, worker thread is switched to sleep state.
Further, this device also comprises: first arranges module, for setting in advance dispatch thread and thread pool; First arranges module also for receiving the frequency of task order and the duration of worker thread Processing tasks according to dispatch thread, and the quantity of worker thread in thread pool is set.
Further, this device also comprises: second arranges module, and for task order message queue is set in advance between dispatch thread and thread pool, task order message queue adopts chained list mode, the first in first out of task order message; Dispatch thread is added the task order message receiving to the afterbody of task order message queue successively, and worker thread takes out task order from the head of task order message queue successively and carries out task processing.
Further, the initial state of worker thread utilizes conditional-variable to be arranged to sleep state, comprising: the initial state of worker thread is called pthread_cond_wait message and is arranged to sleep state.
Further, dispatch thread utilizes conditional-variable to wake worker thread up, comprising: dispatch thread adopts broadcast mode, calls pthread_cond_signal message and wakes all working thread in thread pool up.
Compared with prior art, the present invention includes: the dispatch thread of controller receives the task order message that other controllers send, controller comprises dispatch thread and thread pool, and thread pool comprises at least one worker thread, comprises task order message queue between dispatch thread and thread pool; The initial state of worker thread utilizes conditional-variable to be arranged to sleep state; Dispatch thread is added the task order message receiving in task order message queue to, and utilizes conditional-variable to wake worker thread up; Worker thread takes out task order from task order message queue and carries out task processing, and in the time that task order message queue is sky, worker thread is switched to sleep state.The present invention is by dispatch thread and thread pool are set, and is separated into different threads by receiving task order and Processing tasks, thereby solves the contradiction of task order communication fast and task processing at a slow speed between multi-controller.In addition, between dispatch thread and thread pool, set up sharable task order message queue, if dispatch thread receives the task order from other controllers, task order can be joined in task order message queue, the worker thread of thread pool takes out task order and carries out task processing from task order message queue, therefore, dispatch thread can be processed the task order receiving in time, make the task order communication between controller become bottleneck and can not grow because of the worker thread task processing time, thereby improve the performance of equipment.
Brief description of the drawings
Fig. 1 is the schematic flow sheet of the method for task processing between multi-controller of the present invention.
Fig. 2 is the structural representation of the device of task processing between multi-controller of the present invention.
Embodiment
Describe the present invention below with reference to embodiment shown in the drawings.
Fig. 1 is the schematic flow sheet of the method for task processing between multi-controller, and as shown in Figure 1, the method comprises:
Step 11, arranges dispatch thread and thread pool, and this thread pool comprises at least one worker thread;
In this step, with respect to receiving task order, Processing tasks is consuming time longer, so controller is separated into different threads by receiving task order and Processing tasks, concrete, controller arranges dispatch thread and thread pool, and wherein dispatch thread receives the task order from other controllers, and task order is distributed; Worker thread Processing tasks in thread pool.
Controller can receive the frequency of task order and the duration of worker thread Processing tasks according to dispatch thread, the quantity of worker thread in thread pool is set, for example, 1 Command Task of dispatch thread reception per second, worker thread is processed 1 task needs 10 seconds, and 10~15 worker threads can be set in thread pool so.
Step 12 arranges task order message queue between dispatch thread and thread pool.
In this step, controller is set up sharable task order message queue in advance between dispatch thread and thread pool, and this task order message queue adopts chained list mode, the first in first out of task order message.
Step 13, the initial state of worker thread utilizes conditional-variable to be arranged to sleep state.
In this step, the initial state of worker thread is called pthread_cond_wait message and is arranged to sleep state
Step 14, dispatch thread receives the task order message that other controllers send, and the task order message receiving is added in task order message queue, and utilize conditional-variable to wake worker thread up.
In this step, dispatch thread receives the task order message that other controllers send, and the task order message receiving is added successively to the afterbody of task order message queue.
Dispatch thread adopts broadcast mode, calls pthread_cond_signal message and wakes all working thread in thread pool up.
Step 15, worker thread takes out task order from task order message queue and carries out task processing, and in the time that task order message queue is sky, worker thread is switched to sleep state.
In this step, worker thread takes out task order from the head of task order message queue successively and carries out task processing, until worker thread is while finding need to process without task order on task order message queue, worker thread is switched to sleep state, is distributed thread wakening the next time of always sleeping.
The present invention is by dispatch thread and thread pool are set, and is separated into different threads by receiving task order and Processing tasks, thereby solves the contradiction of task order communication fast and task processing at a slow speed between multi-controller.In addition, between dispatch thread and thread pool, set up sharable task order message queue, if dispatch thread receives the task order from other controllers, task order can be joined in task order message queue, the worker thread of thread pool takes out task order and carries out task processing from task order message queue, therefore, dispatch thread can be processed the task order receiving in time, make the task order communication between controller become bottleneck and can not grow because of the worker thread task processing time, thereby improve the performance of equipment.
Fig. 2 is the structural representation of the device of task processing between multi-controller of the present invention, as shown in Figure 2, comprising:
First arranges module, and for dispatch thread and thread pool are set, this thread pool comprises the worker thread of at least one Processing tasks.
Particularly, first arranges module can receive the frequency of task order and the duration of worker thread Processing tasks according to dispatch thread, and the quantity of worker thread in thread pool is set.
Second arranges module, for task order message queue is set between dispatch thread and thread pool.
Particularly, set up in advance sharable task order message queue between dispatch thread and thread pool, this task order message queue adopts chained list mode, the first in first out of task order message.
Dispatch thread, the task order message of sending for receiving other controllers;
Thread pool, comprises at least one worker thread, and described worker thread is for task processing;
Task order message queue, between dispatch thread and thread pool, for the transmission of task order message;
Wherein, the initial state of worker thread is called pthread_cond_wait message and is arranged to sleep state; Dispatch thread is added the task order message receiving to the afterbody of task order message queue successively, and adopts broadcast mode, calls pthread_cond_signal message and wakes all working thread in thread pool up; Worker thread takes out task order from the head of task order message queue successively and carries out task processing, until worker thread is while finding need to process without task order on task order message queue, worker thread is switched to sleep state, is distributed thread wakening the next time of always sleeping.
The present invention is by dispatch thread and thread pool are set, and is separated into different threads by receiving task order and Processing tasks, thereby solves the contradiction of task order communication fast and task processing at a slow speed between multi-controller.In addition, between dispatch thread and thread pool, set up sharable task order message queue, if dispatch thread receives the task order from other controllers, task order can be joined in task order message queue, the worker thread of thread pool takes out task order and carries out task processing from task order message queue, therefore, dispatch thread can be processed the task order receiving in time, make the task order message communicating between controller become bottleneck and can not grow because of the worker thread task processing time, thereby improve the performance of equipment.
Be to be understood that, although this instructions is described according to embodiment, but be not that each embodiment only comprises an independently technical scheme, this narrating mode of instructions is only for clarity sake, those skilled in the art should make instructions as a whole, technical scheme in each embodiment also can, through appropriately combined, form other embodiments that it will be appreciated by those skilled in the art that.
Listed a series of detailed description is above only illustrating for feasibility embodiment of the present invention; they are not for limiting the scope of the invention, all do not depart from the equivalent embodiment that skill spirit of the present invention does or change and all should be included in protection scope of the present invention within.

Claims (10)

1. a method for task processing between multi-controller, is characterized in that, comprising:
The dispatch thread of controller receives the task order message that other controllers send, described controller comprises dispatch thread and thread pool, described thread pool comprises at least one worker thread, and the initial state of described worker thread utilizes conditional-variable to be arranged to sleep state; Between described dispatch thread and thread pool, comprise task order message queue;
Described dispatch thread is added the task order message receiving in task order message queue to, and utilizes conditional-variable to wake worker thread up;
Described worker thread takes out task order from task order message queue and carries out task processing, and in the time that task order message queue is sky, worker thread is switched to sleep state.
2. the method for task processing between multi-controller according to claim 1, is characterized in that, the method also comprises:
Controller sets in advance dispatch thread and thread pool;
According to the duration of worker thread Processing tasks in the frequency of dispatch thread reception task order and thread pool, the quantity of worker thread in thread pool is set.
3. the method for task processing between multi-controller according to claim 1, is characterized in that, the method also comprises:
Controller arranges sharable task order message queue in advance between dispatch thread and thread pool, and described task order message queue adopts chained list mode, the first in first out of task order message;
Described dispatch thread is added the task order message receiving in task order message queue to, comprising: described dispatch thread is added the task order message receiving to the afterbody of task order message queue successively;
Described worker thread takes out task order from task order message queue and carries out task processing, comprising: described worker thread takes out task order from the head of task order message queue successively and carries out task processing.
4. the method for task processing between multi-controller according to claim 1, is characterized in that, the initial state of described worker thread utilizes conditional-variable to be arranged to sleep state, comprising:
The initial state of described worker thread is called pthread_cond_wait message and is arranged to sleep state.
5. according to the method for task processing between the multi-controller described in claim 1 or 4, it is characterized in that, described dispatch thread utilizes conditional-variable to wake worker thread up, comprising:
Described dispatch thread adopts broadcast mode, calls pthread_cond_signal message and wakes all working thread in thread pool up.
6. a device for task processing between multi-controller, is characterized in that, comprising:
Dispatch thread, the task order message of sending for receiving other controllers;
Thread pool, comprises at least one worker thread, and described worker thread is for task processing;
Task order message queue, between dispatch thread and thread pool, for the transmission of task order message;
The initial state of described worker thread utilizes conditional-variable to be arranged to sleep state; Described dispatch thread is added the task order message receiving in task order message queue to, and utilizes conditional-variable to wake worker thread up; Described worker thread takes out task order from task order message queue and carries out task processing, and in the time that task order message queue is sky, worker thread is switched to sleep state.
7. the device of task processing between multi-controller according to claim 6, is characterized in that, this device also comprises:
First arranges module, for setting in advance dispatch thread and thread pool;
First arranges module also for receiving the frequency of task order and the duration of worker thread Processing tasks according to dispatch thread, and the quantity of worker thread in thread pool is set.
8. the device of task processing between multi-controller according to claim 6, is characterized in that, this device also comprises:
Second arranges module, and for task order message queue is set between dispatch thread and thread pool, described task order message queue adopts chained list mode, the first in first out of task order message;
Described dispatch thread is added the task order message receiving to the afterbody of task order message queue successively, and described worker thread takes out task order from the head of task order message queue successively and carries out task processing.
9. the device of task processing between multi-controller according to claim 6, is characterized in that, the initial state of described worker thread utilizes conditional-variable to be arranged to sleep state, comprising:
The initial state of described worker thread is called pthread_cond_wait message and is arranged to sleep state.
10. according to the device of task processing between the multi-controller described in claim 6 or 9, it is characterized in that, described dispatch thread utilizes conditional-variable to wake worker thread up, comprising:
Described dispatch thread adopts broadcast mode, calls pthread_cond_signal message and wakes all working thread in thread pool up.
CN201410392321.0A 2014-08-11 2014-08-11 Method and device for processing tasks among multiple controllers Pending CN104156261A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410392321.0A CN104156261A (en) 2014-08-11 2014-08-11 Method and device for processing tasks among multiple controllers

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410392321.0A CN104156261A (en) 2014-08-11 2014-08-11 Method and device for processing tasks among multiple controllers

Publications (1)

Publication Number Publication Date
CN104156261A true CN104156261A (en) 2014-11-19

Family

ID=51881767

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410392321.0A Pending CN104156261A (en) 2014-08-11 2014-08-11 Method and device for processing tasks among multiple controllers

Country Status (1)

Country Link
CN (1) CN104156261A (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105700949A (en) * 2014-11-24 2016-06-22 中兴通讯股份有限公司 Data processing method and device based on multi-core processor
CN105868030A (en) * 2015-12-22 2016-08-17 乐视移动智能信息技术(北京)有限公司 Log data communication processing apparatus and method as well as mobile terminal
CN106933681A (en) * 2017-02-05 2017-07-07 深圳怡化电脑股份有限公司 A kind of many object blocking methods and its system
CN108595282A (en) * 2018-05-02 2018-09-28 广州市巨硅信息科技有限公司 A kind of implementation method of high concurrent message queue
CN109189483A (en) * 2018-08-02 2019-01-11 优视科技新加坡有限公司 Regulation method, apparatus, equipment/terminal/server and the storage medium of task execution
CN112685100A (en) * 2020-12-31 2021-04-20 深圳市大富网络技术有限公司 Thread starting method, system and device
US11048568B2 (en) 2017-03-10 2021-06-29 Guangdong Oppo Mobile Telecommunications Corp., Ltd. Broadcast sending control method and apparatus, storage medium, and electronic device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060136930A1 (en) * 2000-11-21 2006-06-22 Microsoft Corporation Generic application server and method of operation therefor
CN101593125A (en) * 2009-07-02 2009-12-02 上海交通大学 Use the method for monitoring thread to the execution flow of binary internal translator dynamic monitoring
CN102207890A (en) * 2011-05-27 2011-10-05 苏州阔地网络科技有限公司 Task information processing method and scheduling control processing device
CN102360310A (en) * 2011-09-28 2012-02-22 中国电子科技集团公司第二十八研究所 Multitask process monitoring method and system in distributed system environment
US8161163B2 (en) * 2000-12-28 2012-04-17 Microsoft Corporation Stateless distributed computer architecture with server-oriented state-caching objects maintained on network or client

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060136930A1 (en) * 2000-11-21 2006-06-22 Microsoft Corporation Generic application server and method of operation therefor
US8161163B2 (en) * 2000-12-28 2012-04-17 Microsoft Corporation Stateless distributed computer architecture with server-oriented state-caching objects maintained on network or client
CN101593125A (en) * 2009-07-02 2009-12-02 上海交通大学 Use the method for monitoring thread to the execution flow of binary internal translator dynamic monitoring
CN102207890A (en) * 2011-05-27 2011-10-05 苏州阔地网络科技有限公司 Task information processing method and scheduling control processing device
CN102360310A (en) * 2011-09-28 2012-02-22 中国电子科技集团公司第二十八研究所 Multitask process monitoring method and system in distributed system environment

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105700949A (en) * 2014-11-24 2016-06-22 中兴通讯股份有限公司 Data processing method and device based on multi-core processor
CN105868030A (en) * 2015-12-22 2016-08-17 乐视移动智能信息技术(北京)有限公司 Log data communication processing apparatus and method as well as mobile terminal
CN106933681A (en) * 2017-02-05 2017-07-07 深圳怡化电脑股份有限公司 A kind of many object blocking methods and its system
CN106933681B (en) * 2017-02-05 2019-10-11 深圳怡化电脑股份有限公司 It is a kind of multipair as blocking method and its system
US11048568B2 (en) 2017-03-10 2021-06-29 Guangdong Oppo Mobile Telecommunications Corp., Ltd. Broadcast sending control method and apparatus, storage medium, and electronic device
CN108595282A (en) * 2018-05-02 2018-09-28 广州市巨硅信息科技有限公司 A kind of implementation method of high concurrent message queue
CN109189483A (en) * 2018-08-02 2019-01-11 优视科技新加坡有限公司 Regulation method, apparatus, equipment/terminal/server and the storage medium of task execution
WO2020026010A3 (en) * 2018-08-02 2020-03-05 优视科技新加坡有限公司 Task execution control method, device, equipment/terminal/server and storage medium
CN112685100A (en) * 2020-12-31 2021-04-20 深圳市大富网络技术有限公司 Thread starting method, system and device

Similar Documents

Publication Publication Date Title
CN104156261A (en) Method and device for processing tasks among multiple controllers
US9170832B2 (en) Virtual machine control apparatus and virtual machine control method
US10139799B2 (en) Controller to modify an execution condition during program execution
CN103870952A (en) Dynamic priority scheduling method and device for logistics system, and logistics system
CN105589757A (en) Method for protecting working process in server framework and server
US10735520B2 (en) Control device, control system, control method, and non-transitory computer-readable storage medium
JP2018180705A (en) Abnormality detecting system, semiconductor device manufacturing system, and manufacturing method
US20140188253A1 (en) Method and system for reprogramming
CN103391210A (en) ID distribution system and method of CAN bus network
US10019292B2 (en) Method for executing a comprehensive real-time computer application by exchanging time-triggered messages among real-time software components
US10659536B2 (en) Method of controlling inverters
CN107396428B (en) Frequency switching method and device
CN102426546A (en) Multiwindow concurrent display method
US20200192565A1 (en) Fusion method and terminal for touch messages and computer-readable storage medium
CN205353629U (en) Unmanned aerial vehicle uses novel remote controller
US10054926B2 (en) Programmable controller and control method of programmable controller
CN103777618B (en) Method and device for controlling instruction execution of semiconductor technology
US20160124488A1 (en) Controlling power states of a device
CN111919180B (en) Conveyor system controller, conveyor system and data synchronization method
CN103439882A (en) Method and device for adjusting parameters of controller
CN112333679B (en) Bluetooth automatic connection method, system, equipment and computer readable storage medium
EP2207070A1 (en) Field control device and field control method
KR20160022722A (en) Synchronization device and synchronization method of cooperation robot
CN114546926A (en) Core cluster synchronization, control method, data processing method, core, device, and medium
CN105673542A (en) Method and device for regulating and controlling rotation speed of fans in multi-control server system

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20141119

RJ01 Rejection of invention patent application after publication