Control flow (also known as flow control) is a term in the field of computer computing, which means that when the program is running, individual instructions (or statements, subroutines) are executed or evaluated. Order. Whether in declarative programming languages or functional programming languages, there are similar concepts.
Basic concepts
In declarative programming languages, flow control instructions refer to instructions that will change the running order of the program, which may be Instructions at different locations, or selecting one of the two (or multi-section) programs to run.
The process control instructions provided by different programming languages will also be different, but they can generally be divided into the following four types:
Continue to run at different positions A block of instructions (unconditional branch instructions).
If a specific condition is true, run an instruction, such as the switch instruction in C language, which is a conditional branch instruction.
Run an instruction several times until a specific condition is established. For example, the for instruction in C language can still be regarded as a conditional branch instruction.
Run a section of instructions located at different locations, but after completion, it will continue to run the original instructions to be run, including subroutines, coroutines and continuations.
Stop the program without running any instructions (unconditional termination).
Lower-level mechanisms such as interrupts and signals in Unix systems can also produce subroutine-like effects, but usually such mechanisms are used to respond to external events or inputs. Program self-modification will also affect the control flow due to its impact on the code, but most of them will not have obvious flow control instructions.
In machine language or assembly language, flow control is achieved by modifying the program counter value. Some CPUs only support conditional branches or unconditional branches (sometimes called jumps).
The above is the detailed content of What does process control mean?. For more information, please follow other related articles on the PHP Chinese website!