Congratulations!
Angus Leeming wrote:
Andre Poenitz wrote:
I'm sure you are already know the algorithm by now:
while (age < 3 months) {
If baby cries,
- want milk?
- change diper?
- need sleep?
if age > 1 month, want to play?
}
Any decent compiler will optimize away that first 'if'...
Hmmmm. In physical terms doesn't that mean that your compiler is
pre-empting the baby's opinion by forcing it to accept milk, diper,
sleep, play even though it isn't crying?
Of course, this may just show how ignorant I am and how much I have to
learn.
Isn't this a interrupt-driven algorithm? If you're awake,
then it is because the baby cried. If he didn't, you'd be sleeping. :-)
Which is why the test is unnecessary . . .
Helge Hafting