Skip to content

posix : implement sched_set/getscheduler and sched_set/getparam #3089

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

Closed
wants to merge 4 commits into from

Conversation

zetwhite
Copy link
Contributor

@zetwhite zetwhite commented Sep 18, 2021

This PR contains os.sched_* series implemetation.
: os.sched_setscheduler , os.sched_getscheduler, os.sched_setparam and os.sched_getparam.

with this code, RustPython works as below.

>>>>> import os
>>>>> os.SCHED_RR #check os support SCHED_RR policy 
2
>>>>> os.sched_getscheduler(0)
0
>>>>> os.sched_setscheduler(0, os.SCHED_RR, os.sched_param(20))
0
>>>>> os.sched_getscheduler(0)
2
>>>>> os.sched_getparam(0)
posix.sched_param(sched_priority = 20)
>>>>> os.sched_setparam(0, os.sched_param(50))
0
>>>>> os.sched_getparam(0)
posix.sched_param(sched_priority = 50)

notes

  • I fixed SchedParam's SlotConstructor implementation, to make sure work as below.
    before : only os.sched_param(1) worked well. os.sched_param(sched_priority = 1) got error.
    after : os.sched_param(sched_priority = 1) is fine

  • Inside both sched_setscheduler and sched_setparam, try_to_libc is called to convert RustPython SchedParam class to libc::sched_param. That function can return error(overflow or type error), if SchedParam.sched_priority is not in i32 range.

@zetwhite zetwhite force-pushed the os_sched branch 3 times, most recently from b9db3b3 to 77cf0b0 Compare September 20, 2021 14:29
@zetwhite
Copy link
Contributor Author

zetwhite commented Sep 24, 2021

oh, posix module has been seperated from os.rs : #3111
I will fix this commit and reopen it soon.

@youknowone
Copy link
Member

I am sorry, I had to merge this PR first. I didn't know this is updated.

@youknowone youknowone added the z-ca-2021 Tag to track contrubution-academy 2021 label Oct 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
z-ca-2021 Tag to track contrubution-academy 2021
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants