In a regular Linux x86 environment, we can use the "sleep(size_t x)" C function to delay execution X number of seconds.
Behind the scenes, libc calls "nanosecond" which makes a system call and gets the current time directly from BIOS. BIOS is programmed to
return the time based on the frequency of the oscillator on the motherboard.
I know the "sleep" function doesn't exit with "avr-gcc". Arduino uses the "delay" function to accomplish the same, here is the source code:
https://github.com/arduino/ArduinoCore-samd/blob/master/cores/arduino/delay.c
My question is, how does this work?
Assume I need to wait "20 milliseconds" on atmega328p. How does its core know how long a millisecond is? Does it work like Linux x86 explained above?