Joe Armstrong - Erlang and other stuff

Why did I wake up before my alarm clock went off?

I often think that I wake up just before my alarm goes off.

A couple of days ago I lay in bed thinking “the alarm is just about to go off” and then a second later it did go off and I thought “how come I woke up just before the alarm went off?” In the past I'd thought to myself “I've got a super-accurate timer in my head that wakes me up ...” but then a new thought hit me:

My brain is a distributed computer. When the alarm goes off various parts of my brain which are in deep-sleep mode need waking up - what I'm observing is a timing error in my brain.

Hopefully a neurophysiologist who is reading this article will add a comment to tell me that I'm totally wrong and point me to some literature that explains what happens when I wake up.

I wake up just before the alarm went off

I didn't wake up before the alarm went off - I woke up because the alarm went off.

So How come I thought I woke up before the alarm went off?

So who actually woke up first?

Who is the “I” in the phrase “I woke up”.

The I in question is my conscious brain, I guess this is the cerebral cortex. The bit of my brain that first registers the alarm is something more primitive - possible the amygdala.

I'm speculating that what happens is something like this:

- The alarm goes off - The amygdala registers this fact and sends emergency wake-up signals to other parts of the brain - The cerebral cortex is in deep sleep mode and needs to be re-booted - different parts of my brain are booting at different speeds and sending status reports to the cerebral cortex. - The cerebral cortex has finished its boot sequence - I'm now awake (conscious) - so I can think a bit (and here's the kicker) the cerebral cortex has not yet received a sound alarm signal, so although I'm awake and thinking my brain does not yet know why it has woken up. - The amygdala sends the ring signal to the auditory cortex for processing - The auditory cortex processes the sound signal and figures out that in means the alarm clock is ringing and sends a message to the cerebral cortex

We can illustrate this in a message sequence diagram (this is something computer scientists like to draw in order to understand what's going on):

Time flows down the diagram and the different activities are show in different colors. I'm assuming the brain is like a computer. Parts of the brain are sleeping (blue) booting (pink) processing (red) or available to perform computations (green).

The conscious “me”' thinks (in time order):

  • 1) I'm awake.
  • 2) The alarm has just gone off.
  • 3) That's funny how come I woke up before the alarm went off?
  • 4) Perhaps I've got a super accurate clock in my head that wakes me up before the alarm goes off.
  • In I regularly wake up moments before my alarm clock rings, no matter what time I set it for. Does this mean I have supernatural powers? this phenomena was discussed in some detail. Interestingly none of the explanations was anywhere near what I'm suggesting.

    Occam's razor would imply that the simplest answer to why you woke up before the alarm went is “you didn't, you woke up because the alarm went, and your brain got it wrong.”

    A simpler model

    The brain behaves like a distributed computer. It has several processing units, different parts of the brain take different times to process signals. The part of the brain where conscious thoughts are processed (like “I'm awake” and “the alarm went off”) interprets information coming from other parts of the brain, but this part of the brain takes longer to work out what is happening than the parts of the brain that supply it with information. Sometimes we get things wrong and have to adjust our view of reality.

    >Suppose now that:

    time to wake up < time to recognized the alarm signal

    Then we get something like the following:

    Now we don't need to assume that parts of the brain are asleep and need rebooting. If the time to process the audio signal (the red box marked B above) into a semantic signal (the alarm went off) is longer than the time taken for the brain to wake up (red box A) then we will think that we woke up before hearing the sound.

    Since this the idea that we wake up before we hear the signal is crazy we misinterpret what is going on and invent fancyfull and incorrect explanations as to what has actually happened (like that we after a super accurate clock in our brain that wakes us up just before the alarm goes off).

    So how come I "know" the alarm is going to go off?

    The argument so far is that the alarm sends a signal that wakes my conscious brain before the sound signal has been processed and sent to the conscious brain. So how come I “know” that the alarm is going to go off? I suspect this is just the result of intelligent guesswork. I “know” that the thing that wakes me up most mornings is the alarm. So If I suddenly wake up it's most likely because the alarm just went off - the fact I haven't yet “heard” the alarm is a result of a timing delay in the brain.

    So the higher conscious part of the brain works like a Lamport clock trying to order the events in a sequence that makes sense.


    I'm not really sure which parts of the brain do what. Do the parts of the brain go to sleep? Do they need rebooting? - How long does it take to turn a sound waveform into a semantic “alarm” signal. How long does it take to reboot parts of the brain?