Not passing forkbomb


(Karan Gopal Bhatia) #1

We are at the stage where we have completed the initial part and fixed our memory leaks. What’s left to implement is heap functionality i.e. sbrk. Upon running asst3.2, I noticed that we are passing almost all (sbrk tests didn’t pass, obviously) except forkbomb! So, I was wondering if forkbomb requires sbrk() functionality to be implemented. Should I be able to pass this without sbrk implemented?
What forkbomb basically does is, while(true) {fork}, so I couldn’t think of any reason why sbrk would be required.
Appreciate any help, thanks!!


(David Robert Olsen) #2

Forkbomb 100% does not need sbrk.


(Richard Salvatore Hanulewicz) #3

Forkbomb needs error handling. That is, it’s just going to keep forking and forking and as it does so it will try to allocate memory for the various parts of each process. You need to return the correct error whenever a fork cannot be fulfilled due to lack of memory (you can do that now, because the memory system is yours!). This can be a little sneaky, keep a careful eye on what’s being allocated and how your as_ functions account for nomem.


(Karan Gopal Bhatia) #4

Thanks a lot, that makes a lot of sense!!! Will look into fixing it.


(Karan Gopal Bhatia) #5

Ok, so I seem to have fixed the issue. I am returning nomem error at the right places. And forkbomb doesn’t hang anymore.
But there’s another problem. The "."s that are printed in forkbomb are printed very slow. Basically, it doesn’t take 10 seconds for the test to pass, but quite a lot more. I still pass the test but it takes a very long time to pass.
Is this normal behavior or are we going somewhere wrong?


(Richard Salvatore Hanulewicz) #6

I too found that my forkbomb ran significantly more slowly than before. I still get the points on the test161 server…for now. I don’t know how harsh the time restrictions are on 3.3, but I’m guessing - if you used linked lists for your data structures in 3.2 like we did - it has to do with the fact that forkbomb is basically eating linked lists for breakfast. That is quite a slow operation.


(Karan Gopal Bhatia) #7

Thanks Richard for the prompt reply!!!
Do you think the linked list implementation will create problems for passing ASST 3.3?
Should we switch to multi-level arrays before moving on to ASST 3.3?

Appreciate it!! Thanks!!


(Richard Salvatore Hanulewicz) #8

I am moving onto 3.3 myself, but I know from those who have completed that you can do it with a linked list. However, it may become a large source of inefficiency that will require your attention down the line. A multi-level page table is recommended but not required. (We probably won’t do it ourselves due to time constraints!)