CN109375965B - State machine processing method and device and readable storage medium - Google Patents

State machine processing method and device and readable storage medium Download PDF

Info

Publication number
CN109375965B
CN109375965B CN201811315037.8A CN201811315037A CN109375965B CN 109375965 B CN109375965 B CN 109375965B CN 201811315037 A CN201811315037 A CN 201811315037A CN 109375965 B CN109375965 B CN 109375965B
Authority
CN
China
Prior art keywords
state
sub
state machine
states
stack
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
CN201811315037.8A
Other languages
Chinese (zh)
Other versions
CN109375965A (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.)
Neusoft Corp
Original Assignee
Neusoft Corp
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 Neusoft Corp filed Critical Neusoft Corp
Priority to CN201811315037.8A priority Critical patent/CN109375965B/en
Publication of CN109375965A publication Critical patent/CN109375965A/en
Application granted granted Critical
Publication of CN109375965B publication Critical patent/CN109375965B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4498Finite state machines

Abstract

The embodiment of the invention provides a state machine processing method and device and a readable storage medium. The method comprises the following steps: determining N states in a state machine, wherein N is a positive integer; classifying states which can run in parallel in the N states according to the service logic corresponding to the state machine; establishing each type of state into a sub-state machine, wherein each sub-state machine comprises at least two states and events determined according to the business logic; and running all the sub-state machines in parallel, and combining the running results of all the sub-state machines to obtain the running result of the state machine. Therefore, the states and events needing to be maintained are greatly reduced, and the maintenance is convenient.

Description

State machine processing method and device and readable storage medium
Technical Field
The embodiment of the invention relates to the technical field of computer application, in particular to a state machine processing method and device and a readable storage medium.
Background
State machines are widely used in the computer field, and many systems use state machines. The state machine is composed of a set of nodes (states) and a set of corresponding transfer functions, and defines a plurality of states and transitions between the states, among the defined plurality of states, there is at least one initial state and at least one final state, the state machine starts to operate from the initial state, and when transitioning to the final state, the state machine stops operating.
For state transitions, the prior art uses a conventional serial state machine, i.e., the state machine runs in response to a series of events, which when certain trigger conditions are met, will cause the state machine to migrate from the current state to the next state.
In a multi-state serial state machine, when multiple states coexist and the number of transitions between different states is large, all the states and events form a full connection graph, and the states and events to be maintained are the full connection number (n × n-1)/2, n is the total number of states) of the state graph, so that the serial states and events are very large and difficult to maintain.
Disclosure of Invention
The embodiment of the invention provides a state machine processing method and device and a readable storage medium, which reduce states and events of a state machine needing to be maintained and are convenient to maintain.
In a first aspect, an embodiment of the present invention provides a state machine processing method, including:
determining N states in a state machine, wherein N is a positive integer;
classifying states which can run in parallel in the N states according to the service logic corresponding to the state machine;
establishing each type of state into a sub-state machine, wherein each sub-state machine comprises at least two states and events determined according to the business logic;
and running all the sub-state machines in parallel, and combining the running results of all the sub-state machines to obtain the running result of the state machine.
Optionally, the establishing the state of each class into a sub-state machine includes:
if the number of states included in one type of state is 1, the initial state of the sub-state machine corresponding to the state number of 1 in the normal state is added when the sub-state machine is established.
Optionally, the method further includes:
adding stacks in the state machines, adding sub-stacks in each sub-state machine, wherein the stacks and the sub-stacks meet a first-in last-out rule;
and when the state is migrated, the migrated state is stacked and stored.
Optionally, the method further includes:
when state rollback is carried out, firstly popping the state of the stack which is put into the stack later until the bottom of the stack to obtain all the states in the stack;
and firstly popping the state of the sub-stack which is then pushed into the stack until the stack bottom to obtain all the states in the sub-stack.
In a second aspect, an embodiment of the present invention provides a state machine processing apparatus, including:
the determining module is used for determining N states in the state machine, wherein N is a positive integer;
the classification module is used for classifying the states which can run in parallel in the N states according to the business logic corresponding to the state machine;
the first processing module is used for establishing each type of state into a sub-state machine, and each sub-state machine comprises at least two states and events determined according to the service logic;
and the operation module is used for operating all the sub-state machines in parallel and combining the operation results of all the sub-state machines to obtain the operation result of the state machine.
Optionally, the first processing module is configured to:
if the number of states included in one type of state is 1, the initial state of the sub-state machine corresponding to the state number of 1 in the normal state is added when the sub-state machine is established.
Optionally, the apparatus further comprises:
the second processing module is used for adding stacks in the state machines and adding sub-stacks in each sub-state machine, and the stacks and the sub-stacks meet a first-in and last-out rule;
and when the state is migrated, the migrated state is stacked and stored.
Optionally, the second processing module is further configured to:
when state rollback is carried out, firstly popping the state of the stack which is put into the stack later until the bottom of the stack to obtain all the states in the stack;
and firstly popping the state of the sub-stack which is then pushed into the stack until the stack bottom to obtain all the states in the sub-stack.
In a third aspect, an embodiment of the present invention provides a state machine processing apparatus, including:
a memory for storing program instructions;
a processor for calling and executing program instructions in said memory to implement the state machine processing method of the first aspect.
In a fourth aspect, an embodiment of the present invention provides a readable storage medium, where a computer program is stored, and when at least one processor of a state machine processing apparatus executes the computer program, the state machine processing apparatus executes the state machine processing method according to the first aspect.
In a fifth aspect, an embodiment of the present invention provides a program product, which includes a computer program, and the computer program is stored in a readable storage medium. The computer program may be read from a readable storage medium by at least one processor of the state machine processing apparatus, execution of which by the at least one processor causes the state machine processing apparatus to carry out the state machine processing method of the first aspect.
The state machine processing method and device, and the readable storage medium provided in the embodiments of the present invention classify states that can be concurrently operated among N states of a state machine according to a service logic corresponding to the state machine, then establish each class of state into a sub-state machine, each sub-state machine includes at least two states and an event determined according to the service logic, and finally concurrently operate all the sub-state machines, and combine operation results of all the sub-state machines to obtain an operation result of the state machine, so that a plurality of parallel sub-state machines are obtained according to a serial state machine, the sub-state machines are not affected by each other, the operation results of the sub-state machines can be combined, and finally obtain an operation result of the state machine, and compared with an original serial state machine, the number of states included in the sub-state machine is reduced, the number of full connections of the sub-state machines corresponding to a state diagram is also reduced, thereby reducing states and events that the state machine needs to be maintained, thus facilitating maintenance.
Drawings
In order to clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a flow chart of an embodiment of a state machine processing method according to the present invention;
FIG. 2 is a simple serial state machine;
FIG. 3 is a flow chart of an embodiment of a state machine processing method provided by the present invention;
FIG. 4 is a multi-state serial state machine;
FIG. 5 is a schematic diagram of a sub-state machine obtained after processing the serial state machine shown in FIG. 4;
fig. 6 is a schematic structural diagram of an embodiment of a state machine processing apparatus according to the present invention;
fig. 7 is a schematic structural diagram of an embodiment of a state machine processing apparatus according to the present invention;
fig. 8 is a schematic structural diagram of an embodiment of a state machine processing device according to the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments obtained by persons of ordinary skill in the art based on the embodiments of the present invention without any creative efforts shall fall within the protection scope of the embodiments of the present invention.
In the prior art, when multiple states coexist, a serial state machine driven by an event and in single-state transition is used, and when multiple states coexist, the different states are converted more, so that the states and events needing to be maintained are very many, and the maintenance is difficult. The technical solution of the present application is described in detail below with reference to the accompanying drawings.
The state machine is a finite state machine, and the state machine processing method and device provided by the application can be applied to the field of computers, and particularly can be applied to the research of modeling application behaviors, hardware circuit system design, software engineering, compilers, network protocols, calculation and languages and the like.
Fig. 1 is a flowchart of an embodiment of a state machine processing method provided by the present invention, the method of the present embodiment may be applied to a serial state machine with a large number of states and events, an execution main body of the present embodiment may be any software or hardware having a function of executing the state machine processing method of the present embodiment, as shown in fig. 1, the method of the present embodiment may include:
s101, determining N states in a state machine, wherein N is a positive integer.
Specifically, that is, it is determined that the state machine includes a total of states from the initial state to the final state, fig. 2 is a simple serial state machine, and taking the state machine shown in fig. 2 as an example, the state machine includes a total of the initialization state and the first state 2 states from the initial state to the final state.
S102, classifying the states which can run in parallel in the N states according to the business logic corresponding to the state machine.
Specifically, according to the service logic corresponding to the state machine, the states that can be run in parallel in the N states are classified, and different service logics are classified differently, for example, 10 states are included between the initial state and the final state in the state machine, after classification, there are 2 types, the first type includes 4 states, the second type includes 6 states, and these 2 types of states can be run in parallel. The parallel executable state refers to a state capable of being executed simultaneously.
In particular, the state machine classifications are based on the fact that states in one classification may be independent of states in another classification, such as logic for a game, and the sport walk-jump state may be independent of the shooting shoot state, such that the sport state may constitute a sub-state machine and the shooting state may constitute a sub-state machine.
S103, establishing each type of state into a sub-state machine, wherein each sub-state machine comprises at least two states and events determined according to the service logic.
Specifically, there are several classes after classification in S102, and the corresponding sub-state machines can be established as several sub-state machines, each sub-state machine includes at least two states and an event determined according to the service logic, and the event in the sub-state machine is also determined according to the service logic of the state machine, for example, the corresponding event in the state machine may also be extracted, and the obtained multiple sub-state machines may run in parallel.
If the number of states included in one class of states is 1, the initial state in the sub-state machine corresponding to the state number of 1 in the normal state is added when the sub-state machine is established. That is, if a certain class includes only 1 state, the normal state corresponding to the state is added as the initial state in the sub-state machine, and the final state is the included 1 state.
And S104, running all the sub-state machines in parallel, and combining the running results of all the sub-state machines to obtain the running result of the state machine.
Specifically, all the established sub-state machines are run in parallel, and after the running results are obtained, the sub-state machines are combined to finally obtain the running results of the state machines, for example: and (3) running 2 sub-state machines in parallel, wherein the running result of the sub-state machine 1 at the first moment is A, and the running result of the sub-state machine 2 at the first moment is B, so that the running result of the state machine at the first moment is AB, namely the combination of the running results of the two sub-state machines.
Compared with the serial state machine, the state number in the sub-state machine and the full connection number of the corresponding state diagram are greatly reduced, wherein the connection number represents the relationship between the two states, and the full connection number is the total number of the connection numbers, so that the maintenance is convenient.
The state machine processing method provided in this embodiment classifies states that can be concurrently operated among N states of a state machine according to service logic corresponding to the state machine, then establishes each class of states into a sub-state machine, each sub-state machine includes at least two states and an event determined according to the service logic, and finally concurrently operates all the sub-state machines, and combines operation results of all the sub-state machines to obtain operation results of the state machine, so that, by obtaining a plurality of parallel sub-state machines according to a serial state machine, the sub-state machines are not mutually affected, the operation results of the sub-state machines can be combined, and finally obtains operation results of the state machine, and compared with an original serial state machine, the number of states included in the sub-state machines is reduced, and the total connection number of the sub-state machines corresponding to a state diagram is also reduced, thereby reducing states and events that the state machine needs to maintain, thus facilitating maintenance.
In a multi-state serial state machine, when a service error occurs in a state and service rollback is required, since a traditional serial state machine cannot record a historical state, service logic rollback cannot be realized, and useless data is caused. In order to facilitate tracking of the historical state, in the embodiment of the present invention, on the basis of the method shown in fig. 1, a stack is added to a state machine, a sub-stack is added to each sub-state machine, the stack and the sub-stack satisfy a first-in last-out rule, and when state migration is performed, the state after migration is stacked and stored, so that state rollback can be achieved, the historical state is tracked, and a service rollback requirement is met. This solution is described in detail below with reference to the accompanying drawings.
Fig. 3 is a flowchart of an embodiment of a state machine processing method provided by the present invention, and as shown in fig. 3, the method of this embodiment may further include, on the basis of the method shown in fig. 1:
and S105, adding stacks in the state machines, adding sub-stacks in each sub-state machine, wherein the stacks and the sub-stacks meet a first-in and last-out rule, and when state migration is carried out, stacking the migrated states for storage.
It should be noted that S105 may be performed after the sub-state machine is established in S103.
S106, when state rollback is carried out, firstly popping the state of the stack which is put into the stack later until the bottom of the stack to obtain all the states in the stack, and firstly popping the state of the stack which is put into the sub-stack until the bottom of the stack to obtain all the states in the sub-stack.
Specifically, taking the state machine shown in fig. 2 as an example, for example, a stack is added to the state machine shown in fig. 2, when state transition is performed, the state after the transition is stacked and stored, and when the state transitions to the final state, the state of the stacked and stored state is as follows from left to right: a final state, a first state, and an initialization state. If the state rollback is carried out in the final state, the state of the stack after the stack is popped up until the bottom of the stack, and all the states in the stack are obtained, wherein the state rollback is as follows: a final state, a first state, and an initialization state. Therefore, the state rollback can be realized, the historical state is tracked, and the requirement of service rollback is met.
In the state machine processing method provided by this embodiment, a stack is added in a state machine, a sub-stack is added in each sub-state machine, the stack and the sub-stack satisfy a first-in and second-out rule, when state migration is performed, the state after migration is stacked and stored, when state rollback is performed, the state after stacking in the stack is firstly popped up to the bottom of the stack to obtain all states in the stack, and the state after stacking in the sub-stack is firstly popped up to the bottom of the stack to obtain all states in the sub-stack. Therefore, the rollback of the state can be realized, the historical state can be conveniently tracked, and the rollback of the business logic is realized when the business logic is wrong. And meanwhile, the system has the functions of combining and rolling back, and can flexibly provide complex service logic functions.
The following describes the technical solution of the embodiment of the method shown in fig. 1 and 3 in detail by using a specific embodiment.
Taking the state of a game as an example, fig. 4 is a multi-state serial state machine, as shown in fig. 4, in the serial state machine, the serial state machine includes seven states from the initialization state to the final state: initialization state, stationary state S1, in-flight state S2, running state S3, stationary shot state S4, in-flight shot state S5, and running shot state S6, the arrows between the states indicating events from the previous state to the next state, such as: station, jump, move, etc., which can be converted between states, and the connection number is Cartesian product, thus forming a more complex state machine. With reference to fig. 4, a method for processing a state machine according to an embodiment of the present invention specifically includes:
s201, determining N states in a state machine, wherein N is a positive integer.
Specifically, it is determined that the serial state machine in fig. 4 includes a total of seven states from the initial state to the final state: the initialization state, the stationary state S1, the in-flight state S2, the running state S3, the stationary shot state S4, the in-flight shot state S5, and the running shot state S6, N is 7.
S202, classifying states which can run in parallel in the 7 states according to the business logic corresponding to the state machine.
Optionally, according to the service logic corresponding to the state machine, for example, in this embodiment, the states of the game are classified, and states that can run in parallel among 7 states are classified into 2 types, including a shooting state a1 and a non-shooting state a2, where one type includes two states: a shot state a1 and a non-shot state a2, the other class includes three states: a stationary state B1, an in-flight state B2, and a running state B3.
S203, establishing the state of each type into a sub-state machine to obtain 2 sub-state machines.
Fig. 5 is a schematic diagram of a sub-state machine obtained by processing the serial state machine shown in fig. 4, and as shown in fig. 5, the processed sub-state machine includes 2 sub-state machines, and the sub-state machine 1: including the fired state a1 and the non-fired state a2, and the sub-state machine 2: including a static state B1, an in-flight state B2, and a running state B3, with events between states determined according to the original business logic. In this embodiment, the states in the sub-state machine do not have a one-to-one correspondence with the states in the original serial state machine.
S204, operating the sub-state machine 1 and the sub-state machine 2 in parallel, and combining the operation results of the sub-state machine 1 and the sub-state machine 2 to obtain the operation result of the state machines.
Specifically, when the sub-state machine 1 and the sub-state machine 2 are operated in parallel, for example, at a certain time, the operation result of the sub-state machine 1 is the non-firing state A2, the operation result of the sub-state machine 2 is the static state B1, and the state of the sub-state machine 1 and the state of the sub-state machine 2 are combined to be A2B1, so that the operation result of the state machine at the time can be obtained as follows: the static state is the state of the original serial state machine, i.e., the static state S1;
at some point, the operation result of sub-state machine 1 is non-shot state a2, and the operation result of sub-state machine 2 is: in the air state B2, the state of the sub-state machine 1 and the state of the sub-state machine 2 are combined to be A2B2, and the operation result of the state machine at the moment can be obtained as follows: in-flight state, i.e., the state of the original serial state machine-in-flight state S2;
at some point, the operation result of sub-state machine 1 is non-shot state a2, and the operation result of sub-state machine 2 is: running state B3, combining the state of sub-state machine 1 and the state of sub-state machine 2 to A2B3, the running result of the state machine at that time is: running state, i.e. the state of the original serial state machine-running state S3;
at some point, the result of the operation of sub-state machine 1 is shot state a1, and the result of the operation of sub-state machine 2 is: in the static state B1, the state of the sub-state machine 1 and the state of the sub-state machine 2 are combined to be A1B1, and the operation result of the state machine at the moment is obtained as follows: a static shooting state, i.e. the state of the original serial state machine-static shooting state S4;
at some point, the result of the operation of sub-state machine 1 is shot state a1, and the result of the operation of sub-state machine 2 is: in the air state B2, the state of the sub-state machine 1 and the state of the sub-state machine 2 are combined to be A1B2, and the operation result of the state machine at the moment can be obtained as follows: the air shooting state is the state of the original serial state machine, namely the air shooting state S5;
at some point, the result of the operation of sub-state machine 1 is shot state a1, and the result of the operation of sub-state machine 2 is: in the air state B3, the state of the sub-state machine 1 and the state of the sub-state machine 2 are combined to be A1B2, and the operation result of the state machine at the moment can be obtained as follows: the running shot state is the state of the original serial state machine, running shot state S6.
As shown in fig. 5, the number of connections represents the relationship between two states, the number of connections is the number of arrows in the figure, the number of full connections is the total number of connections, the number of states in the sub-state machine 1 is 2, the number of states in the sub-state machine 2 is 3, the number of states in the serial state machine shown in fig. 4 is 7, the number of full connections corresponding to the state diagram in the serial state machine shown in fig. 4 is 24, the number of full connections of the sub-state machine 1 shown in fig. 5 is 2, the number of full connections of the sub-state machine 2 is 4, the sum of the number of full connections of the two sub-state machines is 6, the number of full connections is changed from 24 to 6, and it can be seen that the number of states and the number of full connections corresponding to the state diagram are both greatly reduced. It can be seen that the result states of the two parallel sub-state machines run are consistent with the result of the serial state machine, but the number of states in the sub-state machines and the number of full connections of the corresponding state diagram are both greatly reduced, thereby facilitating maintenance.
Fig. 6 is a schematic structural diagram of an embodiment of a state machine processing apparatus according to an embodiment of the present invention, and as shown in fig. 6, the apparatus of this embodiment may include: the device comprises a determining module 11, a classifying module 12, a first processing module 13 and an operating module 14, wherein the determining module 11 is used for determining N states in a state machine, and N is a positive integer.
The classification module 12 is configured to classify states that can run in parallel among the N states according to the service logic corresponding to the state machine.
The first processing module 13 is configured to establish a state of each class as a sub-state machine, where each sub-state machine includes at least two states and an event determined according to the service logic.
The running module 14 is configured to run all the sub-state machines in parallel, and combine the running results of all the sub-state machines to obtain the running result of the state machine.
Optionally, the first processing module 13 is configured to:
if the number of states included in one type of state is 1, the initial state of the sub-state machine corresponding to the state number of 1 in the normal state is added when the sub-state machine is established.
The apparatus of this embodiment may be used to implement the technical solution of the method embodiment shown in fig. 1, and the implementation principle thereof is similar, which is not described herein again.
Compared with the serial state machine, the state number in the sub-state machine and the full connection number of the corresponding state diagram are greatly reduced, the states and events of the state machine which need to be maintained are reduced, and therefore maintenance is facilitated.
Fig. 7 is a schematic structural diagram of an embodiment of a state machine processing device according to an embodiment of the present invention, and as shown in fig. 7, the device of this embodiment may further include, on the basis of the device shown in fig. 6: a second processing module 15, configured to add a stack in the state machine, and add a sub-stack in each sub-state machine, where the stack and the sub-stack meet a first-in-first-out rule;
and when the state is migrated, the migrated state is stacked and stored.
Further, the second processing module 15 is further configured to:
when state rollback is carried out, firstly popping the state of the stack which is put into the stack later until the bottom of the stack to obtain all the states in the stack;
and firstly popping the state of the sub-stack which is then pushed into the stack until the stack bottom to obtain all the states in the sub-stack.
The apparatus of this embodiment may be used to implement the technical solution of the method embodiment shown in fig. 3, and the implementation principle thereof is similar, which is not described herein again.
The state machine processing apparatus provided in this embodiment adds the stack in the state machine, adds the sub-stack in each sub-state machine, and the stack and the sub-stack satisfy the rule of first in then out, when carrying out state migration, stack the state after migration and store, when carrying out state rollback, stack the state after stacking in the stack first out, until the bottom of the stack, obtain all states in the stack, stack the state after stacking in the sub-stack first out, until the bottom of the stack, obtain all states in the sub-stack. Therefore, the rollback of the state can be realized, the historical state can be conveniently tracked, and the rollback of the business logic is realized when the business logic is wrong. And meanwhile, the system has the functions of combining and rolling back, and can flexibly provide complex service logic functions.
Fig. 8 is a schematic structural diagram of an embodiment of a state machine processing device according to an embodiment of the present invention, and as shown in fig. 8, the state machine processing device of this embodiment may include: a memory 201 and a processor 202,
a memory 201 for storing program instructions, which may be a flash (flash memory).
A processor 202 for calling and executing program instructions in the memory to implement the steps of the method for state machine processing shown in fig. 1 or fig. 3. Reference may be made in particular to the description relating to the preceding method embodiment.
The state machine processing apparatus of the present embodiment may further include an input/output interface 203. The input/output interface 203 may include a separate output interface and input interface, or may be an integrated interface that integrates input and output. The output interface is used for outputting data, the input interface is used for acquiring input data, the output data is a general name output in the method embodiment, and the input data is a general name input in the method embodiment.
An embodiment of the present invention further provides a readable storage medium, in which a computer program is stored, and when at least one processor of the state machine processing apparatus executes the computer program, the state machine processing apparatus executes the state machine processing method according to the first aspect.
An embodiment of the present invention also provides a program product including a computer program, where the computer program is stored in a readable storage medium. The computer program may be read from a readable storage medium by at least one processor of the state machine processing apparatus, execution of which by the at least one processor causes the state machine processing apparatus to carry out the state machine processing method of the first aspect.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, a module or a unit may be divided into only one logical function, and may be implemented in other ways, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
The integrated unit implemented in the form of a software functional unit may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) or a processor to execute some steps of the methods according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
In the above embodiments of the apparatus, it is understood that the Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the present application may be embodied directly in a hardware processor, or in a combination of the hardware and software modules in the processor.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (8)

