feat: add SYS_FUTEX_WAIT and SYS_FUTEX_WAKE syscalls; revamp desktop application categories
This commit is contained in:
1 parent
60ca9c78c7
commit
abfd9de8f6
35 files changed
+545
-70
No files matched your search
@@ -126,6 +126,13 @@ namespace Sched {
|
||||
bool joinable = true; // Sibling thread keeps Terminated state for the joiner
|
||||
uint64_t threadArg = 0; // Argument passed into entryPoint on first dispatch
|
||||
|
||||
// Futex wait state (see FutexWait). futexAddr is the user VA this
|
||||
// thread is parked on, 0 when not in a futex wait. futexSeq orders
|
||||
// waiters so FutexWake releases the longest-waiting first.
|
||||
uint64_t futexAddr = 0;
|
||||
uint64_t futexSeq = 0;
|
||||
bool futexWoken = false;
|
||||
|
||||
// I/O redirection for GUI terminal
|
||||
bool redirected = false;
|
||||
int parentPid = -1;
|
||||
@@ -270,6 +277,30 @@ namespace Sched {
|
||||
// Wake any processes blocked on the given object.
|
||||
void WakeObjectWaiters(void* object);
|
||||
|
||||
// ====================================================================
|
||||
// Futexes
|
||||
// ====================================================================
|
||||
|
||||
// Futexes are private to a process: the key is (primary slot, user VA),
|
||||
// so two processes waiting on the same address never see each other.
|
||||
static constexpr uint64_t FutexWaitForever = ~0ULL;
|
||||
|
||||
// Block the current thread on the 32-bit word at `uaddr` if it still
|
||||
// holds `expected`. The comparison and the enrollment happen atomically
|
||||
// under the scheduler lock, so a FutexWake issued after the waker changed
|
||||
// the word can never be lost. `timeoutNs` is rounded up to the 1 ms tick;
|
||||
// FutexWaitForever waits without a deadline, 0 only performs the check.
|
||||
// Returns Success when woken by FutexWake, WouldBlock when the word did
|
||||
// not hold `expected`, TimedOut when the deadline passed, InvalidArgument
|
||||
// for a misaligned address, BadPointer when the word is not mapped.
|
||||
// Spurious Success returns are not possible, but callers must still
|
||||
// re-check their condition: another thread may have run in between.
|
||||
int FutexWait(uint64_t uaddr, uint32_t expected, uint64_t timeoutNs);
|
||||
|
||||
// Wake up to `count` threads of the current process blocked on `uaddr`,
|
||||
// longest-waiting first. Returns the number woken.
|
||||
int FutexWake(uint64_t uaddr, uint32_t count);
|
||||
|
||||
// Kill a process by PID. If the process is running on another CPU,
|
||||
// sets a kill-pending flag checked on the next timer tick.
|
||||
// Returns 0 on success, -1 on failure.
|
||||
|
||||
Reference in new issue
Block a user