Since sleep suspends execution and keeps the RAM state, I suppose it isn't a huge stretch for the kernel to provide some mechanism by which a program can stay awake while execution of others is paused.
I'm sure there are aspects that are hard to reason about which I'm simply unaware of, but the idea makes sense to me.