#!/bin/sh
# DF-2687 round-2 experiment build+run (inside the guest; unprivileged parts
# run as the unprivileged user, the vmstat sampler as root).
#
#  pin:      ./pin.sh            (requires root for the sampler)
set -e
cc -O2 -Wall -o /tmp/df2687x df2687x.c
echo "BUILD OK"
if [ "$(id -u)" = "0" ]; then
	g() { vmstat -m | awk '$1=="session"{print $2}'; }
	B=$(g)
	su -m maxx -c "/tmp/df2687x pin 8 6" &
	sleep 3
	M=$(g)
	wait
	A=$(g)
	echo "BEFORE=$B MIDHOLD=$M AFTER=$A"
else
	exec /tmp/df2687x pin 8 6
fi
