CSE Roadmap

Core tier · about 3 hours · 6 parts

Part 6 of 6 · 2 min read

Exercises

Easy

Easy 1: Pick the tool (20 minutes)

Name the command for: open files of process 500, threads of process 500, free disk space.

Done when: ls -l /proc/500/fd or lsof -p 500, ps -o nlwp -p 500, df -h.

Hint

use the table in section 1.

Easy 2: Convert (20 minutes)

Convert 100 MiB to kB, and 32,588 kB to MiB (one decimal).

Done when: 102,400 kB and 31.8 MiB.

Hint

100 x 1,024.

Easy 3: State letters (20 minutes)

What do S, R, Z and l mean in a ps state column? Check with man ps.

Done when: sleeping, running or runnable, zombie, multi-threaded.

Hint

see the STATE section of man ps.

Medium

Medium 1: Run the worker (45 minutes)

Compile and run the worker. Report VSZ, RSS and NLWP from ps, and compare with the numbers of section 2.

Done when: three numbers close to 121,504, 32,588 and 3, and a sentence on any difference.

Hint

ps -o pid,nlwp,vsz,rss,comm -C worker.

Medium 2: Change the touch (45 minutes)

Change the program to touch 60 MiB. Predict RSS, run it and compare.

Done when: a prediction near 63,000 kB (61,440 plus about 1,900 for code and libraries) and a measured value close to it.

Hint

the touch size is in the memset line.

Medium 3: Load against cores (45 minutes)

A machine with 8 cores shows load averages 2.0, 6.5 and 12.0. Describe what is happening over the last 15 minutes.

Done when: the load rose from 12 (above 8 cores, overloaded) to 6.5 and then 2.0 (well under 8): the problem is going away.

Hint

compare each number with 8.

Hard

Hard 1: A snapshot script (90 minutes)

Write a shell script that prints a dated snapshot of the machine and the five largest processes, and save the output of two runs ten seconds apart. Say what changed.

Done when: a script, two output files and a list of the differences.

Hint

date; uptime; free -m; ps -eo pid,rss,comm --sort=-rss | head -5.

Hard 2: Sum of RSS (90 minutes)

Sum the RSS of all processes with ps and compare with the used column of free. Explain the difference.

Done when: the two numbers, and a reason (shared pages counted many times, kernel memory not counted in RSS).

Hint

ps -eo rss= | awk '{s+=$1} END {print s}'.

Hard 3: Question order (90 minutes)

Write the question order for "the disk is full" and for "the machine feels slow", giving the command at each step and what result sends you to the next.

Done when: two ordered lists with commands and branching results.

Hint

use df -h, df -i, du -x and lsof for the first one.