19 Variations in control flow
This chapter covers
- Understanding normal sequencing of statements in C
- Making short and long jumps through code
- Function control flow
- Handling signals
The control flow (see figure 2.1) of program execution describes how the individual statements of the program code are sequenced—that is, which statement is executed after another. Up to now, we have mostly looked at code that lets us deduce this control flow from syntax and a controlling expression. That way, each function can be described using a hierarchical composition of basic blocks. A basic block is a maximum sequence of statements such that once execution starts at the first of these statements, it continues unconditionally until the last, such that all execution of any statement in the sequence starts with the first.
If we suppose that all conditionals and loop statements use {}
compound statements, in a simplified view, such a basic block
- Starts either at the beginning
{
of a compound statement or acase
or jump label - Ends either at the
}
of the corresponding compound statement or at the next- Statement that is the target of a
case
or jump label - Body of a conditional or loop statement
return
statementgoto
statement- Call to some function in a specific set
- Statement that is the target of a