diff options
author | Ben Wiederhake <BenWiederhake.GitHub@gmx.de> | 2020-08-09 01:08:24 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-10 11:51:45 +0200 |
commit | bee08a4b9ff0f2c269a4e3a8159b689fbb8d1ab8 (patch) | |
tree | 7963eede850be6fcf18ac8b3aae30e72a8d30407 /Kernel/Syscalls/sched.cpp | |
parent | 7bdf54c8372d6951409fae17dd4cec7eea6573a2 (diff) | |
download | serenity-bee08a4b9ff0f2c269a4e3a8159b689fbb8d1ab8.zip |
Kernel: More PID/TID typing
Diffstat (limited to 'Kernel/Syscalls/sched.cpp')
-rw-r--r-- | Kernel/Syscalls/sched.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/Kernel/Syscalls/sched.cpp b/Kernel/Syscalls/sched.cpp index b144f39792..7729a817b0 100644 --- a/Kernel/Syscalls/sched.cpp +++ b/Kernel/Syscalls/sched.cpp @@ -35,7 +35,7 @@ int Process::sys$yield() return 0; } -int Process::sys$donate(int tid) +int Process::sys$donate(pid_t tid) { REQUIRE_PROMISE(stdio); if (tid < 0) @@ -48,7 +48,7 @@ int Process::sys$donate(int tid) return 0; } -int Process::sys$sched_setparam(int tid, Userspace<const struct sched_param*> user_param) +int Process::sys$sched_setparam(int pid, Userspace<const struct sched_param*> user_param) { REQUIRE_PROMISE(proc); if (!validate_read_typed(user_param)) @@ -59,8 +59,8 @@ int Process::sys$sched_setparam(int tid, Userspace<const struct sched_param*> us InterruptDisabler disabler; auto* peer = Thread::current(); - if (tid != 0) - peer = Thread::from_tid(tid); + if (pid != 0) + peer = Thread::from_tid(pid); if (!peer) return -ESRCH; @@ -68,8 +68,7 @@ int Process::sys$sched_setparam(int tid, Userspace<const struct sched_param*> us if (!is_superuser() && m_euid != peer->process().m_uid && m_uid != peer->process().m_uid) return -EPERM; - if (desired_param.sched_priority < THREAD_PRIORITY_MIN || - desired_param.sched_priority > THREAD_PRIORITY_MAX) + if (desired_param.sched_priority < THREAD_PRIORITY_MIN || desired_param.sched_priority > THREAD_PRIORITY_MAX) return -EINVAL; peer->set_priority((u32)desired_param.sched_priority); @@ -84,8 +83,11 @@ int Process::sys$sched_getparam(pid_t pid, Userspace<struct sched_param*> user_p InterruptDisabler disabler; auto* peer = Thread::current(); - if (pid != 0) + if (pid != 0) { + // FIXME: PID/TID BUG + // The entire process is supposed to be affected. peer = Thread::from_tid(pid); + } if (!peer) return -ESRCH; @@ -93,12 +95,14 @@ int Process::sys$sched_getparam(pid_t pid, Userspace<struct sched_param*> user_p if (!is_superuser() && m_euid != peer->process().m_uid && m_uid != peer->process().m_uid) return -EPERM; - struct sched_param param { (int) peer->priority() }; + struct sched_param param { + (int)peer->priority() + }; copy_to_user(user_param, ¶m); return 0; } -int Process::sys$set_thread_boost(int tid, int amount) +int Process::sys$set_thread_boost(pid_t tid, int amount) { REQUIRE_PROMISE(proc); if (amount < 0 || amount > 20) |