CN113986403A - State machine operation method and device, computer equipment and storage medium - Google Patents

State machine operation method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN113986403A
CN113986403A CN202111273083.8A CN202111273083A CN113986403A CN 113986403 A CN113986403 A CN 113986403A CN 202111273083 A CN202111273083 A CN 202111273083A CN 113986403 A CN113986403 A CN 113986403A
Authority
CN
China
Prior art keywords
state
state machine
input
preset position
response
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.)
Withdrawn
Application number
CN202111273083.8A
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.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN202111273083.8A priority Critical patent/CN113986403A/en
Publication of CN113986403A publication Critical patent/CN113986403A/en
Withdrawn legal-status Critical Current

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/4482Procedural

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application relates to a state machine operation method, a state machine operation device, a computer device and a storage medium. The method comprises the following steps: in response to the detection that the input state of the state machine is changed, canceling the state machine to execute logic operation, and storing the changed input state to a preset position; in response to detecting a read operation of an external module on a state machine, performing a logical operation based on data in a current preset position by using the state machine to generate an output state; returning the output state to the external module. The scheme of the invention realizes that the state machine is driven to operate by reading operation, achieves the purpose of delaying logic operation, avoids the problems of repeatedly executing calculation logic and notifying back when the input state is frequently changed, reduces unnecessary logic operation and improves the operating efficiency of the state machine.

Description