1. A state machine processing method, comprising:
determining N states in a state machine, wherein N is a positive integer;
classifying states which can run in parallel in the N states according to the service logic corresponding to the state machine;
establishing each type of state into a sub-state machine, wherein each sub-state machine comprises at least two states and events determined according to the business logic;
running all the sub-state machines in parallel, and combining the running results of all the sub-state machines to obtain the running result of the state machine;
the establishing of the state of each class into a sub-state machine comprises:
if the number of states included in one type of state is 1, the initial state of the sub-state machine corresponding to the state number of 1 in the normal state is added when the sub-state machine is established.
2. The method of claim 1, further comprising:
adding stacks in the state machines, adding sub-stacks in each sub-state machine, wherein the stacks and the sub-stacks meet a first-in last-out rule;
and when the state is migrated, the migrated state is stacked and stored.
3. The method of claim 2, further comprising:
when state rollback is carried out, firstly popping the state of the stack which is put into the stack later until the bottom of the stack to obtain all the states in the stack;
and firstly popping the state of the sub-stack which is then pushed into the stack until the stack bottom to obtain all the states in the sub-stack.
4. A state machine processing apparatus, comprising:
the determining module is used for determining N states in the state machine, wherein N is a positive integer;
the classification module is used for classifying the states which can run in parallel in the N states according to the business logic corresponding to the state machine;
the first processing module is used for establishing each type of state into a sub-state machine, and each sub-state machine comprises at least two states and events determined according to the service logic;
the operation module is used for operating all the sub-state machines in parallel and combining the operation results of all the sub-state machines to obtain the operation results of the state machines;
the first processing module is configured to:
if the number of states included in one type of state is 1, the initial state of the sub-state machine corresponding to the state number of 1 in the normal state is added when the sub-state machine is established.
5. The apparatus of claim 4, further comprising:
the second processing module is used for adding stacks in the state machines and adding sub-stacks in each sub-state machine, and the stacks and the sub-stacks meet a first-in and last-out rule;
and when the state is migrated, the migrated state is stacked and stored.
6. The apparatus of claim 5, wherein the second processing module is further configured to:
when state rollback is carried out, firstly popping the state of the stack which is put into the stack later until the bottom of the stack to obtain all the states in the stack;
and firstly popping the state of the sub-stack which is then pushed into the stack until the stack bottom to obtain all the states in the sub-stack.
7. A state machine processing apparatus, comprising:
a memory for storing program instructions;
a processor for calling and executing the program instructions in the memory to implement the state machine processing method of any one of claims 1 to 3.
8. A readable storage medium, in which a computer program is stored, wherein when the computer program is executed by at least one processor of a state machine processing apparatus, the state machine processing apparatus performs the state machine processing method according to any one of claims 1 to 3.
CN201811315037.8A 2018-11-06 2018-11-06 State machine processing method and device and readable storage medium Active CN109375965B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811315037.8A CN109375965B (en) 2018-11-06 2018-11-06 State machine processing method and device and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811315037.8A CN109375965B (en) 2018-11-06 2018-11-06 State machine processing method and device and readable storage medium

