diff --git a/include/kernel.h b/include/kernel.h index 7d1a777e080..886a64aec3a 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -2139,17 +2139,6 @@ struct z_futex_data { * @{ */ -/** - * @brief Initialize a futex. - * - * This routine initializes a futex object, prior to its first use. - * - * @param futex Address of the k_futex. - * - * @return N/A - */ -__syscall void k_futex_init(struct k_futex *futex); - /** * @brief Pend the current thread on a futex * diff --git a/kernel/futex.c b/kernel/futex.c index 19f958f2784..e1c88d0a796 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -24,23 +24,6 @@ static struct z_futex_data *k_futex_find_data(struct k_futex *futex) return (struct z_futex_data *)obj->data; } -void z_impl_k_futex_init(struct k_futex *futex) -{ - futex->val = 0U; - z_object_init(futex); -} - -Z_SYSCALL_HANDLER(k_futex_init, futex) -{ - if (Z_SYSCALL_MEMORY_WRITE(futex, sizeof(struct k_futex)) != 0) { - return -EACCES; - } - - z_impl_k_futex_init((struct k_futex *)futex); - - return 0; -} - int z_impl_k_futex_wake(struct k_futex *futex, bool wake_all) { k_spinlock_key_t key; diff --git a/tests/kernel/mem_protect/futex/src/main.c b/tests/kernel/mem_protect/futex/src/main.c index f446b2aa33e..f7e2143bf9c 100644 --- a/tests/kernel/mem_protect/futex/src/main.c +++ b/tests/kernel/mem_protect/futex/src/main.c @@ -161,8 +161,7 @@ void test_futex_wait_forever(void) { timeout = K_FOREVER; - k_futex_init(&simple_futex); - atomic_inc(&simple_futex.val); + atomic_set(&simple_futex.val, 1); k_thread_create(&futex_tid, stack_1, STACK_SIZE, futex_wait_task, &timeout, NULL, NULL, @@ -182,8 +181,7 @@ void test_futex_wait_timeout(void) { timeout = K_MSEC(50); - k_futex_init(&simple_futex); - atomic_inc(&simple_futex.val); + atomic_set(&simple_futex.val, 1); k_thread_create(&futex_tid, stack_1, STACK_SIZE, futex_wait_task, &timeout, NULL, NULL, @@ -203,8 +201,7 @@ void test_futex_wait_nowait(void) { timeout = K_NO_WAIT; - k_futex_init(&simple_futex); - atomic_inc(&simple_futex.val); + atomic_set(&simple_futex.val, 1); k_thread_create(&futex_tid, stack_1, STACK_SIZE, futex_wait_task, &timeout, NULL, NULL, @@ -227,8 +224,7 @@ void test_futex_wait_forever_wake(void) woken = 1; timeout = K_FOREVER; - k_futex_init(&simple_futex); - atomic_inc(&simple_futex.val); + atomic_set(&simple_futex.val, 1); k_thread_create(&futex_tid, stack_1, STACK_SIZE, futex_wait_wake_task, &timeout, NULL, NULL, @@ -261,8 +257,7 @@ void test_futex_wait_timeout_wake(void) woken = 1; timeout = K_MSEC(100); - k_futex_init(&simple_futex); - atomic_inc(&simple_futex.val); + atomic_set(&simple_futex.val, 1); k_thread_create(&futex_tid, stack_1, STACK_SIZE, futex_wait_wake_task, &timeout, NULL, NULL, @@ -295,8 +290,7 @@ void test_futex_wait_nowait_wake(void) woken = 0; timeout = K_NO_WAIT; - k_futex_init(&simple_futex); - atomic_inc(&simple_futex.val); + atomic_set(&simple_futex.val, 1); k_thread_create(&futex_tid, stack_1, STACK_SIZE, futex_wait_wake_task, &timeout, NULL, NULL, @@ -322,8 +316,7 @@ void test_futex_wait_forever_wake_from_isr(void) { timeout = K_FOREVER; - k_futex_init(&simple_futex); - atomic_inc(&simple_futex.val); + atomic_set(&simple_futex.val, 1); k_thread_create(&futex_tid, stack_1, STACK_SIZE, futex_wait_wake_task, &timeout, NULL, NULL, @@ -349,7 +342,7 @@ void test_futex_multiple_threads_wait_wake(void) timeout = K_FOREVER; woken = TOTAL_THREADS_WAITING; - k_futex_init(&simple_futex); + atomic_clear(&simple_futex.val); for (int i = 0; i < TOTAL_THREADS_WAITING; i++) { atomic_inc(&simple_futex.val); @@ -386,8 +379,7 @@ void test_multiple_futex_wait_wake(void) for (int i = 0; i < TOTAL_THREADS_WAITING; i++) { index[i] = i; - k_futex_init(&multiple_futex[i]); - atomic_inc(&multiple_futex[i].val); + atomic_set(&multiple_futex[i].val, 1); k_thread_create(&multiple_tid[i], multiple_stack[i], STACK_SIZE, futex_multiple_wait_wake_task, &timeout, &index[i], NULL, PRIO_WAIT,