CN105068861A - Transaction execution method and device - Google Patents

Transaction execution method and device Download PDF

Info

Publication number
CN105068861A
CN105068861A CN201510405188.2A CN201510405188A CN105068861A CN 105068861 A CN105068861 A CN 105068861A CN 201510405188 A CN201510405188 A CN 201510405188A CN 105068861 A CN105068861 A CN 105068861A
Authority
CN
China
Prior art keywords
affairs
thread
perform
execution
idle
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
CN201510405188.2A
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.)
Hefei Jun Zheng Science And Technology Ltd
Original Assignee
Hefei Jun Zheng Science And Technology 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 Hefei Jun Zheng Science And Technology Ltd filed Critical Hefei Jun Zheng Science And Technology Ltd
Priority to CN201510405188.2A priority Critical patent/CN105068861A/en
Publication of CN105068861A publication Critical patent/CN105068861A/en
Pending legal-status Critical Current

Links

Abstract

The present invention discloses a transaction execution method and device, and relates to a computer technology. The transaction execution method provided by the embodiment of the present invention includes that after a set cycle is reached each time, idle threads are started, and according to a preset sequence, transactions are called and current stages to be executed of the transactions are executed, so that a plurality of threads can respectively execute a plurality of transactions at the same time, if the set of a cycle length is good, the N threads can respectively execute the N transactions at the same time, and meanwhile the execution efficiency is improved. Because of periodic start of the idle threads and sequential execution of transaction by the idle threads, the increase and decrease of transactions, partition of transaction stages, and setting of cycles may be modified flexibly, and the flexibility of transaction calls may be improved.

Description

A kind of affairs manner of execution and device
Technical field
The present invention relates to computer technology, particularly relate to a kind of affairs manner of execution and device.
Background technology
At present, computing machine, when affairs perform, for improving the efficiency that affairs perform, adopts computer pipeline mechanism and multi-thread mechanism usually.
Computer pipeline mechanism: modern computing machine generally can realize by multi-stage pipeline several stages that an instruction performs concurrently to carry out, and can reach the effect that each clock period completes an instruction so on average.
Multithreading: thread is an affairs executable unit, each thread can perform separately oneself affairs, by the technology of time-sharing multiplex and multinuclear, multiple thread can be allowed simultaneously to work, raise the efficiency.
Synchronously, sequentially calling processing method: generally, if there are multiple affairs to need process, the execution affairs A of needs order, affairs B, affairs C, affairs D etc., now, the starting of rear stage affairs depends on completing of previous stage affairs, and new one takes turns transaction dependency in last affairs of epicycle and completes.
Generally, when there being multinomial affairs to need process, need synchronously, sequentially to call each affairs, such guarantee every affairs are completed in order successively.But so often cause the waste of resource (degree of parallelism is not high), and the overall efficiency performed of impact.As shown in Figure 1,4 affairs order performs, and one takes turns affairs performs and need T.T. to be: t1+t2+t3+t4, and when each affairs performs, only has the resource of these affairs occupied, and the resource of other affairs is idle, causes waste.
For improving execution efficiency, can adopt parallel mechanism, while first round affairs B performs, another thread execution affairs A, such A and B can " simultaneously " perform.When adopting parallel mechanism, the multinomial resource of synchronization all can be called.But such software mechanism is fixing, the software of encoding out for particular case cannot be applied in news, and news needs redesign to write according to parallel mechanism, debugging software, takies a large amount of software development time.
Further because synchronously, sequence call mechanism, common parallel mechanism structure is fixing, operationally cannot complete " hot plug " of affairs.To increase or deleting affairs, need software all to stop and again building affairs chain to run, so just can lower efficiency, affect Consumer's Experience.
Summary of the invention
The embodiment of the present invention provides a kind of affairs manner of execution and device, to improve the execution efficiency of affairs, and improves the dirigibility that affairs call.
A kind of affairs manner of execution that the embodiment of the present invention provides, comprising:
After determining to reach setting cycle, start an idle thread;
By this thread according to the order preset, call affairs and perform these affairs current stage that will perform, each affairs at synchronization only by a thread execution.
Further, described determine to reach setting cycle after, start an idle thread, specifically comprise:
After determining to reach setting cycle, from thread pool, choose an idle thread, and wake this thread up;
Now, described by this thread according to the order preset, call affairs and after performing these affairs current stage that will perform, also comprise:
Determine all affairs current stage that will perform in thread all complete after, thread enters idle condition, revert to thread pool.
Preferably, describedly determine to reach setting cycle, specifically comprise:
Determine to reach setting cycle by ticking driving.
Further, each affairs, specifically comprise only by a thread execution at synchronization:
Each affairs inherit same public base class when performing, and described public base class is used for affairs were forbidden by other thread dispatching before a thread execution terminates.
Further, the method also comprises:
When calling the affairs failure that will perform, after waiting for setting-up time, then call and perform this affairs;
Or
When calling the affairs failure that will perform, thread enters idle condition, revert to thread pool.
Further, each affairs realize affairs concrete function by constructed fuction and readjustment process function.
The embodiment of the present invention also provides a kind of affairs actuating unit, comprising:
Start unit, after determining to reach setting cycle, starts an idle thread;
Performance element, for by this thread according to the order preset, call affairs and perform these affairs current stage that will perform, each affairs at synchronization only by a thread execution.
Further, described start unit specifically for:
After determining to reach setting cycle, from thread pool, choose an idle thread, and wake this thread up;
Now, described performance element also for:
Determine all affairs current stage that will perform in thread all complete after, thread enters idle condition, revert to thread pool.
Further, each affairs, specifically comprise only by a thread execution at synchronization:
Each affairs are when performing, and all inherit same public base class, described public base class is used for affairs were forbidden by other thread dispatching before a thread execution terminates.
Further, described performance element also for:
When calling the affairs failure that will perform, after waiting for setting-up time, then call and perform this affairs;
Or
When calling the affairs failure that will perform, thread enters idle condition, revert to thread pool.
The embodiment of the present invention provides a kind of affairs manner of execution and device, after reaching setting cycle at every turn, start idle thread, according to the order preset, call affairs and perform these affairs current stage that will perform, thus can be implemented in synchronization and have multiple thread to perform multiple affairs respectively, if it is better that cycle duration is arranged, then can realize N affairs to be performed respectively by N number of thread at synchronization, thus improve the execution efficiency of affairs, owing to periodically starting idle thread, affairs are performed again by idle thread order, the increase and decrease of affairs, the division of transaction phase and the cycle etc. of setting can revise flexibly, improve the dirigibility that affairs are called.
Accompanying drawing explanation
Fig. 1 is that affairs of the prior art perform schematic diagram consuming time;
The affairs manner of execution process flow diagram that Fig. 2 provides for the embodiment of the present invention;
Fig. 3 performs schematic diagram consuming time for the affairs of the affairs manner of execution that the embodiment of the present invention provides;
The inheritance schematic diagram of affairs in the affairs manner of execution that Fig. 4 provides for the embodiment of the present invention;
The affairs actuating unit structural representation that Fig. 5 provides for the embodiment of the present invention.
Embodiment
The embodiment of the present invention provides a kind of affairs manner of execution and device, after reaching setting cycle at every turn, start idle thread, according to the order preset, call affairs and perform these affairs current stage that will perform, thus can be implemented in synchronization and have multiple thread to perform multiple affairs respectively, if it is better that cycle duration is arranged, then can realize N affairs to be performed respectively by N number of thread at synchronization, thus improve the execution efficiency of affairs, owing to periodically starting idle thread, affairs are performed again by idle thread order, the increase and decrease of affairs, the division of transaction phase and the cycle etc. of setting can revise flexibly, improve the dirigibility that affairs are called.
As shown in Figure 2, the affairs manner of execution that the embodiment of the present invention provides, comprising:
Step S201, determine to reach setting cycle after, start an idle thread;
Step S202, by this thread according to the order preset, call affairs and perform these affairs current stage that will perform, each affairs at synchronization only by a thread execution.
After reaching setting cycle, all start a thread order and perform affairs, synchronization can be made to have multiple thread to perform multiple affairs respectively, and the resource of multiple affairs is all occupied, improves the execution efficiency of affairs and the utilization factor of resource at every turn.Further, periodically start idle thread, then perform affairs by idle thread order, the control of the increase and decrease of affairs, cycle and thread can be revised flexibly, improves the dirigibility that affairs are called.
Such as, after the first stage of complete first affairs of thread execution that one-period starts, start the first stage performing the second affairs, now, the thread that second period starts starts the subordinate phase performing the first affairs, simultaneously the first stage of the second affairs and the subordinate phase of the first affairs performed by different threads, thus improve affairs execution efficiency.
As shown in Figure 3, after the first stage of complete first affairs of thread execution that one-period starts, start the first stage performing the second affairs, now, the thread that second period starts starts the subordinate phase performing the first affairs, after the first stage of complete second affairs of thread execution that one-period starts, start the first stage performing the 3rd affairs, now, the thread that second period starts starts the subordinate phase performing the second affairs, and the thread of the 3rd cycle startup starts the three phases performing the first affairs.
The quantity in the stage that the quantity of affairs and each affairs divide is more close, and the execution efficiency of its affairs is higher, in theory, when the two is equal, the peak value of affairs execution efficiency can be reached, in practical operation, the division in stage can be carried out according to the concrete condition of affairs.
Further, in step s 201, after determining to reach setting cycle, start an idle thread, specifically comprise:
After determining to reach setting cycle, from thread pool, choose an idle thread, and wake this thread up;
Now, in step S202 by this thread according to the order preset, call affairs and after performing these affairs current stage that will perform, also comprise:
Determine all affairs current stage that will perform in thread all complete after, thread enters idle condition, revert to thread pool.
Thread in the embodiment of the present invention, sometimes referred to as Lightweight Process, is the minimum unit that program performs stream.Thread pool is a kind of multiple threads form, adds affairs to queue in processing procedure, then these affairs of sequence call after startup thread.
In the embodiment of the present invention, can by determining whether to reach setting cycle by ticking driving.
For guaranteeing each affairs at synchronization only by a thread execution, can when specific implementation, make each affairs inherit same public base class when performing, public base class is used for affairs were forbidden by other thread dispatching before a thread execution terminates.Each affairs can realize affairs concrete function by constructed fuction and readjustment process function.
Realize each affairs when synchronization is only by a thread execution by which, after each thread starts, itself need not be concerned about the concurrency relation with other threads.Each affairs inherit public base class, achieves the mutual exclusion of affairs in this public base class, i.e. not reenterability.Same like this affairs by another one thread dispatching, can not ensure that the uniqueness of single affairs before end.Because ticktack drives with time T for the cycle starts, namely every T time starts " a string " affairs, and therefore can obtain an average performance times of taking turns affairs is also T, improves execution efficiency.
As shown in Figure 4, each concrete affairs need succession public base class, achieved public method in this public base class, concrete affairs only need to realize constructed fuction createNew () and readjustment process function doProcess ()---namely realize the function that affairs are concrete.Also can find out that the affairs manner of execution that the embodiment of the present invention provides easily is expanded from this point, dirigibility is high.
Further, the affairs manner of execution that the embodiment of the present invention provides also comprises:
When calling the affairs failure that will perform, after waiting for setting-up time, then call and perform this affairs; Or when calling the affairs failure that will perform, thread enters idle condition, revert to thread pool.
During the affairs failure that will perform if call, after waiting for setting-up time, then call and perform this affairs, this setting-up time can set according to actual conditions, if due to the malloc failure malloc that the previous stage of affairs is being caused by other thread execution, then the execution efficiency of affairs is higher; During the affairs failure that will perform if call, thread enters idle condition, revert to thread pool, then situation about being suitable for is more, is more conducive to the stable of system and more easily expands.
The embodiment of the present invention also provides a kind of affairs actuating unit, as shown in Figure 5, comprising:
Start unit 501, after determining to reach setting cycle, starts an idle thread;
Performance element 502, for by this thread according to the order preset, call affairs and perform these affairs current stage that will perform, each affairs at synchronization only by a thread execution.
Wherein, start unit 501 specifically for:
After determining to reach setting cycle, from thread pool, choose an idle thread, and wake this thread up;
Now, performance element 502 also for:
Determine all affairs current stage that will perform in thread all complete after, thread enters idle condition, revert to thread pool.
Further, each affairs, specifically comprise only by a thread execution at synchronization:
Each affairs are when performing, and all inherit same public base class, public base class is used for affairs were forbidden by other thread dispatching before a thread execution terminates.
Further, performance element 502 also for:
When calling the affairs failure that will perform, after waiting for setting-up time, then call and perform this affairs;
Or
When calling the affairs failure that will perform, thread enters idle condition, revert to thread pool.
The embodiment of the present invention provides a kind of affairs manner of execution and device, after reaching setting cycle at every turn, start idle thread, according to the order preset, call affairs and perform these affairs current stage that will perform, thus can be implemented in synchronization and have multiple thread to perform multiple affairs respectively, if it is better that cycle duration is arranged, then can realize N affairs to be performed respectively by N number of thread at synchronization, thus improve the execution efficiency of affairs, owing to periodically starting idle thread, affairs are performed again by idle thread order, the increase and decrease of affairs, the division of transaction phase and the cycle etc. of setting can revise flexibly, improve the dirigibility that affairs are called.
Those skilled in the art should understand, embodiments of the invention can be provided as method, system or computer program.Therefore, the present invention can adopt the form of complete hardware embodiment, completely software implementation or the embodiment in conjunction with software and hardware aspect.And the present invention can adopt in one or more form wherein including the upper computer program implemented of computer-usable storage medium (including but not limited to magnetic disk memory, CD-ROM, optical memory etc.) of computer usable program code.
The present invention describes with reference to according to the process flow diagram of the method for the embodiment of the present invention, equipment (system) and computer program and/or block scheme.Should understand can by the combination of the flow process in each flow process in computer program instructions realization flow figure and/or block scheme and/or square frame and process flow diagram and/or block scheme and/or square frame.These computer program instructions can being provided to the processor of multi-purpose computer, special purpose computer, Embedded Processor or other programmable data processing device to produce a machine, making the instruction performed by the processor of computing machine or other programmable data processing device produce device for realizing the function of specifying in process flow diagram flow process or multiple flow process and/or block scheme square frame or multiple square frame.
These computer program instructions also can be stored in can in the computer-readable memory that works in a specific way of vectoring computer or other programmable data processing device, the instruction making to be stored in this computer-readable memory produces the manufacture comprising command device, and this command device realizes the function of specifying in process flow diagram flow process or multiple flow process and/or block scheme square frame or multiple square frame.
These computer program instructions also can be loaded in computing machine or other programmable data processing device, make on computing machine or other programmable devices, to perform sequence of operations step to produce computer implemented process, thus the instruction performed on computing machine or other programmable devices is provided for the step realizing the function of specifying in process flow diagram flow process or multiple flow process and/or block scheme square frame or multiple square frame.
Although describe the preferred embodiments of the present invention, those skilled in the art once obtain the basic creative concept of cicada, then can make other change and amendment to these embodiments.So claims are intended to be interpreted as comprising preferred embodiment and falling into all changes and the amendment of the scope of the invention.
Obviously, those skilled in the art can carry out various change and modification to the present invention and not depart from the spirit and scope of the present invention.Like this, if these amendments of the present invention and modification belong within the scope of the claims in the present invention and equivalent technologies thereof, then the present invention is also intended to comprise these change and modification.

Claims (10)

1. an affairs manner of execution, is characterized in that, comprising:
After determining to reach setting cycle, start an idle thread;
By this thread according to the order preset, call affairs and perform these affairs current stage that will perform, each affairs at synchronization only by a thread execution.
2. the method for claim 1, is characterized in that, described determine to reach setting cycle after, start an idle thread, specifically comprise:
After determining to reach setting cycle, from thread pool, choose an idle thread, and wake this thread up;
Described by this thread according to the order preset, call affairs and after performing these affairs current stage that will perform, also comprise:
Determine all affairs current stage that will perform in thread all complete after, thread enters idle condition, revert to thread pool.
3. method as claimed in claim 1 or 2, is characterized in that, describedly determines to reach setting cycle, specifically comprises:
Determine to reach setting cycle by ticking driving.
4. the method for claim 1, is characterized in that, each affairs, specifically comprise only by a thread execution at synchronization:
Each affairs inherit same public base class when performing, and described public base class is used for affairs were forbidden by other thread dispatching before a thread execution terminates.
5. method as claimed in claim 4, is characterized in that, also comprise:
When calling the affairs failure that will perform, after waiting for setting-up time, then call and perform this affairs;
Or
When calling the affairs failure that will perform, thread enters idle condition, revert to thread pool.
6. method as claimed in claim 4, is characterized in that, each affairs realize affairs concrete function by constructed fuction and readjustment process function.
7. an affairs actuating unit, is characterized in that, comprising:
Start unit, after determining to reach setting cycle, starts an idle thread;
Performance element, for by this thread according to the order preset, call affairs and perform these affairs current stage that will perform, each affairs at synchronization only by a thread execution.
8. device as claimed in claim 7, is characterized in that, described start unit specifically for:
After determining to reach setting cycle, from thread pool, choose an idle thread, and wake this thread up;
Described performance element also for:
Determine all affairs current stage that will perform in thread all complete after, thread enters idle condition, revert to thread pool.
9. device as claimed in claim 7, it is characterized in that, each affairs, specifically comprise only by a thread execution at synchronization:
Each affairs are when performing, and all inherit same public base class, described public base class is used for affairs were forbidden by other thread dispatching before a thread execution terminates.
10. device as claimed in claim 9, is characterized in that, described performance element also for:
When calling the affairs failure that will perform, after waiting for setting-up time, then call and perform this affairs;
Or
When calling the affairs failure that will perform, thread enters idle condition, revert to thread pool.
CN201510405188.2A 2015-07-09 2015-07-09 Transaction execution method and device Pending CN105068861A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510405188.2A CN105068861A (en) 2015-07-09 2015-07-09 Transaction execution method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510405188.2A CN105068861A (en) 2015-07-09 2015-07-09 Transaction execution method and device

