[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN105930219B - A custom communication method for multi-threaded management - Google Patents

A custom communication method for multi-threaded management Download PDF

Info

Publication number
CN105930219B
CN105930219B CN201610261157.9A CN201610261157A CN105930219B CN 105930219 B CN105930219 B CN 105930219B CN 201610261157 A CN201610261157 A CN 201610261157A CN 105930219 B CN105930219 B CN 105930219B
Authority
CN
China
Prior art keywords
thread
value
parameter
father
uplink
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
CN201610261157.9A
Other languages
Chinese (zh)
Other versions
CN105930219A (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.)
Hangzhou Markov Technology Co ltd
Original Assignee
Zhejiang University of Technology ZJUT
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 Zhejiang University of Technology ZJUT filed Critical Zhejiang University of Technology ZJUT
Priority to CN201610261157.9A priority Critical patent/CN105930219B/en
Publication of CN105930219A publication Critical patent/CN105930219A/en
Application granted granted Critical
Publication of CN105930219B publication Critical patent/CN105930219B/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/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Communication Control (AREA)

Abstract

一种自定义的多线程管控的通信方法,包括如下步骤:1)针对子线程的入口函数设计一个参数结构对象,其内嵌业务参数和两个命令指针单项;内嵌业务参数是正常的业务设计功能所需要的,命令指针单项是为父子线程之间的控制管理所设计;2)在父线程中定义、初始化2个局部变量,其地址作为上行、下行命令参数指针,启动子线程;3)在父线程中改变局部变量取值,所述局部变量包括下行命令参数,该取值变动引起子线程执行逻辑的变动;4)在子线程中获取传入指针,改变上行命令参数的取值,该取值变动引起父线程中代码执行逻辑的变动。本发明减少内核资源消耗、代码封装较简约、实时性良好。

A self-defined communication method for multi-thread management and control, comprising the following steps: 1) designing a parameter structure object for the entry function of a sub-thread, in which business parameters and two command pointer items are embedded; the embedded business parameters are normal services What is required for the design function, the single item of the command pointer is designed for the control management between the parent and child threads; 2) Define and initialize two local variables in the parent thread, and their addresses are used as the parameter pointers of the up and down commands to start the child thread; 3 ) in the parent thread, change the value of the local variable, the local variable includes the downlink command parameter, and this value change causes the change of the execution logic of the child thread; 4) obtain the incoming pointer in the child thread, and change the value of the uplink command parameter , the value change causes the code execution logic in the parent thread to change. The invention reduces the consumption of kernel resources, the code encapsulation is relatively simple, and the real-time performance is good.

Description

A kind of communication means of customized multithreading control
Technical field
The invention belongs to the communication means that program communication method more particularly to a kind of multithreading are managed.
Background technique
Multi-thread programming is a kind of software design that the several operation systems such as Windows/Linux/vxWorks are generally supported The design method that a variety of development language platforms such as method and C/C++, Java, C# are supported.In each generic operation system of C/C++ level Management control, data communication between enterprising line journey of uniting, there is similar a concept and mode, for example, mutual exclusion, locking, synchronization and Wait etc..In JAVA since the multithreading API of language level supports that multi-thread design becomes more simple, JAVA Multi-thread control The granularity of management is thicker compared with C/C++, thus flexibility is unlike the latter.
On each type operating system, using C/C++ carry out multithread programming thread management-control method, especially two The synchronization of father and son's cross-thread progress different code sections.It is realized usually using lock mechanism, signal lamp, it can be on the windows The switching and control of code execution flow are carried out using message.But these mechanism generally use kernel objects, external variable, in resource It is not brief enough in consumption, code wrap;The message mechanism of windows be it is non real-time, sometimes will lead to the excessively long time Delay.
Summary of the invention
In order to overcome, the kernel resources consumption of the communication means of existing multithreading control is larger, code wrap is not brief, real The poor deficiency of when property, the present invention provides a kind of consumption of reduction kernel resources, code wrap is more brief, real-time is good certainly The communication means of the multithreading control of definition.
The technical solution adopted by the present invention to solve the technical problems is:
A kind of communication means of customized multithreading control, the communication means include the following steps:
1) an argument structure object is designed for the entrance function of sub thread, embedded service parameter and two orders refer to Needle individual event;Embedded service parameter is required for normal service design function, and command pointer individual event is between father and son's thread Control management designed by;
2) it defined in father's thread, initialize 2 local variables, address is opened as uplink, down order parameter pointer Mover thread;
3) change local variable value in father's thread, the local variable includes down order parameter, which changes Sub thread is caused to execute the variation of logic;
4) incoming pointer is obtained in sub thread, changes the value of uplink command parameter, and value variation causes father's thread Middle code executes the variation of logic.
Further, the step 3), 4) view actual code design needs repeatedly, alternately irregularly carry out.
Further, step 3), 4) in, caused by switching respectively in the order for executing other side's thread before code segment, in advance First initial value is changeed back parameter command.
Further, before carrying out the control to another thread by change bid value in thread, the current command is checked Whether parameter is initial value, is the revaluate that initial value just carries out order, otherwise it is assumed that preceding once to the revaluate of order, there are no draw Play the variation that thread executes flow direction.
Technical concept of the invention are as follows: devise a kind of thread code switching control technology based on command parameter, the party Method is suitable for the several operation systems such as Windows/Linux/vxWorks and realizes in C/C++ level.
Using the command parameter of built-in pointer form in the input parameter of thread function, father's thread can after starting sub thread With setting command value, sub thread executes different code segments according to order;Different command parameters also can be set in sub thread Value executes flow direction to the code segment of father's thread and controls.Its pointer ginseng that function in C/C++ language is substantially really utilized The property that carrying input and output are had both possessed by number.
Stick to ready-made Mutli-thread Programming Technology relative to existing general procedure person, and this method is different from ready-made more Thread synchronization programming mechanism;From system resources consumption, it is light weight method that the technology occupancy resource that this method uses is low;With WINDOWS message mechanism is compared, and this method real-time is good, is delayed low;This method is based on the parameter pointer realization between function, no It is related to definition outside or global variable, code wrap is relatively good.
Beneficial effects of the present invention are mainly manifested in: the consumption of reduction kernel resources, code wrap is more brief, real-time is good It is good.
Detailed description of the invention
Fig. 1 is the schematic diagram of the communication means of customized multithreading control.
Specific embodiment
The invention will be further described below in conjunction with the accompanying drawings.
Referring to Fig.1, a kind of communication means of customized multithreading control, includes the following steps:
1) an argument structure object is designed for the entrance function of sub thread, embedded service parameter and two orders refer to Needle individual event;The former is required for normal service design function, and the latter is designed by the control management between father and son's thread;
Typedef struct
{
Char*downcmd;// downlink control parameter controls sub thread for father's thread
Char*upcmd;// upload control parameter is used for sub-line process control father's thread
Struct*SunWorkPara;
}SUN_THREAD_PARA;
For example, SunWorkPara is that sub thread needed for former business is passed to parameter,
Downcmd/upcmd is the command parameter of character type, they synthesize new sub thread function
Parameter.
2) it defined in father's thread, initialize 2 local variables, address is opened as uplink, down order parameter pointer Mover thread;
3) change (down order parameter) local variable value in father's thread, value variation causes sub thread execution to be patrolled The variation collected;
4) incoming pointer is obtained in sub thread, changes the value of uplink command parameter, and value variation causes father's thread Middle code executes the variation of logic.
The step 3), 4) design of view actual code needs, and repeatedly, alternately can irregularly carry out.
The step 3), 4) in, caused by switching respectively in the order for executing other side's thread before code segment, in advance ginseng Initial value is changeed back in number order.
By changing before bid value carries out the control to another thread in thread, check the current command parameter whether be Initial value is the revaluate that initial value just carries out order, otherwise it is assumed that preceding once to the revaluate of order, there are no cause thread to execute The variation of flow direction.
Example: a method prototype with C Implementation of pseudocode, sub thread is the thread of long-term terminate-and-stay-resident here, wherein Father's thread code

Claims (4)

1. a kind of communication means of customized multithreading control, it is characterised in that: the communication means includes the following steps:
1) an argument structure object is designed for the entrance function of sub thread, embeds service parameter and two command pointer lists ?;Embedded service parameter is required for normal service design function, and command pointer individual event is the control between father and son's thread Designed by tubulation reason;
2) it defined in father's thread, initialize 2 local variables, address is as uplink, down order parameter pointer, promoter Thread;
3) change local variable value in father's thread, the local variable includes down order parameter, and value variation causes The variation of sub thread execution logic;
4) incoming pointer is obtained in sub thread, changes the value of uplink command parameter, and value variation causes generation in father's thread Code executes the variation of logic.
2. a kind of communication means of customized multithreading control as described in claim 1, it is characterised in that: the step 3), 4) view actual code design need, and repeatedly, alternately irregularly carries out.
3. a kind of communication means of customized multithreading control as claimed in claim 1 or 2, it is characterised in that: step 3), 4) in, before code segment caused by switching respectively in the order for executing other side's thread, in advance down order parameter in father's thread Value change back that initial value, the value of uplink command parameter changes back initial value in sub thread.
4. a kind of communication means of customized multithreading control as claimed in claim 1 or 2, it is characterised in that: in thread It is interior carry out the control to father, sub thread by changing uplink, down order parameter value before, check that uplink and downlink command parameter value is No is initial value, is the revaluate that initial value just carries out uplink and downlink command parameter, otherwise it is assumed that preceding once to uplink and downlink command parameter Revaluate, there are no cause operating system execution thread dispatch execution flow direction variation.
CN201610261157.9A 2016-04-22 2016-04-22 A custom communication method for multi-threaded management Active CN105930219B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610261157.9A CN105930219B (en) 2016-04-22 2016-04-22 A custom communication method for multi-threaded management

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610261157.9A CN105930219B (en) 2016-04-22 2016-04-22 A custom communication method for multi-threaded management

Publications (2)

Publication Number Publication Date
CN105930219A CN105930219A (en) 2016-09-07
CN105930219B true CN105930219B (en) 2019-02-05

Family

ID=56837109

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610261157.9A Active CN105930219B (en) 2016-04-22 2016-04-22 A custom communication method for multi-threaded management

Country Status (1)

Country Link
CN (1) CN105930219B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113485839A (en) * 2021-07-27 2021-10-08 中国银行股份有限公司 Data processing method and system

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101833476A (en) * 2010-05-28 2010-09-15 西安交通大学 Independent Stack Function Calling Method under Speculative Multithreading Mechanism Based on CMP
CN102279774A (en) * 2011-08-22 2011-12-14 中兴通讯股份有限公司 Method and device for realizing multi-thread message interaction by using synchronous function calling mechanism
CN103744643A (en) * 2014-01-10 2014-04-23 浪潮(北京)电子信息产业有限公司 Method and device for structuring a plurality of nodes parallel under multithreaded program
US8819700B2 (en) * 2010-12-22 2014-08-26 Lsi Corporation System and method for synchronous inter-thread communication

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE102005001025A1 (en) * 2005-01-07 2006-07-27 Infineon Technologies Ag Multi-thread processor, has switching table receiving internal and external exceptions of specific context, where context parameter sets of exceptions are updated, and switching parameter set is set for flow control of program commands

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101833476A (en) * 2010-05-28 2010-09-15 西安交通大学 Independent Stack Function Calling Method under Speculative Multithreading Mechanism Based on CMP
US8819700B2 (en) * 2010-12-22 2014-08-26 Lsi Corporation System and method for synchronous inter-thread communication
CN102279774A (en) * 2011-08-22 2011-12-14 中兴通讯股份有限公司 Method and device for realizing multi-thread message interaction by using synchronous function calling mechanism
CN103744643A (en) * 2014-01-10 2014-04-23 浪潮(北京)电子信息产业有限公司 Method and device for structuring a plurality of nodes parallel under multithreaded program

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
POS实时监控软件多线程通信设计及实现;刘艳群,朱庄生;《计算机工程与设计》;20150630;第1401-1406页 *

Also Published As

Publication number Publication date
CN105930219A (en) 2016-09-07

Similar Documents

Publication Publication Date Title
CN103744643B (en) The method and device of multi-node parallel framework under a kind of multithread programs
CN114841345B (en) Distributed computing platform based on deep learning algorithm and application thereof
CN107407918A (en) Expand your programmable logic controller with an app
CN112506477B (en) Method for adding computing nodes in Kubernetes cluster by using RESTful API
US11695632B1 (en) Management and control across heterogeneous edge devices of a client network using device abstractions
Prehofer et al. From internet of things mashups to model-based development
CN106201670B (en) A kind of CAN bus data processing method based on Labview
CN101833458A (en) Method for automatically generating user application interface based on template
CN103530898A (en) Animation processing method and system based on 3D real-time rendering
CN105930219B (en) A custom communication method for multi-threaded management
CN105204859A (en) Animation management method and system
WO2019136837A1 (en) Intelligent load system, method and device, and storage medium
CN106603583A (en) Micro-service network building method
CN105843660A (en) Code optimization scheduling method for encoder
CN110990009A (en) Method for adapting different screen sizes of Android-UI and Android application development method
CN103605526A (en) Template componentized code generating method based on chain-of-responsibility pattern
CN107678863A (en) The page assembly means of communication and device
US20130179864A1 (en) Deadlock free synchronization synthesizer for must-happen-before relations in parallel programs and method thereof
CN105335135A (en) Data processing method and center node
CN105700913B (en) A kind of parallel operation method of lightweight bare die code
Vepsäläinen et al. Tool support for the UML automation profile-for domain-specific software development in manufacturing
CN116841560A (en) A highly customized operating system construction method and system for RISC-V AIoT
CN109144486A (en) A kind of workflow implementation method statelessly changed
US20240045733A1 (en) Method and apparatus for deploying deep learning system
CN110007597A (en) The optimization method of status poll and event driven software state machine design mode

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20220128

Address after: 310000 5-1006, No. 501, No. 2 street, Baiyang street, Qiantang new area, Hangzhou, Zhejiang Province

Patentee after: Hangzhou Markov Technology Co.,Ltd.

Address before: The city Zhaohui six districts Chao Wang Road Hangzhou City, Zhejiang province 310014 18

Patentee before: ZHEJIANG University OF TECHNOLOGY