mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 06:38:47 +00:00
os2: nice != priority
This commit is contained in:
@@ -22,16 +22,16 @@ foreign lib {
|
|||||||
_process_info_by_pid :: proc(pid: int, selection: Process_Info_Fields, allocator: runtime.Allocator) -> (info: Process_Info, err: Error) {
|
_process_info_by_pid :: proc(pid: int, selection: Process_Info_Fields, allocator: runtime.Allocator) -> (info: Process_Info, err: Error) {
|
||||||
info.pid = pid
|
info.pid = pid
|
||||||
|
|
||||||
get_pidinfo :: proc(pid: int, selection: Process_Info_Fields) -> (ppid: u32, nice: Maybe(i32), uid: posix.uid_t, ok: bool) {
|
get_pidinfo :: proc(pid: int, selection: Process_Info_Fields) -> (ppid: u32, prio: Maybe(i32), uid: posix.uid_t, ok: bool) {
|
||||||
// Short info is enough and requires less permissions if the priority isn't requested.
|
// Short info is enough and requires less permissions if the priority isn't requested.
|
||||||
if .Priority in selection {
|
if .Priority in selection {
|
||||||
pinfo: darwin.proc_bsdinfo
|
info: darwin.proc_taskallinfo
|
||||||
ret := darwin.proc_pidinfo(posix.pid_t(pid), .BSDINFO, 0, &pinfo, size_of(pinfo))
|
ret := darwin.proc_pidinfo(posix.pid_t(pid), .TASKALLINFO, 0, &info, size_of(info))
|
||||||
if ret > 0 {
|
if ret > 0 {
|
||||||
assert(ret == size_of(pinfo))
|
assert(ret == size_of(info))
|
||||||
ppid = pinfo.pbi_ppid
|
ppid = info.pbsd.pbi_ppid
|
||||||
nice = pinfo.pbi_nice
|
prio = info.ptinfo.pti_priority
|
||||||
uid = pinfo.pbi_uid
|
uid = info.pbsd.pbi_uid
|
||||||
ok = true
|
ok = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,7 @@ _process_info_by_pid :: proc(pid: int, selection: Process_Info_Fields, allocator
|
|||||||
|
|
||||||
pidinfo: {
|
pidinfo: {
|
||||||
if selection & {.PPid, .Priority, .Username } != {} {
|
if selection & {.PPid, .Priority, .Username } != {} {
|
||||||
ppid, mnice, uid, ok := get_pidinfo(pid, selection)
|
ppid, mprio, uid, ok := get_pidinfo(pid, selection)
|
||||||
if !ok {
|
if !ok {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = _get_platform_error()
|
err = _get_platform_error()
|
||||||
@@ -68,8 +68,8 @@ _process_info_by_pid :: proc(pid: int, selection: Process_Info_Fields, allocator
|
|||||||
info.fields += {.PPid}
|
info.fields += {.PPid}
|
||||||
}
|
}
|
||||||
|
|
||||||
if nice, has_nice := mnice.?; has_nice && .Priority in selection {
|
if prio, has_prio := mprio.?; has_prio && .Priority in selection {
|
||||||
info.priority = int(nice)
|
info.priority = int(prio)
|
||||||
info.fields += {.Priority}
|
info.fields += {.Priority}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,6 +98,32 @@ vinfo_stat :: struct {
|
|||||||
vst_qspare: [2]i64,
|
vst_qspare: [2]i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proc_taskinfo :: struct {
|
||||||
|
pti_virtual_size: u64 `fmt:"M"`,
|
||||||
|
pti_resident_size: u64 `fmt:"M"`,
|
||||||
|
pti_total_user: u64,
|
||||||
|
pti_total_system: u64,
|
||||||
|
pti_threads_user: u64,
|
||||||
|
pti_threads_system: u64,
|
||||||
|
pti_policy: i32,
|
||||||
|
pti_faults: i32,
|
||||||
|
pti_pageins: i32,
|
||||||
|
pti_cow_faults: i32,
|
||||||
|
pti_messages_sent: i32,
|
||||||
|
pti_messages_received: i32,
|
||||||
|
pti_syscalls_mach: i32,
|
||||||
|
pti_syscalls_unix: i32,
|
||||||
|
pti_csw: i32,
|
||||||
|
pti_threadnum: i32,
|
||||||
|
pti_numrunning: i32,
|
||||||
|
pti_priority: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
proc_taskallinfo :: struct {
|
||||||
|
pbsd: proc_bsdinfo,
|
||||||
|
ptinfo: proc_taskinfo,
|
||||||
|
}
|
||||||
|
|
||||||
fsid_t :: distinct [2]i32
|
fsid_t :: distinct [2]i32
|
||||||
|
|
||||||
PBI_Flag_Bits :: enum u32 {
|
PBI_Flag_Bits :: enum u32 {
|
||||||
|
|||||||
Reference in New Issue
Block a user