Publications (2)

Publication Number Publication Date
CN109375965A CN109375965A (en) 2019-02-22
CN109375965B true CN109375965B (en) 2022-04-26

Family

ID=65397450

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811315037.8A Active CN109375965B (en) 2018-11-06 2018-11-06 State machine processing method and device and readable storage medium

Country Status (1)

Country Link
CN (1) CN109375965B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110109618B (en) * 2019-04-24 2022-09-27 珠海妙存科技有限公司 Method for maintaining flash memory operation time sequence
CN113064674B (en) * 2020-01-02 2024-04-16 广东优特云科技有限公司 Method and device for expanding state machine logic, storage medium and electronic device
CN113326083A (en) * 2021-05-28 2021-08-31 阿波罗智联(北京)科技有限公司 State machine processing method, state processing device, electronic equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7447874B1 (en) * 2005-10-18 2008-11-04 Qlogic, Corporation Method and system for designing a flexible hardware state machine
CN104142666A (en) * 2014-07-24 2014-11-12 华南理工大学 Production control device and method for multi-process equipment on basis of state machines
CN107660281A (en) * 2015-05-19 2018-02-02 华为技术有限公司 The system and method for synchronous Distributed Calculation run time

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7543200B2 (en) * 2005-02-17 2009-06-02 Advantest Corporation Method and system for scheduling tests in a parallel test system
CN101309254A (en) * 2007-05-17 2008-11-19 上海宇梦通信科技有限公司 Device and method for controlling multiple function of communication apparatus by related parallel state machine
CN102467414B (en) * 2010-11-19 2015-03-18 阿里巴巴集团控股有限公司 State machine control method, device and state machine system
CN104572457B (en) * 2014-12-30 2017-07-14 北京工业大学 A kind of method transformed the non-universal finite state machine containing special transfer process
CN106548261A (en) * 2015-09-21 2017-03-29 阿里巴巴集团控股有限公司 A kind of Business Process Control method, device and electronic equipment
EP3244340A1 (en) * 2016-05-09 2017-11-15 Gemalto Sa Method for securely running an application

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7447874B1 (en) * 2005-10-18 2008-11-04 Qlogic, Corporation Method and system for designing a flexible hardware state machine
CN104142666A (en) * 2014-07-24 2014-11-12 华南理工大学 Production control device and method for multi-process equipment on basis of state machines
CN107660281A (en) * 2015-05-19 2018-02-02 华为技术有限公司 The system and method for synchronous Distributed Calculation run time

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
模拟经营游戏中智能决策系统的研究与实现;鲍方;《中国优秀博硕士学位论文全文数据库(硕士)信息科技辑》;20140915(第09期);I138-771 *

