This is a 2-line fix.
os_delay_loop:
hlt
cmp qword [os_ClockCounter], rax ; Compare it against our end time
jle os_delay_loop ; Loop if RAX is still lower
The loop is modified to 'hlt' until an interrupt is received.
In interrupt.asm in the rtc function:
rtc_end:
mov al, 0x0C ; Select RTC register C
out 0x70, al ; Port 0x70 is the RTC index, and 0x71 is the RTC data
in al, 0x71 ; Read the value in register C
mov rsi, [os_LocalAPICAddress] ; Acknowledge the IRQ on APIC
xor eax, eax
mov dword [rsi+0xB0], eax
call os_smp_wakeup_all ; A terrible hack
We add a call to os_smp_wakeup_all to broadcast whenever the RTC interrupt fires. This is not ideal as it wakes up all CPU cores instead of just the one that is waiting. This is the same way that the keyboard interrupt is handled at the moment.
I tried the changes and it removes the 100% CPU load when os_delay is called.
-Ian
On Monday, April 16, 2012 3:45:11 AM UTC-4, håvard ostnes wrote:
Ok :) Thank you so much for the reply.
Good luck, and I hope this will be updated soon ;)