for all benchmark graphs G: for all algorithm variants A: for k in [2, 4, 8, ..., 128]: Execute A on G with the current value for kNow if this computation takes 20 hours and I'm running this on my laptop, one of the CPU cores is hogged and the fan goes berserk. So what happens if I want to take my computer somewhere else or view a movie? As it turns out, I can simply suspend the machine and after waking up the program will continue to run. This already solves the first problem and shows that the operating system can suspend my program out of the box. The bash shell (and I'm sure other shells, too) helps me with the second problem: It is able to do basic job management. Consider the following command sequence. This lists my temporary directory and pastes it through less. less will wait for my input.
$ ls /tmp | lessNow, I press Ctrl+Z to suspend less:
+ Stopped ls /tmp | lessNeat! How do we get back the listing. With fg %<job number>:
$ fg %1We can also have multiple jobs:
$ ls /tmp | less Ctrl+Z + Stopped ls /tmp | less $ ls /usr | less Ctrl+Z + Stopped ls /usr | lessThe command job gives us a listing of the current jobs:
$ jobs - Stopped ls /tmp | less + Stopped ls /usr | lessThere is one gotcha: If you use the bash command time, it will display the passed time when you suspend your job and not print the remaining spent time after you restart it again:
$ time ls /tmp | less Ctrl+Z + Stopped ls /tmp | less real 0m1.139s user 0m0.001s sys 0m0.003s manuel@coxorange ~ $ fg %1 ls /tmp | less Ctrl+Z + Stopped ls /tmp | lessIn this case, use time on fg %1:
$ time ls /tmp | less Ctrl+Z + Stopped ls /tmp | less real 0m0.723s user 0m0.001s sys 0m0.003s manuel@coxorange ~ $ time fg ls /tmp | less Ctrl+Z + Stopped ls /tmp | less real 0m0.913s user 0m0.000s sys 0m0.000s