Also Published As

Publication number Publication date
CN109375965A (en) 2019-02-22

Similar Documents

Publication Publication Date Title
CN109375965B (en) State machine processing method and device and readable storage medium
CN103262030B (en) Via dynamic aggregation operation fast and the concurrent priority query of linearization
CN110069495A (en) Date storage method, device and terminal device
US20230026006A1 (en) Convolution computation engine, artificial intelligence chip, and data processing method
EP2854094A1 (en) System and method for a high-performance graph analytics engine
CN102142032B (en) Method and system for reading and writing data of distributed file system
CN109544344B (en) Block chain transaction processing method and equipment based on DAG
WO2023065983A1 (en) Computing apparatus, neural network processing device, chip, and data processing method
CN110708369B (en) File deployment method and device for equipment nodes, scheduling server and storage medium
CN109189327A (en) The compression processing method and device of block chain data
CN110032469A (en) Data processing system and its operating method
CN110764705B (en) Data reading and writing method, device, equipment and storage medium
US20120102496A1 (en) Reconfigurable processor and method for processing a nested loop
CN103136043B (en) The moving method of a kind of asynchronous IO, System and Network node
Hare et al. Practical scalable image analysis and indexing using Hadoop
US8935710B1 (en) Unique event identification
CN103473368A (en) Virtual machine real-time migration method and system based on counting rank ordering
CN110247818A (en) A kind of data monitoring method, device, storage medium and server
CN103593606B (en) Context information management method and system
CN113515547B (en) Out-of-order processing method, device, medium and equipment for multi-association real-time data stream
CN114968422A (en) Method and device for automatically executing contracts based on variable state
US11435981B2 (en) Arithmetic circuit, and neural processing unit and electronic apparatus including the same
CN111464456B (en) Flow control method and device
CN111061576B (en) Method and system for creating entity object
US8104045B1 (en) Universal data forwarding system and method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant