/Zephyr-latest/kernel/ |
D | sem.c | 45 int z_impl_k_sem_init(struct k_sem *sem, unsigned int initial_count, in z_impl_k_sem_init() argument 52 SYS_PORT_TRACING_OBJ_FUNC(k_sem, init, sem, -EINVAL); in z_impl_k_sem_init() 57 sem->count = initial_count; in z_impl_k_sem_init() 58 sem->limit = limit; in z_impl_k_sem_init() 60 SYS_PORT_TRACING_OBJ_FUNC(k_sem, init, sem, 0); in z_impl_k_sem_init() 62 z_waitq_init(&sem->wait_q); in z_impl_k_sem_init() 64 sys_dlist_init(&sem->poll_events); in z_impl_k_sem_init() 66 k_object_init(sem); in z_impl_k_sem_init() 69 k_obj_core_init_and_link(K_OBJ_CORE(sem), &obj_type_sem); in z_impl_k_sem_init() 76 int z_vrfy_k_sem_init(struct k_sem *sem, unsigned int initial_count, in z_vrfy_k_sem_init() argument [all …]
|
/Zephyr-latest/lib/os/ |
D | sem.c | 47 int sys_sem_init(struct sys_sem *sem, unsigned int initial_count, in sys_sem_init() argument 50 if ((sem == NULL) || (limit == SYS_SEM_MINIMUM) || in sys_sem_init() 55 (void)atomic_set(&sem->futex.val, initial_count); in sys_sem_init() 56 sem->limit = limit; in sys_sem_init() 61 int sys_sem_give(struct sys_sem *sem) in sys_sem_give() argument 66 old_value = bounded_inc(&sem->futex.val, in sys_sem_give() 67 SYS_SEM_MINIMUM, sem->limit); in sys_sem_give() 69 ret = k_futex_wake(&sem->futex, true); in sys_sem_give() 74 } else if (old_value >= sem->limit) { in sys_sem_give() 82 int sys_sem_take(struct sys_sem *sem, k_timeout_t timeout) in sys_sem_take() argument [all …]
|
/Zephyr-latest/tests/kernel/mem_protect/obj_validation/src/ |
D | main.c | 29 static int test_object(struct k_sem *sem, int retval) in test_object() argument 37 ret = k_object_validate(k_object_find(sem), K_OBJ_SEM, 0); in test_object() 39 ret = k_object_validation_check(k_object_find(sem), sem, in test_object() 44 TC_PRINT("FAIL check of %p is not %d, got %d instead\n", sem, in test_object() 51 void object_permission_checks(struct k_sem *sem, bool skip_init) in object_permission_checks() argument 54 zassert_false(test_object(sem, -EPERM), in object_permission_checks() 57 k_object_access_grant(sem, k_current_get()); in object_permission_checks() 61 zassert_false(test_object(sem, -EINVAL), in object_permission_checks() 63 k_sem_init(sem, 0, 1); in object_permission_checks() 67 zassert_false(test_object(sem, 0), in object_permission_checks()
|
/Zephyr-latest/include/zephyr/sys/ |
D | sem.h | 97 int sys_sem_init(struct sys_sem *sem, unsigned int initial_count, 113 int sys_sem_give(struct sys_sem *sem); 129 int sys_sem_take(struct sys_sem *sem, k_timeout_t timeout); 140 unsigned int sys_sem_count_get(struct sys_sem *sem); 207 #define SYS_SEM_LOCK(sem) \ argument 208 for (int __rc SYS_SEM_LOCK_ONEXIT = sys_sem_take((sem), K_FOREVER); ({ \ 213 __rc = sys_sem_give((sem)); \
|
/Zephyr-latest/tests/posix/semaphores/src/ |
D | main.c | 18 sem_t *sem = (sem_t *)p1; in child_func() local 20 zassert_equal(sem_post(sem), 0, "sem_post failed"); in child_func() 24 static void semaphore_test(sem_t *sem) in semaphore_test() argument 33 zassert_equal(sem_init(sem, 0, (CONFIG_POSIX_SEM_VALUE_MAX + 1)), -1, in semaphore_test() 37 zassert_equal(sem_init(sem, 0, 0), 0, "sem_init failed"); in semaphore_test() 40 zassert_equal(sem_getvalue(sem, &val), 0); in semaphore_test() 46 zassert_equal(sem_trywait(sem), -1); in semaphore_test() 49 ret = pthread_create(&thread1, NULL, child_func, sem); in semaphore_test() 59 zassert_equal(sem_timedwait(sem, &abstime), 0); in semaphore_test() 64 zassert_equal(sem_timedwait(sem, &abstime), -1); in semaphore_test() [all …]
|
/Zephyr-latest/tests/arch/arm/arm_irq_vector_table/src/ |
D | arm_irq_vector_table.c | 39 struct k_sem sem[3]; variable 50 k_sem_give(&sem[0]); in isr0() 63 k_sem_give(&sem[1]); in isr1() 76 k_sem_give(&sem[2]); in isr2() 106 k_sem_init(&sem[ii], 0, K_SEM_MAX_LIMIT); in ZTEST() 109 zassert_true((k_sem_take(&sem[0], K_NO_WAIT) || in ZTEST() 110 k_sem_take(&sem[1], K_NO_WAIT) || in ZTEST() 111 k_sem_take(&sem[2], K_NO_WAIT)), NULL); in ZTEST() 125 zassert_false((k_sem_take(&sem[0], K_NO_WAIT) || in ZTEST() 126 k_sem_take(&sem[1], K_NO_WAIT) || in ZTEST() [all …]
|
/Zephyr-latest/tests/benchmarks/latency_measure/src/ |
D | sema_test_signal_release.c | 20 static struct k_sem sem; variable 38 k_sem_give(&sem); in alt_thread_entry() 46 k_sem_give(&sem); in alt_thread_entry() 73 k_sem_take(&sem, K_FOREVER); in start_thread_entry() 84 k_sem_take(&sem, K_FOREVER); in start_thread_entry() 100 k_sem_take(&sem, K_FOREVER); in start_thread_entry() 129 k_thread_access_grant(&start_thread, &sem, &alt_thread); in sema_context_switch() 131 k_thread_access_grant(&alt_thread, &sem); in sema_context_switch() 153 k_sem_give(&sem); in sema_context_switch() 197 k_sem_give(&sem); in immediate_give_take() [all …]
|
D | int_to_thread.c | 41 struct k_sem *sem = (struct k_sem *)arg; in test_isr() local 44 k_sem_give(sem); in test_isr() 75 struct k_sem *sem = p2; in start_thread_entry() local 85 (void) k_sem_take(sem, K_NO_WAIT); in start_thread_entry() 92 k_sem_take(sem, K_FOREVER); in start_thread_entry() 108 struct k_sem *sem = p2; in alt_thread_entry() local 116 irq_offload(test_isr, sem); in alt_thread_entry()
|
/Zephyr-latest/drivers/misc/ethos_u/ |
D | ethos_u.c | 63 struct k_sem *sem; in ethosu_semaphore_create() local 65 sem = k_malloc(sizeof(*sem)); in ethosu_semaphore_create() 66 if (sem == NULL) { in ethosu_semaphore_create() 71 k_sem_init(sem, 0, 100); in ethosu_semaphore_create() 73 return (void *)sem; in ethosu_semaphore_create() 76 int ethosu_semaphore_take(void *sem, uint64_t timeout) in ethosu_semaphore_take() argument 80 status = k_sem_take((struct k_sem *)sem, (timeout == ETHOSU_SEMAPHORE_WAIT_FOREVER) in ethosu_semaphore_take() 102 int ethosu_semaphore_give(void *sem) in ethosu_semaphore_give() argument 104 k_sem_give((struct k_sem *)sem); in ethosu_semaphore_give()
|
/Zephyr-latest/subsys/zbus/ |
D | zbus_runtime_observers.c | 22 err = k_sem_take(&chan->data->sem, timeout); in zbus_chan_add_obs() 34 k_sem_give(&chan->data->sem); in zbus_chan_add_obs() 43 k_sem_give(&chan->data->sem); in zbus_chan_add_obs() 54 k_sem_give(&chan->data->sem); in zbus_chan_add_obs() 63 k_sem_give(&chan->data->sem); in zbus_chan_add_obs() 79 err = k_sem_take(&chan->data->sem, timeout); in zbus_chan_rm_obs() 90 k_sem_give(&chan->data->sem); in zbus_chan_rm_obs() 98 k_sem_give(&chan->data->sem); in zbus_chan_rm_obs()
|
/Zephyr-latest/tests/bsim/bluetooth/mesh/src/ |
D | test_replay_cache.c | 55 struct k_sem *sem = data; in tx_ended() local 65 k_sem_give(sem); in tx_ended() 130 struct k_sem sem; in test_tx_immediate_replay_attack() local 132 k_sem_init(&sem, 0, 1); in test_tx_immediate_replay_attack() 141 &send_cb, &sem)); in test_tx_immediate_replay_attack() 143 if (k_sem_take(&sem, K_SECONDS(TEST_DATA_WAITING_TIME))) { in test_tx_immediate_replay_attack() 159 &send_cb, &sem)); in test_tx_immediate_replay_attack() 161 if (k_sem_take(&sem, K_SECONDS(TEST_DATA_WAITING_TIME))) { in test_tx_immediate_replay_attack() 195 struct k_sem sem; in test_tx_power_replay_attack() local 197 k_sem_init(&sem, 0, 1); in test_tx_power_replay_attack() [all …]
|
D | test_iv_index.c | 30 struct k_sem *sem = data; in async_send_end() local 32 if (sem) { in async_send_end() 33 k_sem_give(sem); in async_send_end() 132 struct k_sem sem; in test_ivu_deferring() local 134 k_sem_init(&sem, 0, 1); in test_ivu_deferring() 141 &sem)); in test_ivu_deferring() 145 ASSERT_OK(k_sem_take(&sem, K_SECONDS(10))); in test_ivu_deferring()
|
/Zephyr-latest/drivers/mdio/ |
D | mdio_stm32_hal.c | 25 struct k_sem sem; member 41 k_sem_take(&dev_data->sem, K_FOREVER); in mdio_stm32_read() 45 k_sem_give(&dev_data->sem); in mdio_stm32_read() 63 k_sem_take(&dev_data->sem, K_FOREVER); in mdio_stm32_write() 67 k_sem_give(&dev_data->sem); in mdio_stm32_write() 97 k_sem_init(&dev_data->sem, 1, 1); in mdio_stm32_init()
|
D | mdio_esp32.c | 25 struct k_sem sem; member 38 k_sem_take(&dev_data->sem, K_FOREVER); in mdio_transfer() 42 k_sem_give(&dev_data->sem); in mdio_transfer() 63 k_sem_give(&dev_data->sem); in mdio_transfer() 71 k_sem_give(&dev_data->sem); in mdio_transfer() 95 k_sem_init(&dev_data->sem, 1, 1); in mdio_esp32_initialize()
|
/Zephyr-latest/lib/posix/options/ |
D | semaphore.c | 17 sem_t sem; member 294 (void)k_sem_init(&nsem->sem, value, CONFIG_POSIX_SEM_VALUE_MAX); in sem_open() 308 return nsem == NULL ? SEM_FAILED : &nsem->sem; in sem_open() 345 int sem_close(sem_t *sem) in sem_close() argument 347 struct nsem_obj *nsem = CONTAINER_OF(sem, struct nsem_obj, sem); in sem_close() 349 if (sem == NULL) { in sem_close() 362 int nsem_get_ref_count(sem_t *sem) in nsem_get_ref_count() argument 364 struct nsem_obj *nsem = CONTAINER_OF(sem, struct nsem_obj, sem); in nsem_get_ref_count() 367 __ASSERT_NO_MSG(sem != NULL); in nsem_get_ref_count()
|
/Zephyr-latest/tests/drivers/uart/uart_errors/src/ |
D | main.c | 51 struct k_sem *sem; member 151 struct k_sem *sem = user_data; in aux_async_callback() local 155 k_sem_give(sem); in aux_async_callback() 182 k_sem_give(data->sem); in aux_int_callback() 239 struct k_sem sem; in aux_tx() local 241 k_sem_init(&sem, 0, 1); in aux_tx() 249 .sem = &sem in aux_tx() 259 err = k_sem_take(&sem, K_MSEC(100)); in aux_tx() 266 err = k_sem_take(&sem, K_MSEC(100)); in aux_tx() 274 err = k_sem_take(&sem, K_MSEC(100)); in aux_tx() [all …]
|
/Zephyr-latest/lib/libc/armstdc/src/ |
D | threading_weak.c | 37 void __weak z_impl_k_sem_give(struct k_sem *sem) in z_impl_k_sem_give() argument 41 int __weak z_impl_k_sem_init(struct k_sem *sem, unsigned int initial_count, in z_impl_k_sem_init() argument 47 int __weak z_impl_k_sem_take(struct k_sem *sem, k_timeout_t timeout) in z_impl_k_sem_take() argument
|
/Zephyr-latest/tests/kernel/queue/src/ |
D | test_queue_user.c | 31 struct k_sem *sem = p2; in child_thread_get() local 57 k_sem_give(sem); in child_thread_get() 80 struct k_sem *sem; in ZTEST() local 90 sem = k_object_alloc(K_OBJ_SEM); in ZTEST() 91 zassert_not_null(sem, "no memory for semaphore object"); in ZTEST() 92 k_sem_init(sem, 0, 1); in ZTEST() 111 child_thread_get, q, sem, NULL, K_HIGHEST_THREAD_PRIO, in ZTEST() 118 k_sem_take(sem, K_FOREVER); in ZTEST()
|
/Zephyr-latest/samples/sensor/fxas21002/src/ |
D | main.c | 11 K_SEM_DEFINE(sem, 0, 1); /* starts off "not available" */ 16 k_sem_give(&sem); in trigger_handler() 40 k_sem_take(&sem, K_FOREVER); in main()
|
/Zephyr-latest/soc/nordic/nrf54h/gpd/ |
D | gpd.c | 34 struct k_sem sem; member 52 .sem = Z_SEM_INITIALIZER(fast_active0.sem, 0, 1), 57 .sem = Z_SEM_INITIALIZER(fast_active1.sem, 0, 1), 62 .sem = Z_SEM_INITIALIZER(fast_main.sem, 0, 1), 67 .sem = Z_SEM_INITIALIZER(slow_active.sem, 0, 1), 72 .sem = Z_SEM_INITIALIZER(slow_main.sem, 0, 1), 105 k_sem_give(&gpd_mgr->sem); in request_cb() 246 (void)k_sem_take(&gpd_mgr->sem, K_FOREVER); in nrf_gpd_request()
|
/Zephyr-latest/samples/sensor/accel_trig/src/ |
D | main.c | 12 K_SEM_DEFINE(sem, 0, 1); /* starts off "not available" */ 26 k_sem_give(&sem); in trigger_handler() 50 k_sem_take(&sem, K_FOREVER); in main()
|
/Zephyr-latest/samples/sensor/magn_trig/src/ |
D | main.c | 12 K_SEM_DEFINE(sem, 0, 1); /* starts off "not available" */ 26 k_sem_give(&sem); in trigger_handler() 50 k_sem_take(&sem, K_FOREVER); in main()
|
/Zephyr-latest/drivers/pwm/ |
D | pwm_capture.c | 17 struct k_sem sem; member 33 k_sem_give(&data->sem); in z_pwm_capture_cycles_callback() 49 k_sem_init(&data.sem, 0, 1); in z_impl_pwm_capture_cycles() 64 err = k_sem_take(&data.sem, timeout); in z_impl_pwm_capture_cycles()
|
/Zephyr-latest/tests/boards/nrf/mram_latency/src/ |
D | main.c | 27 struct k_sem sem; member 38 k_sem_give(&req->sem); in basic_cb() 53 k_sem_init(&req1.sem, 0, 1); in ZTEST() 54 k_sem_init(&req2.sem, 0, 1); in ZTEST() 68 rv = k_sem_take(&req1.sem, K_MSEC(TIMEOUT_MS)); in ZTEST() 73 rv = k_sem_take(&req2.sem, K_MSEC(TIMEOUT_MS)); in ZTEST() 121 k_sem_init(&req.sem, 0, 1); in ZTEST() 128 rv = k_sem_take(&req.sem, K_MSEC(TIMEOUT_MS)); in ZTEST()
|
/Zephyr-latest/drivers/modem/ |
D | modem_cmd_handler.h | 183 struct k_sem *sem, k_timeout_t timeout, int flags); 202 const uint8_t *buf, struct k_sem *sem, in modem_cmd_send_nolock() argument 206 handler_cmds_len, buf, sem, timeout, in modem_cmd_send_nolock() 227 struct k_sem *sem, k_timeout_t timeout) in modem_cmd_send() argument 230 handler_cmds_len, buf, sem, timeout, 0); in modem_cmd_send() 248 struct k_sem *sem, k_timeout_t timeout); 265 size_t cmds_len, struct k_sem *sem,
|