summaryrefslogtreecommitdiff
path: root/sys/src/9/port/pgrp.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-05-20 23:55:38 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2013-05-20 23:55:38 +0200
commit18b8ae56e8f944df3c9078afd294aad03b204557 (patch)
tree35f559f15539189e9c1be8f74174b3da08806f30 /sys/src/9/port/pgrp.c
parentf97798e710929c0acb2b110c1cc16b1b267039a0 (diff)
use resrcwait() when waiting for memory to become available
use resrcwait() when waiting for memory to become available. randomize the sleep time and properly restore old process status in case tsleep() gets interrupted.
Diffstat (limited to 'sys/src/9/port/pgrp.c')
-rw-r--r--sys/src/9/port/pgrp.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/src/9/port/pgrp.c b/sys/src/9/port/pgrp.c
index 22fc78b56..21ac7af86 100644
--- a/sys/src/9/port/pgrp.c
+++ b/sys/src/9/port/pgrp.c
@@ -306,6 +306,10 @@ resrcwait(char *reason)
p = up->psstate;
if(reason) {
+ if(waserror()){
+ up->psstate = p;
+ nexterror();
+ }
up->psstate = reason;
now = seconds();
/* don't tie up the console with complaints */
@@ -314,7 +318,9 @@ resrcwait(char *reason)
print("%s\n", reason);
}
}
-
- tsleep(&up->sleep, return0, 0, 300);
- up->psstate = p;
+ tsleep(&up->sleep, return0, 0, 100+nrand(200));
+ if(reason) {
+ up->psstate = p;
+ poperror();
+ }
}