Publications (1)

Publication Number Publication Date
CN105068861A true CN105068861A (en) 2015-11-18

Family

ID=54498239

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510405188.2A Pending CN105068861A (en) 2015-07-09 2015-07-09 Transaction execution method and device

Country Status (1)

Country Link
CN (1) CN105068861A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107729137A (en) * 2017-09-04 2018-02-23 上海壹账通金融科技有限公司 Server, the method and storage medium of the decryption of block chain sign test
CN110351345A (en) * 2019-06-25 2019-10-18 阿里巴巴集团控股有限公司 Method and device for service request processing
CN111083202A (en) * 2019-11-28 2020-04-28 中科驭数(北京)科技有限公司 Multi-connection interaction method and device for TCP/IP accelerator

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1873615A (en) * 2006-01-20 2006-12-06 华为技术有限公司 Method for servicing task of timer
US20070283361A1 (en) * 2004-07-06 2007-12-06 Jean-Bernard Blanchet Processor Time-Sharing Method
CN101887361A (en) * 2009-05-14 2010-11-17 灰熊(北京)科技有限公司 Method for efficiently processing delayed tasks under multi-thread environment
CN102594891A (en) * 2012-02-17 2012-07-18 中国科学院计算技术研究所 Method and system for processing remote procedure call request
CN104615413A (en) * 2015-02-13 2015-05-13 赛诺威盛科技(北京)有限公司 Flow line task self-adaptation parallelization method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070283361A1 (en) * 2004-07-06 2007-12-06 Jean-Bernard Blanchet Processor Time-Sharing Method
CN1873615A (en) * 2006-01-20 2006-12-06 华为技术有限公司 Method for servicing task of timer
CN101887361A (en) * 2009-05-14 2010-11-17 灰熊(北京)科技有限公司 Method for efficiently processing delayed tasks under multi-thread environment
CN102594891A (en) * 2012-02-17 2012-07-18 中国科学院计算技术研究所 Method and system for processing remote procedure call request
CN104615413A (en) * 2015-02-13 2015-05-13 赛诺威盛科技(北京)有限公司 Flow line task self-adaptation parallelization method

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107729137A (en) * 2017-09-04 2018-02-23 上海壹账通金融科技有限公司 Server, the method and storage medium of the decryption of block chain sign test
CN107729137B (en) * 2017-09-04 2021-06-22 深圳壹账通智能科技有限公司 Server, block chain signature verification decryption method and storage medium
CN110351345A (en) * 2019-06-25 2019-10-18 阿里巴巴集团控股有限公司 Method and device for service request processing
CN110351345B (en) * 2019-06-25 2021-10-12 创新先进技术有限公司 Method and device for processing service request
CN111083202A (en) * 2019-11-28 2020-04-28 中科驭数(北京)科技有限公司 Multi-connection interaction method and device for TCP/IP accelerator
CN111083202B (en) * 2019-11-28 2021-03-26 中科驭数(北京)科技有限公司 Multi-connection interaction method and device for TCP/IP accelerator

Similar Documents

Publication Publication Date Title
AU2018203641B2 (en) Controlling tasks performed by a computing system
CA2767667C (en) Fault tolerant batch processing
JP2011507112A5 (en)
CN105068861A (en) Transaction execution method and device
CN111198689B (en) Code execution method, device and computer readable storage medium
CN110737533B (en) Task scheduling method and device, electronic equipment and storage medium
CN110968412B (en) Task execution method, system and storage medium
CN110716987B (en) Asynchronous execution method and scheduling system for synchronous tasks
CN111399969B (en) Virtual resource arranging system, method, device, medium and equipment
CN114327412A (en) Multithreading-based asynchronous supporting process arrangement method and system
AU2014274491B2 (en) Fault tolerant batch processing
CN113778742A (en) Program execution method, program processing method, and related apparatus
US8161436B1 (en) Method and system for transforming fork-join blocks in a hardware description language (HDL) specification
CN115454613A (en) Distributed processing method, node and distributed database system of DDL task

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20151118

WD01 Invention patent application deemed withdrawn after publication