-
Notifications
You must be signed in to change notification settings - Fork 81
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
Rethink scheduling using Future
s
#787
Comments
This would need a bit of planning beforehand, as there are multiple ways/levels of implementing this: Thread wraps userspace or syscallFor my (unreleased) kernel, I'm using a kernel-thread-per-core design where the user threads are handles with an struct UserThread { .. }
impl UserThread {
fn execute(&mut self, retval: isize) -> Return { .. }
}
enum Return {
Syscall(u8 or fn(..) -> usize, Parameters),
Interrupt(u8),
}
// Execute these futures in the scheduler
async fn thread(mut user: UserThread) {
let mut retval = 0;
loop {
match user.execute(retval) {
// Handle syscall/interrupt
}
}
} Thread wraps userspace wraps syscallAnother way of doing this would be to make all blocking syscalls extern "C" fn syscall_wrapper(..params) -> isize {
let mut future = pin!(syscall(..params));
loop {
match future.as_mut().poll(scheduler.waker()) {
Poll::Ready(retval) => return retval,
Poll::Pending => {
exchange_context_with_kernel_context(terminate: false/true);
}
}
}
}
struct Thread { .. }
// Could be a separate method instead of a `Future` implementation.
impl Future for Thread {
fn poll(..) -> Poll<()> {
let terminate = execute_userspace();
if terminate {
Poll::Ready(())
} else {
Poll::Pending
}
}
} |
The first option sounds really interesting. I had thought of something similar to the second option, I think, but I have not looked deeper into this topic. I also did not discuss with @stlankes if this was something that he would be interested in adopting. What level of interest do you have in this, @joboet? Would you be interested in contributing something like this? If not, I will look into this myself, eventually, but that will probably take a while. :) |
My last exam for this semester is on Saturday, and I'll have plenty of time over the summer break, so sure, I can do it 😄! |
Great! 🥳 |
It might be interesting to revision scheduling by making all tasks a
Future
.The text was updated successfully, but these errors were encountered: