Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add preemption timer #102

Merged
merged 5 commits into from
Dec 25, 2024
Merged

add preemption timer #102

merged 5 commits into from
Dec 25, 2024

Conversation

Freax13
Copy link
Owner

@Freax13 Freax13 commented Dec 25, 2024

The supervisors now try to inject a timer interrupt into each kernel thread. Assuming a well-behaved hypervisor, the timer frequency will be 100 Hz, though if the hypervisor is malicious it could skew the frequency. The main use case for this is to give the scheduler a chance to preempt user threads that never voluntarily yield to the kernel. This also gives as an opportunity to evaluate the live-ness of threads that don't yield to the kernel.

This is the first step for preemptive scheduling. Some processes will
never invoke any syscalls on their own and so the scheduler never has a
chance to run another thread. Similarly, we never have a chance to
check if a thread is still supposed to be running if the thread never
yields to the kernel.
To solve this, we now expect the supervisors to periodically inject
timer interrupts and force a transition out of userspace into
kernelspace.
When the CPU jumps to the IRQ handler, it clears the IF flag. We
shouldn't set it again when entering to kernel space, because we want
the IF flag to continue to be clear up until the IRQ has been handled.
@Freax13 Freax13 merged commit a4c8c34 into main Dec 25, 2024
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant