The "pids" is a plain text file contains PIDs for important tasks.
Project manager tell you every task is *IMPORTANT*, should be done as soon as possible.
You're a programmer (also a system administrator), it's a piece of cake to change piorities.
$ cat pids
16994
17377
17378
17379
for p in `cat pids`; do renice -n -20 -p $p; done
Which process is most favorable scheduling?
(二) 程式設計師為什麼總是不斷加班?
Demo: http://jsfiddle.net/MWMBk/
var taskNum = 3;
var money = 10000;
var health = 100;
function incoming_task() {
taskNum ++;
taskNum ++;
}
function work() {
taskNum --;
money ++;
}
function work_overtime() {
taskNum --;
money ++;
money ++;
health --;
}
function programmer_life() {
while (taskNum > 0) {
work();
incoming_task();
work_overtime();
if (money >= 1000000) {
return "retired";
}
else if (health <= 0) {
return "died";
}
else {
//nothing
}
}
}
function assert(val1, val2) {
if (val1 == val2) {
alert("True");
}
else {
alert("False");
}
}
assert(programmer_life(), "died");
assert(programmer_life(), "retired");
// or infinite loop ?
沒有留言:
張貼留言