mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:17:35 +00:00
Kernel: Some futex improvements
This adds support for FUTEX_WAKE_OP, FUTEX_WAIT_BITSET, FUTEX_WAKE_BITSET, FUTEX_REQUEUE, and FUTEX_CMP_REQUEUE, as well well as global and private futex and absolute/relative timeouts against the appropriate clock. This also changes the implementation so that kernel resources are only used when a thread is blocked on a futex. Global futexes are implemented as offsets in VMObjects, so that different processes can share a futex against the same VMObject despite potentially being mapped at different virtual addresses.
This commit is contained in:
parent
7581b64705
commit
1d621ab172
23 changed files with 928 additions and 63 deletions
|
@ -60,10 +60,38 @@ int profiling_disable(pid_t pid)
|
|||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int futex(int32_t* userspace_address, int futex_op, int32_t value, const struct timespec* timeout)
|
||||
int futex(uint32_t* userspace_address, int futex_op, uint32_t value, const struct timespec* timeout, uint32_t* userspace_address2, uint32_t value3)
|
||||
{
|
||||
Syscall::SC_futex_params params { userspace_address, futex_op, value, timeout };
|
||||
int rc = syscall(SC_futex, ¶ms);
|
||||
int rc;
|
||||
switch (futex_op & FUTEX_CMD_MASK) {
|
||||
//case FUTEX_CMP_REQUEUE:
|
||||
// FUTEX_CMP_REQUEUE_PI:
|
||||
case FUTEX_WAKE_OP: {
|
||||
// These interpret timeout as a u32 value for val2
|
||||
Syscall::SC_futex_params params {
|
||||
.userspace_address = userspace_address,
|
||||
.futex_op = futex_op,
|
||||
.val = value,
|
||||
.val2 = (uint32_t)timeout,
|
||||
.userspace_address2 = userspace_address2,
|
||||
.val3 = value3
|
||||
};
|
||||
rc = syscall(SC_futex, ¶ms);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
Syscall::SC_futex_params params {
|
||||
.userspace_address = userspace_address,
|
||||
.futex_op = futex_op,
|
||||
.val = value,
|
||||
.timeout = timeout,
|
||||
.userspace_address2 = userspace_address2,
|
||||
.val3 = value3
|
||||
};
|
||||
rc = syscall(SC_futex, ¶ms);
|
||||
break;
|
||||
}
|
||||
}
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue