-
Notifications
You must be signed in to change notification settings - Fork 1.3k
os : implement os.sched_yield, os.sched_get_priority_min, os.sched_get_priority_max #2997
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
Conversation
c90cd0f
to
a0624dd
Compare
Is this unix api or linux api? if it is unix apis, we don't need linux check.
|
vm/src/stdlib/os.rs
Outdated
let res = nix::sched::sched_yield(); | ||
match res { | ||
Ok(_) => Ok(()), | ||
Err(err) => Err(err.into_pyexception(vm)), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let res = nix::sched::sched_yield(); | |
match res { | |
Ok(_) => Ok(()), | |
Err(err) => Err(err.into_pyexception(vm)), | |
} | |
let _ = nix::sched::sched_yield().map_err(|e| e.into_pyexception(vm))?; | |
Ok(()) |
fb86bd9
to
3a70a6f
Compare
I found I didn't remove target cfg from pyattr. The functions work. But pyattrs will not be simple. |
Okay. I understood. |
About About scheduling policies such as #ifdef SCHED_OTHER
if (PyModule_AddIntMacro(m, SCHED_OTHER)) return -1;
#endif
#ifdef SCHED_FIFO
if (PyModule_AddIntMacro(m, SCHED_FIFO)) return -1;
#endif
#ifdef SCHED_RR
if (PyModule_AddIntMacro(m, SCHED_RR)) return -1;
#endif https://github.com/python/cpython/blob/main/Modules/posixmodule.c#L15267-L15300 |
|
This PR contains implementation of
os.sched_yield
,os.sched_get_priority_min
andos.sched_get_priority_max
.You can check the interface of each function here : https://docs.python.org/3/library/os.html#interface-to-the-scheduler
Inside each function, related system call is called through the libc Crate.
with this code, rust python works as below.