mirror of
https://github.com/ebrandi/FDD-book.git
synced 2026-12-06 00:23:30 +00:00
Organize companion code and materials by book part: part-01/ Foundations part-02/ Kernel & driver fundamentals part-03/ Character & block devices part-04/ Networking & storage part-05/ Buses & advanced topics part-06/ Debugging & performance part-07/ Real-world drivers appendices/ Supplementary material README.md Overview and build instructions
40 lines
836 B
Bash
Executable file
40 lines
836 B
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# lab23_2_dtrace.sh - Lab 23.2: Measuring the Driver with DTrace
|
|
#
|
|
# Exercises the driver while DTrace counts function entries.
|
|
|
|
set -e
|
|
|
|
if [ "$(id -u)" -ne 0 ]; then
|
|
echo "This script must run as root (for dtrace and kldload)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "=== Lab 23.2: Measuring the Driver with DTrace ==="
|
|
echo
|
|
|
|
MODULE=${1:-./myfirst.ko}
|
|
if ! kldstat | grep -q myfirst; then
|
|
echo "Loading module: $MODULE"
|
|
kldload "$MODULE"
|
|
fi
|
|
|
|
echo
|
|
echo "Starting DTrace count in the background..."
|
|
dtrace -q -n 'fbt::myfirst_*:entry { @[probefunc] = count(); }
|
|
tick-5s { exit(0); }' &
|
|
DT_PID=$!
|
|
|
|
sleep 1
|
|
echo
|
|
echo "Exercising the driver (100 reads)..."
|
|
for i in $(seq 1 100); do
|
|
cat /dev/myfirst0 > /dev/null
|
|
done
|
|
|
|
wait $DT_PID
|
|
echo
|
|
echo "Expected: 100 open, 100 close, 100 read entries."
|
|
echo
|
|
echo "=== End of Lab 23.2 ==="
|