State machine operation method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for operating a state machine, a computer device, and a storage medium.
Background
In software systems, a state machine is a common programming model. In a conventional state machine programming model, an event occurs or an input state is changed, which causes the state machine to operate, execute certain computation logic, and obtain a certain output state, and other modules concerned about the output state generally subscribe to the state so as to be notified in time when the change occurs, thereby taking the next action.
Currently, a conventional state machine operates in a mode that operates when an input state changes, and generates a corresponding output state. However, in some scenarios, the input state may change many times in a short time, and the module concerned about the output state only wants to actively acquire the latest state value at a specific time. Under such a scenario, reusing the conventional subscription mode may cause unnecessary computation logic and notification callback, which may cause serious impact on the operating efficiency of the software system, especially in the case of more input states and less output states, which is multiplied.
Disclosure of Invention
In view of the above, it is necessary to provide a state machine operating method, apparatus, computer device and storage medium for solving the above technical problems.
According to a first aspect of the present invention, there is provided a state machine operation method, the method comprising: in response to the detection that the input state of the state machine is changed, canceling the state machine to execute logic operation, and storing the changed input state to a preset position;
in response to detecting a read operation of an external module on a state machine, performing a logical operation based on data in a current preset position by using the state machine to generate an output state;
returning the output state to the external module.
In some optional embodiments, the preset position is used to store a plurality of input states.
In some optional embodiments, in response to detecting that the input state of the state machine is changed, canceling the state machine from performing the logic operation, and storing the changed input state to a preset location includes:
in response to detecting that the input state is changed, acquiring the current input state;
judging whether an unused storage space exists in the preset position or not;
in response to that an unused storage space exists in the preset position, writing the current input state into the unused storage space in the preset position;
and in response to that the unused storage space does not exist in the preset position, writing the changed input state into the used storage space in the preset position in an overlaying mode.
In some optional embodiments, in response to detecting a read operation of the state machine by the external module, performing a logical operation based on data in the current preset position with the state machine to generate an output state includes:
reading the last written input state from the preset position in response to detecting the reading operation of the external input module on the state machine;
creating a temporary context and copying the input state written last time into the temporary context;
performing, by the state machine, a logical operation with the last written input state as an input to generate an output state corresponding to the last written input state, and writing the output state in a temporary context.
In some optional embodiments, the step of returning the output state to the external module comprises:
data is read from the temporary context and the read data is sent to the external module.
In some optional embodiments, the method further comprises:
and destroying the temporary context in response to the external input module acquiring the data in the temporary context.
In some optional embodiments, the state machine performs logical operations by a central processing unit.
According to a second aspect of the present invention, there is provided a state machine operating device, the device including:
the first detection module is configured to respond to the detection that the input state of the state machine is changed, cancel the execution of the logic operation of the state machine and store the changed input state to a preset position;
a second detection module configured to perform a logical operation based on data in a current preset position with the state machine to generate an output state in response to detecting a read operation of an external module on the state machine;
a state return module configured to return the output state to the external module.
In a third aspect of the present invention, there is also provided a computer device, including:
at least one processor; and
the memory stores a computer program operable on the processor, and the processor executes the state machine operation method when executing the computer program.
In a fourth aspect of the present invention, a computer-readable storage medium is further provided, where a computer program is stored, and the computer program is characterized in that when being executed by a processor, the computer program performs the foregoing state machine operation method.
According to the state machine operation method, the state machine operation device, the computer equipment and the storage medium, the state machine is driven to operate through reading operation, the purpose of delaying logic operation is achieved, the problems of repeatedly executing calculation logic and informing back when the input state is frequently changed are avoided, unnecessary logic operation is reduced, and the operation efficiency of the state machine is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other embodiments can be obtained by using the drawings without creative efforts.
FIG. 1A is a flow chart illustrating a method 100 for operating a state machine according to an embodiment of the invention;
FIG. 1B is a diagram of a state machine according to an embodiment of the present invention;
FIG. 2 is a flow chart illustrating a method 200 for operating a state machine according to another embodiment of the present invention;
fig. 3 is a schematic structural diagram of a state machine operating apparatus 300 according to another embodiment of the present invention;
fig. 4 is an internal structural view of a computer device according to another embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the following embodiments of the present invention are described in further detail with reference to the accompanying drawings.
It should be noted that all expressions using "first" and "second" in the embodiments of the present invention are used for distinguishing two entities with the same name but different names or different parameters, and it should be noted that "first" and "second" are merely for convenience of description and should not be construed as limitations of the embodiments of the present invention, and they are not described in any more detail in the following embodiments.
Referring to fig. 1A, fig. 1A is a schematic flow chart illustrating a method 100 for operating a state machine according to an embodiment of the present invention, which includes the following steps:
step 101, in response to detecting that the input state of the state machine is changed, canceling the state machine to execute logic operation, and storing the changed input state to a preset position;
in this embodiment, the state machine may be any common programming mode, and the input state of the state machine may be one input state or one input state formed by a combination of a plurality of states. In some optional embodiments, the state machine performs logical operations by a central processor. Optionally, the preset position is used for storing a plurality of input states, for example, assuming that the input state includes one input, the preset position may be set to store five input states, and the above number is only used for illustration and should not be construed as a limitation to the method of the present invention.
Step 102, in response to detecting a reading operation of an external module on a state machine, performing a logic operation by using the state machine based on data in a current preset position to generate an output state;
in this implementation, the external module may be a module that communicates with the state machine, the external module being able to invoke and use the output state of the state machine. In the implementation process, the output state of the state machine may be one, or may be a group of output states consisting of a plurality of output states. For example, referring to fig. 1B, a set of input states of the state machine includes input 1, input 2 … …, input n, and a set of output states consisting of output 1 and output 2 is obtained by performing logic operation through input 1 to input n.
Step 103, returning the output state to the external module.
In this embodiment, the output state is returned to the external module as a result of the response to the read operation, so that the external module can directly use the output state generated by the state machine.
According to the state machine operation method, the input state change of the state machine is detected, the execution of logic operation is cancelled when the input state changes, the reading operation of an external module on the state machine is detected, the state machine is read and utilized to execute the logic operation based on the current input state to generate the output state, and finally the output state is returned to the external module, so that the state machine is driven to operate through the reading operation, the purpose of delaying the logic operation is achieved, the problems that the calculation logic is repeatedly executed and the notification is returned when the input state is frequently changed are solved, unnecessary logic operation is reduced, and the operation efficiency of the state machine is improved.
In another embodiment, please refer to fig. 2, fig. 2 is a flowchart illustrating a method 200 for operating a state machine according to another embodiment of the present invention, which includes the following steps:
step 201, in response to detecting that the input state is changed, acquiring a current input state;
in this embodiment, a change in the input state indicates that the whole or part of the input parameters are changed, for example, in an input state composed of a plurality of inputs, a parameter of a certain input is changed or all the inputs are changed.
Step 202, judging whether an unused storage space exists in the preset position;
step 203, in response to that an unused storage space exists in the preset position, writing the current input state into the unused storage space in the preset position;
in this embodiment, the unused storage space refers to a space in the storage space where no data is stored, and the corresponding used storage space refers to a space in the storage space where data is stored.
And 204, in response to that the unused storage space does not exist in the preset position, writing the changed input state into the used storage space in the preset position in an overlapping manner.
In this embodiment, writing data in an overwriting manner means replacing data in a target location with data to be written, so as to overwrite original data with the target data, when a preset location (also referred to as a preset storage location) can store a plurality of input states, overwriting may be performed by using a first-in first-out principle, for example, assuming that the preset storage location can store three sets of input states, if an unwritten space exists in the preset storage location, data is preferentially written into such a space, and when data is written, and when a fourth change of the input state is detected, the input state at this time is written into a storage location corresponding to the first state change, thereby realizing maximum storage of the latest output state
Step 205, in response to detecting a read operation of the state machine by the external input module, reading the last written input state from the preset position;
step 206, creating a temporary context and copying the input state written for the last time into the temporary context;
step 207, performing a logical operation by the state machine with the last written input state as input to generate an output state corresponding to the last written input state, and writing the output state in a temporary context.
According to the state machine operation method, the input state in the preset position is updated circularly in a covering mode, the logic operation is not executed when the input state changes, the logic operation is carried out according to the requirement of an external module, the logic operation is carried out in a delayed mode, a large amount of intermediate data are prevented from being stored, unnecessary performance loss is reduced, and the use efficiency of the state machine and the system operation efficiency are improved.
Optionally, with continuing reference to fig. 2, on the basis of the foregoing embodiment, the method for operating a state machine further includes:
step 208, reading data from the temporary context and sending the read data to the external module.
Optionally, with reference to fig. 2, on the basis of the foregoing embodiment, the state operation method further includes:
step S209, in response to the external input module acquiring the data in the temporary context, destroy the temporary context.
According to the state machine operation method, the temporary context is used for temporarily storing the input state and the generated output state used by the state machine for executing the logic operation, and the external module is cleaned in time after acquiring the data, so that invalid data is prevented from being stored.
Referring to fig. 3, fig. 3 is a schematic structural diagram of a state machine operating device 300 according to another embodiment of the present invention, specifically, the device includes:
the first detection module 301 is configured to, in response to detecting that the input state of the state machine is changed, cancel the state machine from executing the logical operation, and store the changed input state to a preset position;
a second detection module 301 configured to, in response to detecting a read operation of an external module on a state machine, perform a logical operation with the state machine based on data in a current preset position to generate an output state;
a state return module 303 configured to return the output state to the external module.
According to the state machine operation device, the input state change of the state machine is detected, the execution of logic operation is cancelled when the input state changes, the reading operation of an external module on the state machine is detected, the state machine is used for executing the logic operation based on the current input state to generate an output state when the reading operation is needed, and finally the output state is returned to the external module, so that the state machine is driven to operate through the reading operation, the purpose of delaying the logic operation is achieved, the problems that the calculation logic is repeatedly executed and the notification is returned when the input state is frequently changed are solved, unnecessary logic operation is reduced, and the operation efficiency of the state machine is improved.
In some optional embodiments, the preset position is used to store a plurality of input states.
In some optional embodiments, the first detection module 101 is further configured to:
in response to detecting that the input state is changed, acquiring the current input state;
judging whether an unused storage space exists in the preset position or not;
in response to that an unused storage space exists in the preset position, writing the current input state into the unused storage space in the preset position;
and in response to that the unused storage space does not exist in the preset position, writing the changed input state into the used storage space in the preset position in an overlaying mode.
In some optional embodiments, the second detection module 102 is further configured to:
reading the last written input state from the preset position in response to detecting the reading operation of the external input module on the state machine;
creating a temporary context and copying the input state written last time into the temporary context;
performing, by the state machine, a logical operation with the last written input state as an input to generate an output state corresponding to the last written input state, and writing the output state in a temporary context.
In some optional examples, the status return module 303 is further configured to:
data is read from the temporary context and the read data is sent to the external module.
In some optional embodiments, the apparatus further comprises a destruction module configured to:
and destroying the temporary context in response to the external input module acquiring the data in the temporary context.
In some optional embodiments, the state machine performs logical operations by a central processing unit.
It should be noted that, for the specific limitations of the state machine operation device, reference may be made to the limitations of the method above, and details thereof are not repeated herein. The modules in the state machine running device can be wholly or partially realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In another embodiment, please refer to fig. 4, which provides a computer device, which may be a server, and its internal structure diagram may be as shown in fig. 4. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing data. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement the above-mentioned method for operating a state machine, and specifically the method includes:
in response to the detection that the input state of the state machine is changed, canceling the state machine to execute logic operation, and storing the changed input state to a preset position;
in response to detecting a read operation of an external module on a state machine, performing a logical operation based on data in a current preset position by using the state machine to generate an output state;
returning the output state to the external module.
In some optional embodiments, the preset position is used to store a plurality of input states.
In some optional embodiments, in response to detecting that the input state of the state machine is changed, canceling the state machine from performing the logic operation, and storing the changed input state to a preset location includes:
in response to detecting that the input state is changed, acquiring the current input state;
judging whether an unused storage space exists in the preset position or not;
in response to that an unused storage space exists in the preset position, writing the current input state into the unused storage space in the preset position;
and in response to that the unused storage space does not exist in the preset position, writing the changed input state into the used storage space in the preset position in an overlaying mode.
In some optional embodiments, in response to detecting a read operation of the state machine by the external module, performing a logical operation based on data in the current preset position with the state machine to generate an output state includes:
reading the last written input state from the preset position in response to detecting the reading operation of the external input module on the state machine;
creating a temporary context and copying the last written input state into the temporary context;
performing, by the state machine, a logical operation with the last written input state as an input to generate an output state corresponding to the last written input state, and writing the output state in a temporary context.
In some optional embodiments, the step of returning the output state to the external module comprises:
data is read from the temporary context and the read data is sent to the external module.
In some optional embodiments, the method further comprises:
and destroying the temporary context in response to the external input module acquiring the data in the temporary context.
According to a further aspect of the present invention, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the method of operating a state machine described above, the method comprising:
in response to the detection that the input state of the state machine is changed, canceling the state machine to execute logic operation, and storing the changed input state to a preset position;
in response to detecting a read operation of an external module on a state machine, performing a logical operation based on data in a current preset position by using the state machine to generate an output state;
returning the output state to the external module.
In some optional embodiments, the preset position is used to store a plurality of input states.
In some optional embodiments, in response to detecting that the input state of the state machine is changed, canceling the state machine from performing the logic operation, and storing the changed input state to a preset location includes:
in response to detecting that the input state is changed, acquiring the current input state;
judging whether an unused storage space exists in the preset position or not;
in response to that an unused storage space exists in the preset position, writing the current input state into the unused storage space in the preset position;
and in response to that the unused storage space does not exist in the preset position, writing the changed input state into the used storage space in the preset position in an overlaying mode.
In some optional embodiments, in response to detecting a read operation of the state machine by the external module, performing a logical operation based on data in the current preset position with the state machine to generate an output state includes:
reading the last written input state from the preset position in response to detecting the reading operation of the external input module on the state machine;
creating a temporary context and copying the input state written last time into the temporary context;
performing, by the state machine, a logical operation with the last written input state as an input to generate an output state corresponding to the last written input state, and writing the output state in a temporary context.
In some optional embodiments, the step of returning the output state to the external module comprises:
data is read from the temporary context and the read data is sent to the external module.
In some optional embodiments, the method further comprises:
and destroying the temporary context in response to the external input module acquiring the data in the temporary context.
Finally, it should be noted that, as one of ordinary skill in the art can appreciate that all or part of the processes in the methods of the above embodiments can be implemented by a computer program to instruct related hardware, and the programs of the methods described in the present application can be stored in a computer readable storage medium, and when executed, the programs can include the processes of the embodiments of the methods described above. The storage medium of the program may be a magnetic disk, an optical disk, a Read Only Memory (ROM), a Random Access Memory (RAM), or the like. The embodiments of the computer program may achieve the same or similar effects as any of the above-described method embodiments.
Furthermore, the methods disclosed according to embodiments of the present invention may also be implemented as a computer program executed by a processor, which may be stored in a computer-readable storage medium. Which when executed by a processor performs the above-described functions defined in the methods disclosed in embodiments of the invention.
Further, the above method steps and system elements may also be implemented using a controller and a computer readable storage medium for storing a computer program for causing the controller to implement the functions of the above steps or elements.
Further, it should be appreciated that the computer-readable storage media (e.g., memory) herein can be either volatile memory or nonvolatile memory, or can include both volatile and nonvolatile memory. By way of example, and not limitation, nonvolatile memory can include Read Only Memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM), which can act as external cache memory. By way of example and not limitation, RAM is available in a variety of forms such as synchronous RAM (DRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The storage devices of the disclosed aspects are intended to comprise, without being limited to, these and other suitable types of memory.
Those of skill would further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the disclosure herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as software or hardware depends upon the particular application and design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the disclosed embodiments of the present invention.
The various illustrative logical blocks, modules, and circuits described in connection with the disclosure herein may be implemented or performed with the following components designed to perform the functions herein: a general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination of these components. A general purpose processor may be a microprocessor, but in the alternative, the processor may be any conventional processor, controller, microcontroller, or state machine. A processor may also be implemented as a combination of computing devices, e.g., a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a DSP, and/or any other such configuration.
The steps of a method or algorithm described in connection with the disclosure herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. In the alternative, the storage medium may be integral to the processor. The processor and the storage medium may reside in an ASIC. The ASIC may reside in a user terminal. In the alternative, the processor and the storage medium may reside as discrete components in a user terminal.
In one or more exemplary designs, the functions may be implemented in hardware, software, firmware, or any combination thereof. If implemented in software, the functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium. Computer-readable media includes both computer storage media and communication media including any medium that facilitates transfer of a computer program from one place to another. A storage media may be any available media that can be accessed by a general purpose or special purpose computer. By way of example, and not limitation, such computer-readable media can comprise RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a general-purpose or special-purpose computer, or a general-purpose or special-purpose processor. Also, any connection is properly termed a computer-readable medium. For example, if the software is transmitted from a website, server, or other remote source using a coaxial cable, fiber optic cable, twisted pair, Digital Subscriber Line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of medium. Disk and disc, as used herein, includes Compact Disc (CD), laser disc, optical disc, Digital Versatile Disc (DVD), floppy disk, blu-ray disc where disks usually reproduce data magnetically, while discs reproduce data optically with lasers. Combinations of the above should also be included within the scope of computer-readable media.
The foregoing is an exemplary embodiment of the present disclosure, but it should be noted that various changes and modifications could be made herein without departing from the scope of the present disclosure as defined by the appended claims. The functions, steps and/or actions of the method claims in accordance with the disclosed embodiments described herein need not be performed in any particular order. Furthermore, although elements of the disclosed embodiments of the invention may be described or claimed in the singular, the plural is contemplated unless limitation to the singular is explicitly stated.
It should be understood that, as used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly supports the exception. It should also be understood that "and/or" as used herein is meant to include any and all possible combinations of one or more of the associated listed items.
The numbers of the embodiments disclosed in the embodiments of the present invention are merely for description, and do not represent the merits of the embodiments.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
Those of ordinary skill in the art will understand that: the discussion of any embodiment above is meant to be exemplary only, and is not intended to intimate that the scope of the disclosure, including the claims, of embodiments of the invention is limited to these examples; within the idea of an embodiment of the invention, also technical features in the above embodiment or in different embodiments may be combined and there are many other variations of the different aspects of the embodiments of the invention as described above, which are not provided in detail for the sake of brevity. Therefore, any omissions, modifications, substitutions, improvements, and the like that may be made without departing from the spirit and principles of the embodiments of the present invention are intended to be included within the scope of the embodiments of the present invention.

Claims (10)

1. A method of operating a state machine, the method comprising:
in response to the detection that the input state of the state machine is changed, canceling the state machine to execute logic operation, and storing the changed input state to a preset position;
in response to detecting a read operation of an external module on a state machine, performing a logical operation based on data in a current preset position by using the state machine to generate an output state;
returning the output state to the external module.
2. The method according to claim 1, wherein the predetermined position is used to store a plurality of input states.
3. The method according to claim 2, wherein the step of canceling the logic operation performed by the state machine and storing the changed input state to a predetermined location in response to detecting the change of the input state of the state machine comprises:
in response to detecting that the input state is changed, acquiring the current input state;
judging whether an unused storage space exists in the preset position or not;
in response to that an unused storage space exists in the preset position, writing the current input state into the unused storage space in the preset position;
and in response to that the unused storage space does not exist in the preset position, writing the changed input state into the used storage space in the preset position in an overlaying mode.
4. The method according to claim 1, wherein the step of performing a logic operation based on data in a current preset position by using the state machine to generate an output state in response to detecting a read operation of the state machine by an external module comprises:
reading the last written input state from the preset position in response to detecting the reading operation of the external input module on the state machine;
creating a temporary context and copying the input state written last time into the temporary context;
performing, by the state machine, a logical operation with the last written input state as an input to generate an output state corresponding to the last written input state, and writing the output state in a temporary context.
5. The state machine operation method of claim 4, wherein the step of returning the output state to the external module comprises:
data is read from the temporary context and the read data is sent to the external module.
6. The method of operating a state machine according to claim 4, further comprising:
and destroying the temporary context in response to the external input module acquiring the data in the temporary context.
7. The method according to any one of claims 1 to 6, wherein the state machine performs logical operations by a central processing unit.
8. A state machine operating device, characterized by comprising:
the first detection module is configured to respond to the detection that the input state of the state machine is changed, cancel the execution of the logic operation of the state machine and store the changed input state to a preset position;
a second detection module configured to perform a logical operation based on data in a current preset position with the state machine to generate an output state in response to detecting a read operation of an external module on the state machine;
a state return module configured to return the output state to the external module.
9. A computer device, comprising:
at least one processor; and
a memory storing a computer program operable on the processor, the processor executing the program to perform the state machine operation method according to any one of claims 1 to 7.
10. A computer-readable storage medium, in which a computer program is stored, which, when being executed by a processor, carries out a method for operating a state machine according to any one of claims 1 to 7.
CN202111273083.8A 2021-10-29 2021-10-29 State machine operation method and device, computer equipment and storage medium Withdrawn CN113986403A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111273083.8A CN113986403A (en) 2021-10-29 2021-10-29 State machine operation method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111273083.8A CN113986403A (en) 2021-10-29 2021-10-29 State machine operation method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113986403A true CN113986403A (en) 2022-01-28

Family

ID=79744477

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111273083.8A Withdrawn CN113986403A (en) 2021-10-29 2021-10-29 State machine operation method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113986403A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115348167A (en) * 2022-08-31 2022-11-15 杭州云合智网技术有限公司 Method and device for realizing RowStatus state machine

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115348167A (en) * 2022-08-31 2022-11-15 杭州云合智网技术有限公司 Method and device for realizing RowStatus state machine
CN115348167B (en) * 2022-08-31 2024-05-07 云合智网(上海)技术有限公司 RowStatus state machine implementation method and RowStatus state machine implementation device

Similar Documents

Publication Publication Date Title
US20060112215A1 (en) Apparatus and method for processing data of flash memory
CN110222107B (en) Data transmission method and related equipment
CN110929883A (en) Method and device for supporting FPGA (field programmable gate array) training in TensorFlow
CN113986403A (en) State machine operation method and device, computer equipment and storage medium
CN110851207B (en) State transition management method and device, electronic equipment and storage medium
CN111309264B (en) Method, system, device and medium for making directory quota compatible with snapshot
CN114979260B (en) Protocol-based communication method and device, electronic equipment and storage medium
CN110780855A (en) Method, device and system for uniformly managing and controlling interface
CN110018910B (en) Method, storage medium, device and system for realizing registration template of event bus
CN114003203B (en) Maintenance method, device and equipment for activity counting variable and readable medium
CN115827049A (en) Configuration-based cache switching method, electronic equipment and storage medium
CN111222156B (en) Method, device and equipment for operating system safety protection and readable medium
CN111158565B (en) Page turning prompting method and device, electronic equipment and storage medium
CN109542598B (en) Timed task management method and device
CN109150993B (en) Method for obtaining network request tangent plane, terminal device and storage medium
CN111061571A (en) Event processing method and device and electronic equipment
CN111008125B (en) Automatic platform cycle test control method and device
JP2002032357A (en) In-place memory management for fft
CN111090432A (en) Interface processing method and device and electronic equipment
CN111522783B (en) Data synchronization method, device, electronic equipment and computer readable storage medium
CN113448513B (en) Data reading and writing method and device of redundant storage system
CN113259265B (en) Message processing method and device, electronic equipment and storage medium
CN110674106B (en) Storage method, device and equipment of policy data and computer readable storage medium
CN114036171B (en) Application data management method, device, computer equipment and storage medium
CN111722801B (en) Label-based storage volume attribute management method, device, equipment and medium

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
WW01 Invention patent application withdrawn after publication

Application publication date: 20220128

WW01 Invention patent application withdrawn after publication