kernel: make allocb() wait instead of panic() when possible

as long as our process doesnt hold any locks or ilocks, we
can try to wait for the memory to become available instead of
panicing.
This commit is contained in:
cinap_lenrek 2013-05-21 02:29:46 +02:00
parent 58201a67c1
commit 8a3a36fc05

View file

@ -64,10 +64,16 @@ allocb(int size)
*/
if(up == nil)
panic("allocb without up: %#p", getcallerpc(&size));
if((b = _allocb(size)) == nil){
xsummary();
mallocsummary();
panic("allocb: no memory for %d bytes", size);
while((b = _allocb(size)) == nil){
if(up->nlocks.ref || m->ilockdepth || !islo()){
xsummary();
mallocsummary();
panic("allocb: no memory for %d bytes", size);
}
if(!waserror()){
resrcwait("no memory for allocb");
poperror();
}
}
setmalloctag(b, getcallerpc(&size));