The API's related to this stuff are pretty byzantine and poorly documented, but here's what I've found.
First, the datatypes related to RR scheduling seem to be in /usr/include/mach/policy.h
, around line 155. There's this struct:
struct policy_rr_info {
...
integer_t quantum;
....
};
The quantum
is, I think, the timeslice (not sure of units.) Then grepping around for this or related types defined in the same place, I found the file /usr/include/mach/mach_types.def
, which says that the type struct thread_policy_t
contains a field policy_rr_info_t
on line 203.
Next, I found in /usr/include/mach/thread_act.h
the public function thread_policy_get
, which can retrieve information about a thread's policy into a struct thread_policy_t *
.
So, working backwards. I think (but haven't tried at all) that you can
- Use the
thread_policy_get()
routine to return information about the thread's scheduling state into a thread_policy_t
- That struct seems to have a
policy_rr_info_t
sub-substructure
- That sub-structure should have a
quantum
field.
- That field appears to be the timeslice, but I don't know about the units.
There are no man pages for this part of the API, but this Apple Developer page explains at least a little bit about how to use this API.
Note that this is all gleaned from just grepping the various kernel headers, and I've definitely not tried to use any of these APIs in any actual code.
policy.h
that says ‘Definitions for scheduing policy. N.B. The interfaces defined here are all obsolete!!’ makes me doubt this works. Also thequantum
is defined only for Round Robin policy, FIFO and timeshare policies lack anything relevant. I fear we’re digging in a wrong place here. – Wit