Why do we wake up after 6-8 hours of sleep ? Why don't we sleep for lets say 20-30 hours ? What mechanism is it that controls when to wake us up and how does it determine the moment that we should wake up ?
Think this review from Nature can answer your question. A brief summary ( with slight simplification):
The ascending activating system (that is responsible for wakefulness) has two branches:
The first one ascends to the thalamus and activates the thalamic relay neurons - these transmit information to the cortex. They get their main input form two acetylcholine producing group of cells: the pedunculo- pontine and laterodorsal tegmental nuclei (PPT/LDT). These two group of cells are also the source of main input for reticular nucleus of the thalamus.
The neurons in the PPT/LDT fire most rapidly during wakefulness and rapid eye movement (REM) sleep, which is the stage accompanied by cortical activation, loss of muscle tone in the body and active dreams
The second branch, directly activates neurons in the hypothalamus, basal forebrain (BF) and cortex, bypassing the thalamus. This pathway has origins in monoaminergic neurons in the upper brainstem, caudal hypothalamus, as well as the noradrenergic locus coeruleus (LC), serotoninergic dorsal (DR) and median raphe nuclei, dopaminergic ventral periaqueductal grey matter and histaminergic tuberomammillary neurons. Input from this pathway to the cortex is extended /augmented by the lateral hypothalamic peptidergic neurons (that contain melanin-concentrating hormone (MCH) or orexin/hypocretin), and BF neurons(that produce acetylcholine or GABA).
Sleep is promoted by the so called VLPO (ventrolateral preoptic nucleus). The VLPO send outputs to major group of cells of the arousal system in the hypothalamus and brainstem.
The VLPO neurons are primarily active during sleep, and contain the inhibitory neurotransmitters, galanin and GABA. The VLPO also receives afferents from each of the major monoaminergic systems. Both noradrenaline and serotonin inhibit VLPO neurons. The latter do not have histamine receptors, but the tuberomammillary neurons also contain GABA, which is inhibitory to VLPO neurons, as well as several other potentially inhibitory pep tides, such as galanin and endomorphin. Therefore, the VLPO can be inhibited by the very arousal systems that it inhibits during sleep.
As you can see in the quote from the paper these two systems can mutually inhibit each other and basically work as a seesaw or 'flip-flop switch'. In this system activity in one subsystem shuts down the inhibition from the other subsystem and disinhibits its own action (selfreinforcing loop). The transition from one state to the other is relatively fast. Orexin plays important role in stabilizing the switch in one position or the other.
Regulation pf sleep:
Homeostatic: It is unclear how homeaostatic regulation of sleep work, yet it has been proposed, that adenosine accumulation in the brain may signal for 'need for sleep'. The extended wakefulness causes the exhaustion of brain glycogen reserves and depletion of ATP levels. As ATP is degraded to ADP, AMP and eventually adenosine, extracellular adenosine levels rise in some parts of the brain including the BF.
In addition, adenosine might disinhibit the VLPO via presynaptic A1 receptors by reducing inhibitory GABAergic inputs.
This implies that during sleep ATP and energy sources are regenerated and free adenosine levels drop, thus inhibition of VLPO might take place again. Also it is important to note that the amount of sleep we need is proportional to the time we spend awake.
It is known that humans have quite precise :circadian rhythm:
The suprachiasmatic nucleus (SCN) serves as the brain’s ‘master clock’. Neurons in the SCN fire in a 24-hour cycle that is driven by a transcriptional–translational loop, which persists even when the neurons are dissociated in cell culture.
The SCN has moderate output to the VLPO or orexin neurons, but it has more important projections to the adjacent subparaventricular zone (SPZ) and the dorsomedial nucleus of the hypothalamus (DMH).
The SPZ also has relatively limited projections to the VLPO, orexin neurons and other components of the wake-sleep-regulatory system. However, a major target is the DMH. This region receives inputs from many more neurons in the SPZ than the SCN, so the SPZ is in a position to amplify the output of the SCN. (...) The DMH is one of the largest sources of input to the VLPO and orexin neurons and is crucial for conveying SCN influence to the wake–sleep-regulatory system. The DMH projection to the VLPO comes largely from GABA-containing neurons (that is, those that promote wakefulness by inhibiting sleep), and the projection to the LHA originates from neurons containing glutamate and thyrotropin-releasing hormone (which should presumably be excitatory and promote wakefulness).
So as you can see our circadian rhythm as direct control over our sleep-wake cycle, and that the SCN can heavily promote awakening through SPZ and DMH.
Thorough review and details can be found in the article I linked at the beginning, I only tried to select key information to provide a (not so ) brief summary. We only sleep about 7-8 hours normally because this is enough for homeostatic regeneration and our circadian rhythm promotes wakefulness in the morning (this is quite simplified).
Based on their abstract these limited access papers might also be useful (unfortunately I do not have full access to them right now):
I think what the OP is getting at is less about the mechanism of sleep -> wake transition and more about how the length of sleep time is regulated...
In that regard, it's an interesting question without a definitive answer. In a sense, it is a question of homeostasis and the time when your sleep need/pressure is satisfied determines when you wake up (without an alarm clock).
It is hypothesised that sleep drive is a function of the previous wake period plus any sleep debt you carried from the previous days. One molecule, adenosine, is thought to represent that and the accumulation of that in the brain makes you want to sleep [Ref. 1]. Thus, the clearance of external adenosine in the brain to a certain level may be part of the homeostatic mechanism signalling enough sleep.
Another hypothesis is that sleep is required to encode memories long term [Ref. 2] and to calibrate emotion/mood [Ref. 3] which themselves can add to the sleep need and those processes would need to be completed to a certain level to release that sleep need.
As for the specific moment for awakening, if there isn't some external arousal stimulus like daylight/alarm or the rush of cortisol cycle driven by your circadian mechanism, then it will likely correlate to the end of the current 90min sleep cycle when your brain is close to the wake state coming out of REM [Ref. 4]. In fact, it's thought you wake a little every 90min through the night, it's just you don't remember it.