From 1e53a7c0de6f40d8af1019906c1e6fb67b4b3207 Mon Sep 17 00:00:00 2001 From: chb Date: Tue, 28 Aug 2012 11:02:41 +0000 Subject: [PATCH] fail*: only start a client if there is a reasonable amount of free memory git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1578 8c4709b5-6ec9-48aa-a5cd-a96041d1645a --- scripts/client.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/scripts/client.sh b/scripts/client.sh index a470921a..ee502047 100755 --- a/scripts/client.sh +++ b/scripts/client.sh @@ -42,12 +42,19 @@ do done fi - #nice -n 19 ./bochs -q 2>&1 | tee log.$$.txt | fgrep Result - #nice -n 18 ./bochs -q 2>&1 | fgrep Result - nice -n 18 ./fail-client -q >/dev/null 2>&1 - if [ $? -eq 1 ] - then - break + # only start a client if at least 500 MiB is available + FREE_MEM=$(free -m | grep "buffers/cache:" | awk '{print $4}') + if [ $FREE_MEM -lt "500" ]; then + # waiting for free memory. sleep 1-60s and retry. + sleep $(($RANDOM / (32768 / 60) + 1)) + else + #nice -n 19 ./bochs -q 2>&1 | tee log.$$.txt | fgrep Result + #nice -n 18 ./bochs -q 2>&1 | fgrep Result + nice -n 18 ./fail-client -q >/dev/null 2>&1 + if [ $? -eq 1 ] + then + break + fi fi done echo DONE