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 realtime scheduling calls to std.os.linux (issue #19671) #19675
base: master
Are you sure you want to change the base?
Conversation
lib/std/os/linux.zig
Outdated
sched_priority: i32, | ||
}; | ||
|
||
pub const SCHED = struct { |
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.
should this not be an enum, rather than a struct?
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.
The problem with it being an enum is that the RESET_ON_FORK is not an independent value, but a flag that is ORed with one of the other values.
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.
I think the recommended thing to do would be to make it a packed struct
, something like this (untested):
pub const SCHED = packed struct(i32) {
pub const Mode = enum(u3) {
/// normal multi-user scheduling
pub const OTHER = 0;
/// FIFO realtime scheduling
pub const FIFO = 1;
/// Round-robin realtime scheduling
pub const RR = 2;
/// For "batch" style execution of processes
pub const BATCH = 3;
/// Low latency scheduling
pub const ISO = 4;
/// For running very low priority background jobs
pub const IDLE = 5;
/// Sporadic task model deadline scheduling
pub const DEADLINE = 6;
};
mode: Mode, //bits [0, 2]
_3: u27 = 0, //bits [3, 29]
/// set to true to stop children from inheriting policies
RESET_ON_FORK: bool = false, //bit 30
_31: u1 = 0, //bit 31
}
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.
Thank you. I will update my code accordingly.
Add the following system calls to std.os.linux:
Also add required sched_param structure and SCHED constant definitions: