mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:48:12 +00:00
LibGUI+Kernel: Add a GLock class (userspace mutex.)
It's basically a userspace port of the kernel's Lock class. Added gettid() and donate() syscalls to support the timeslice donation feature we already enjoyed in the kernel.
This commit is contained in:
parent
108b663618
commit
500df578fe
10 changed files with 176 additions and 12 deletions
|
@ -2461,3 +2461,27 @@ int Process::sys$create_thread(int(*entry)(void*), void* argument)
|
|||
thread->set_state(Thread::State::Runnable);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Process::sys$gettid()
|
||||
{
|
||||
return current->tid();
|
||||
}
|
||||
|
||||
int Process::sys$donate(int tid)
|
||||
{
|
||||
if (tid < 0)
|
||||
return -EINVAL;
|
||||
InterruptDisabler disabler;
|
||||
Thread* beneficiary = nullptr;
|
||||
for_each_thread([&] (Thread& thread) {
|
||||
if (thread.tid() == tid) {
|
||||
beneficiary = &thread;
|
||||
return IterationDecision::Abort;
|
||||
}
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
if (!beneficiary)
|
||||
return -ENOTHREAD;
|
||||
Scheduler::donate_to(beneficiary, "sys$donate");
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue