State (computer science)
In information technology and computer science, a system is described as stateful if it is designed to remember preceding events or user interactions;[1] the remembered information is called the state of the system.
The set of states a system can occupy is known as its
The output of a digital circuit or deterministic computer program at any time is completely determined by its current inputs and its state.[2]
Digital logic circuit state
Since each binary memory element, such as a flip-flop, has only two possible states, one or zero, and there is a finite number of memory elements, a digital circuit has only a certain finite number of possible states. If N is the number of binary memory elements in the circuit, the maximum number of states a circuit can have is 2N.
Program state
Similarly, a computer program stores data in variables, which represent storage locations in the computer's memory. The contents of these memory locations, at any given point in the program's execution, are called the program's state.[5][6][7]
A more specialized definition of state is used for computer programs that operate serially or sequentially on
In declarative programming languages, the program describes the desired results and doesn't specify changes to the state directly.
In
Finite state machines
The output of a sequential circuit or computer program at any time is completely determined by its current inputs and current state. Since each
Examples
An example of an everyday device that has a state is a television set. To change the channel of a TV, the user usually presses a channel up or channel down button on the remote control, which sends a coded message to the set. In order to calculate the new channel that the user desires, the digital tuner in the television must have stored in it the number of the current channel it is on. It then adds one or subtracts one from this number to get the number for the new channel, and adjusts the TV to receive that channel. This new number is then stored as the current channel. Similarly, the television also stores a number that controls the level of volume produced by the speaker. Pressing the volume up or volume down buttons increments or decrements this number, setting a new level of volume. Both the current channel and current volume numbers are part of the TV's state. They are stored in non-volatile memory, which preserves the information when the TV is turned off, so when it is turned on again the TV will return to its previous station and volume level.
As another example, the state of a
See also
- Data (computing)
References
- ^ "What is stateless? - Definition from WhatIs.com". techtarget.com.
- ISBN 978-0123704979.
- ISBN 978-0521882675.
- ISBN 978-8120327856. Retrieved 7 December 2012.
page 46
- ISBN 978-0849326912.
- ISBN 978-0387952062.
- ISBN 978-0132713603.