Closed MoistCoder closed 2 years ago
Hi. I created such a function here in my fork of this example OS: https://github.com/rualark/SimpleOsDemo/blob/master/src/impl/kernel/nanosleep/nanosleep.c
There are actually several approaches to do it. I implemented (i think) the most simple one without creating interrupt handler. I also created a more complex but more precise nanosleep function, which allows very precise time delays, and it also does not use interrupts:
https://github.com/rualark/SimpleOsDemo/blob/master/src/impl/kernel/nanosleep/nanosleep_exact.c
In real world using interrupt handlers is better, because it allows CPU to do some other work. But in this case there is no other work.
How do I create a function that waits for x ms?