From fa241747af9e37b43a97fd644f98ce4fa6721d9d Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 8 Feb 2019 22:06:30 +0100 Subject: [PATCH] Kernel: When donating ticks to a lock holder, cap the donation. When donating ticks to a lock holder, never donate more ticks than that process would normally get from the scheduler. --- Kernel/Scheduler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp index deb665c265..827368586a 100644 --- a/Kernel/Scheduler.cpp +++ b/Kernel/Scheduler.cpp @@ -211,7 +211,7 @@ bool Scheduler::donate_to(Process* beneficiary, const char* reason) return yield(); } - unsigned ticks_to_donate = ticks_left - 1; + unsigned ticks_to_donate = min(ticks_left - 1, time_slice_for(beneficiary->priority())); #ifdef SCHEDULER_DEBUG dbgprintf("%s(%u) donating %u ticks to %s(%u), reason=%s\n", current->name().characters(), current->pid(), ticks_to_donate, beneficiary->name().characters(), beneficiary->pid(), reason); #endif