This time, I did not wait to be unexpectely assaulted by the ghost in the machine. I would get in a pre-emptive strike!!
I decided to beat up on Fib – a little memory location containing the results of the fibonacci sequence. By the time the motherboard was on to me, I’d be long gone. Granted, I’m bullying the microprocessor, but I figure all is fair in love and war. Finally, I’d have my revenge. The motherboard would turn on her own memory.
I launched the blitzkrieg. Four threads ran amok in the cpu. The math processor was implicated. I followed the trace laughing ….. until… The ghost came back!
How is it that the last value of Fib is reported before the last thread ends?!?
(click on the screenshot to see it)
The fibonacci sequence is calculated thusly: it begins with two numbers, generally both 1’s. Each new term is calculated by adding the previous two terms. For example: 1 + 1 = 2, 2 + 1 = 3, 3 + 2 = 5, … up to n terms. The resulting sequence is this: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, … n-1 + n