zephyr/kernel
Wentong Wu 5611e92347 kernel: add futex support
A k_futex is a lightweight mutual exclusion primitive designed
to minimize kernel involvement. Uncontended operation relies
only on atomic access to shared memory. k_futex structure lives
in application memory. And when using futexes, the majority of
the synchronization operations are performed in user mode. A
user-mode thread employs the futex wait system call only when
it is likely that the program has to block for a longer time
until the condition becomes true. When the condition comes true,
futex wake operation will be used to wake up one or more threads
waiting on that futex.

This patch implements two futex operations: k_futex_wait and
k_futex_wake. For k_futex_wait, the comparison with the expected
value, and starting to sleep are performed atomically to prevent
lost wake-ups. If different context changed futex's value after
the calling use-mode thread decided to block himself based on
the old value, the comparison will help observing the value
change and will not start to sleep. And for k_futex_wake, it
will wake at most num_waiters of the waiters that are sleeping
on that futex. But no guarantees are made on which threads are
woken, that means scheduling priority is not taken into
consideration.

Fixes: #14493.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-06-24 15:38:21 -07:00
..
include kernel: introduce k_float_disable system call 2019-06-12 09:17:45 -07:00
CMakeLists.txt kernel: add futex support 2019-06-24 15:38:21 -07:00
Kconfig x86: remove unused and x86 only latency benchmark 2019-06-03 09:42:00 -07:00
Kconfig.power_mgmt power: modify HAS_STATE_SLEEP_ Kconfig options 2019-03-26 13:27:55 -04:00
atomic_c.c kernel: fix atomic ops in user mode on some arches 2019-03-18 09:18:00 -04:00
compiler_stack_protect.c all: Update reserved function names 2019-03-11 13:48:42 -04:00
device.c all: Add 'U' suffix when using unsigned variables 2019-03-28 17:15:58 -05:00
errno.c all: Update reserved function names 2019-03-11 13:48:42 -04:00
futex.c kernel: add futex support 2019-06-24 15:38:21 -07:00
idle.c kernel: idle: exclude no-op funcs from coverage 2019-06-18 09:08:01 -04:00
init.c BOOT_BANNER: show KERNEL_VERSION and BUILD_VERSION differently 2019-06-19 15:48:08 -04:00
mailbox.c k_stack: make it 64-bit compatible 2019-06-14 05:46:29 -04:00
mem_domain.c kernel: mem_domain: update name/doc of API function for partition add 2019-05-02 11:37:38 -04:00
mem_slab.c mem_slab: rationalize block alignment assertion 2019-06-20 08:42:45 -04:00
mempool.c linker generated list: provide an iterator to simplify list access 2019-06-06 14:21:32 -07:00
msg_q.c linker generated list: provide an iterator to simplify list access 2019-06-06 14:21:32 -07:00
mutex.c linker generated list: provide an iterator to simplify list access 2019-06-06 14:21:32 -07:00
pipes.c docs: fix misspelling across the tree 2019-06-19 15:34:13 -05:00
poll.c misc: Replace uses of __builtin_*_overflow() with <misc/math_extras.h>. 2019-05-14 19:53:30 -05:00
queue.c linker generated list: provide an iterator to simplify list access 2019-06-06 14:21:32 -07:00
sched.c kernel: allow k_sleep(K_FOREVER) 2019-06-18 09:08:01 -04:00
sem.c linker generated list: provide an iterator to simplify list access 2019-06-06 14:21:32 -07:00
smp.c kernel/smp: Rename smp_init() 2019-06-05 17:15:55 -04:00
stack.c k_stack: make it 64-bit compatible 2019-06-14 05:46:29 -04:00
system_work_q.c
thread.c kernel: introduce k_float_disable system call 2019-06-12 09:17:45 -07:00
thread_abort.c kernel/thread_abort: Swap, don't reschedule when aborting _current 2019-06-03 12:03:48 -07:00
timeout.c kernel: timeout: add syscall for runtime clk freq 2019-05-22 23:33:55 +02:00
timer.c linker generated list: provide an iterator to simplify list access 2019-06-06 14:21:32 -07:00
userspace.c mbedtls: move to external module 2019-06-11 08:33:53 -04:00
userspace_handler.c all: Update reserved function names 2019-03-11 13:48:42 -04:00
version.c
work_q.c kernel: Fix usage of CONFIG_SYS_CLOCK_EXISTS 2019-05-15 10:44:59 +02:00