-
Does the kernel provides a way to do For now I'm using this
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 10 replies
-
The kernel |
Beta Was this translation helpful? Give feedback.
-
Recommend putting an asm("hlt"); inside the busy wait to reduce CPU usage. HLT waits until the next interrupt to resume execution. |
Beta Was this translation helpful? Give feedback.
-
Trying to implement my first system call, so I opted to adapt your code. src/BareMetal/src/syscalls/system.asm (replace empty os_delay implementation)
src/BareMetal-Demo/src/libBareMetal.c:
A 100 000 000 delay seems to complete 4 seconds earlier than a sleep 100 on a shell on the same host system. |
Beta Was this translation helpful? Give feedback.
-
Same idea, however replace RDTSC with HPET timer, assumes the timer is in 64 bit mode. Warning, this code isn't 100% proper or really robust.
Now a 100 000 000 delay seems to complete as precisely as my eyes can visually verify. |
Beta Was this translation helpful? Give feedback.
-
Wow. Amazing. |
Beta Was this translation helpful? Give feedback.
I've added your HPET code to
b_delay
. I did change the formatting a bit to get in line with the code style of the rest of the project. Thank you for the contribution! I tested this in QEMU, as well as a physical host with a 10-second delay.ReturnInfinity/BareMetal@f6079c2