In this lab, students will use the top command to dynamically view, sort, and stop processes.
Outcomes
Practice with managing processes in real time.
Perform the following tasks as student on the serverX
machine. Run lab process101 setup on serverX
to prepare for this exercise.
[student@serverX ~]$lab process101 setup
Open two terminal windows, side by side, to be referred to as left and right. In the right terminal, run the top utility. Size the window to be as tall as possible.
[student@serverX ~]$top
In the left terminal, determine the number of logical CPUs on this virtual machine.
[student@serverX ~]$grep "model name" /proc/cpuinfo | wc -l1
In the left terminal, run a single instance of the process101 executable.
[student@serverX ~]$process101
In the right terminal, observe the top display. Use the single keystrokes l, t, and m to toggle the load, threads, and memory header lines. After observing this behavior, ensure that all headers are displaying.
Note the process ID (PID) for process101. View the CPU percentage for the process, which is expected to hover around 25% or 30%.
View the load averages. On a single-CPU virtual machine, for example, the one-minute load average is currently less than a value of 1. The value observed may be affected by resource contention from another virtual machine or the virtual host.
In the left terminal, run a second instance of process101.
[student@serverX ~]$process101
In top, note the process ID (PID) for the second process101. View the CPU percentage for the process, also expected to hover around 25% or 30%.
View the one-minute load average again, which may still be less than 1. Wait up to one minute to allow the calculation to adjust to the new workload.
In the left terminal, run a third instance of process101.
[student@serverX ~]$process101
In top, note the process ID (PID) for the third process101. View the CPU percentage for the process, again expected to hover around 25% or 30%.
View the one-minute load average again, which now is expected to be above 1. Wait up to one minute to allow the calculation to again adjust to the new workload.
Optional: If this virtual machine has more than one logical CPU, slowly start additional process101 instances until the one-minute load average equals or exceeds the number of logical CPUs. Divide the load average value by the number of CPUs to determine the estimated load average per CPU.
When finished observing the load average values, terminate each of the process101 processes from within top.
Press k. Observe the prompt below the headers and above the columns.
Type the PID for one of the process101 instances. Press Enter.
Press Enter again to use the default
SIGTERM signal 15.
Confirm that the selected process is no longer observed in top.
If the PID still remains, repeat these terminating steps,
substituting SIGKILL signal 9 when prompted.
Repeat the previous step for each remaining process101 instance. Confirm that no process101 instances remain in top.
In the right window, press q to exit top. Close extra terminal windows.