System information

82 System Analysis and Tuning Guide
hardware platform). With the global statement it is possible to use the variables
count_jiffies and count_ms also in the probe timer.ms(12345). With +
+ the value of a variable is incremented by 1.
Conditional Statements
There are a number of conditional statements that you can use in SystemTap scripts.
The following are probably most common:
If/Else Statements
They are expressed in the following format:
if (condition) statement1
else statement2
The if statement compares an integer-valued expression to zero. If the condition
expression is non-zero, the first statement is executed. If the condition ex-
pression is zero, the second statement is executed. The else clause ( and ) is
optional. Both and can also be statement blocks.
While Loops
They are expressed in the following format:
while (condition) statement
As long as condition is non-zero, the statement is executed. can also be a
statement block. It must change a value so condition will eventually be zero.
For Loops
They are basically a shortcut for while loops and are expressed in the following
format:
for (initialization ; conditional ; increment ) statement
The expression specified in is used to initialize a counter for the number of
loop iterations and is executed before execution of the loop starts. The execu-
tion of the loop continues until the loop condition is false. (This expression is
checked at the beginning of each loop iteration). The expression specified in
is used to increment the loop counter. It is executed at the end of each loop itera-
tion.
Conditional Operators
The following operators can be used in conditional statements:
==: Is equal to