Home
last modified time | relevance | path

Searched full:semaphore (Results 1 – 25 of 340) sorted by relevance

12345678910>>...14

/Zephyr-latest/doc/kernel/services/synchronization/
Dsemaphores.rst6 A :dfn:`semaphore` is a kernel object that implements a traditional
7 counting semaphore.
17 semaphore is referenced by its memory address.
19 A semaphore has the following key properties:
21 * A **count** that indicates the number of times the semaphore can be taken.
22 A count of zero indicates that the semaphore is unavailable.
24 * A **limit** that indicates the maximum value the semaphore's count
27 A semaphore must be initialized before it can be used. Its count must be set
30 A semaphore may be **given** by a thread or an ISR. Giving the semaphore
33 A semaphore may be **taken** by a thread. Taking the semaphore
[all …]
/Zephyr-latest/subsys/portability/cmsis_rtos_v2/
Dsemaphore.c22 * @brief Create and Initialize a semaphore object.
27 struct cv2_sem *semaphore; in osSemaphoreNew() local
38 (void **)&semaphore, K_MSEC(100)) == 0) { in osSemaphoreNew()
39 (void)memset(semaphore, 0, sizeof(struct cv2_sem)); in osSemaphoreNew()
44 k_sem_init(&semaphore->z_semaphore, initial_count, max_count); in osSemaphoreNew()
47 strncpy(semaphore->name, init_sema_attrs.name, in osSemaphoreNew()
48 sizeof(semaphore->name) - 1); in osSemaphoreNew()
50 strncpy(semaphore->name, attr->name, in osSemaphoreNew()
51 sizeof(semaphore->name) - 1); in osSemaphoreNew()
54 return (osSemaphoreId_t)semaphore; in osSemaphoreNew()
[all …]
/Zephyr-latest/subsys/portability/cmsis_rtos_v1/
Dcmsis_semaphore.c15 * @brief Create and Initialize a semaphore object.
20 struct k_sem *semaphore; in osSemaphoreCreate() local
31 (void **)&semaphore, K_MSEC(100)) == 0) { in osSemaphoreCreate()
32 (void)memset(semaphore, 0, sizeof(struct k_sem)); in osSemaphoreCreate()
37 k_sem_init(semaphore, count, count); in osSemaphoreCreate()
39 return (osSemaphoreId)semaphore; in osSemaphoreCreate()
43 * @brief Wait until a semaphore becomes available.
47 struct k_sem *semaphore = (struct k_sem *) semaphore_id; in osSemaphoreWait() local
59 status = k_sem_take(semaphore, K_FOREVER); in osSemaphoreWait()
61 status = k_sem_take(semaphore, K_NO_WAIT); in osSemaphoreWait()
[all …]
/Zephyr-latest/tests/subsys/portability/cmsis_rtos_v2/src/
Dsemaphore.c19 /* Try taking semaphore immediately when it is not available */ in thread_sema()
22 "Semaphore acquired unexpectedly!"); in thread_sema()
24 /* Try taking semaphore after a TIMEOUT, but before release */ in thread_sema()
27 "Semaphore acquired unexpectedly!"); in thread_sema()
29 /* This delay ensures that the semaphore gets released by the other in thread_sema()
34 /* Now that the semaphore is free, it should be possible to acquire in thread_sema()
38 zassert_true(status == osOK, "Semaphore could not be acquired"); in thread_sema()
41 "Semaphore release failure"); in thread_sema()
43 /* Try releasing when no semaphore is obtained */ in thread_sema()
46 "Semaphore released unexpectedly!"); in thread_sema()
[all …]
/Zephyr-latest/soc/st/stm32/common/
Dstm32_hsem.h14 /** HW semaphore Complement ID list defined in hw_conf.h from STM32WB
18 * Index of the semaphore used by CPU2 to prevent the CPU1 to either write or
20 * this semaphore is taken by the CPU2. When the CPU1 needs to either write or
21 * erase in flash, it shall first get the semaphore and release it just
23 * On v1.4.0 and older CPU2 wireless firmware, this semaphore is unused and
25 * timing. The CPU1 may request the CPU2 to use the semaphore instead of the
31 * Index of the semaphore used by CPU1 to prevent the CPU2 to either write or
33 * semaphore to prevent the CPU2 to either write or erase in flash
40 * Index of the semaphore used to manage the CLK48 clock configuration
41 * When the USB is required, this semaphore shall be taken before configuring
[all …]
/Zephyr-latest/tests/subsys/portability/cmsis_rtos_v1/src/
Dsemaphore.c19 /* Try taking semaphore immediately when it is not available */ in thread_sema()
22 "Semaphore acquired unexpectedly!"); in thread_sema()
24 /* Try taking semaphore after a TIMEOUT, but before release */ in thread_sema()
27 "Semaphore acquired unexpectedly!"); in thread_sema()
29 /* This delay ensures that the semaphore gets released by the other in thread_sema()
34 /* Now that the semaphore is free, it should be possible to acquire in thread_sema()
41 "Semaphore release failure"); in thread_sema()
43 /* Try releasing when no semaphore is obtained */ in thread_sema()
45 "Semaphore released unexpectedly!"); in thread_sema()
57 zassert_true(semaphore_id != NULL, "semaphore creation failed"); in ZTEST()
[all …]
/Zephyr-latest/lib/posix/options/
Dsemaphore.c13 #include <zephyr/posix/semaphore.h>
52 /* Clean up a named semaphore object completely (incl its `name` buffer) */
63 /* Remove a named semaphore if it isn't unsed */
80 * @brief Destroy semaphore.
84 int sem_destroy(sem_t *semaphore) in sem_destroy() argument
86 if (semaphore == NULL) { in sem_destroy()
91 if (k_sem_count_get(semaphore)) { in sem_destroy()
96 k_sem_reset(semaphore); in sem_destroy()
101 * @brief Get value of semaphore.
105 int sem_getvalue(sem_t *semaphore, int *value) in sem_getvalue() argument
[all …]
DKconfig.semaphore6 bool "POSIX semaphore support"
8 Enable this option for POSIX semaphore support.
13 int "Maximum semaphore value"
17 Maximum semaphore count in POSIX compliant Application.
29 int "Maximum semaphore name length"
33 Maximum length of name for a named semaphore.
/Zephyr-latest/include/zephyr/posix/
Dsemaphore.h18 int sem_destroy(sem_t *semaphore);
19 int sem_getvalue(sem_t *ZRESTRICT semaphore, int *ZRESTRICT value);
20 int sem_init(sem_t *semaphore, int pshared, unsigned int value);
21 int sem_post(sem_t *semaphore);
22 int sem_timedwait(sem_t *ZRESTRICT semaphore, struct timespec *ZRESTRICT abstime);
23 int sem_trywait(sem_t *semaphore);
24 int sem_wait(sem_t *semaphore);
/Zephyr-latest/samples/cpp/cpp_synchronization/src/
Dmain.cpp27 * @class semaphore the basic pure virtual semaphore class
29 class semaphore { class
45 * @brief Semaphore
47 * Class derives from the pure virtual semaphore class and
48 * implements it's methods for the semaphore
50 class cpp_semaphore: public semaphore {
66 printk("Create semaphore %p\n", this); in cpp_semaphore()
71 * @brief wait for a semaphore
73 * Test a semaphore to see if it has been signaled. If the signal
76 * @return 1 when semaphore is available
[all …]
/Zephyr-latest/tests/kernel/semaphore/semaphore/src/
Dmain.c108 void isr_sem_give(const void *semaphore) in isr_sem_give() argument
110 k_sem_give((struct k_sem *)semaphore); in isr_sem_give()
136 void isr_sem_take(const void *semaphore) in isr_sem_take() argument
138 int ret = k_sem_take((struct k_sem *)semaphore, K_NO_WAIT); in isr_sem_take()
194 * when semaphore is taken by current thread, and no other in sem_queue_mutual_exclusion1()
213 * when semaphore is taken by current thread, and no other in sem_queue_mutual_exclusion2()
236 * @brief Test semaphore defined at compile time
238 * - Get the semaphore count.
239 * - Verify the semaphore count equals to initialized value.
243 ZTEST_USER(semaphore, test_k_sem_define) in ZTEST_USER() argument
[all …]
/Zephyr-latest/include/zephyr/sys/
Dsem.h17 * sys_sem exists in user memory working as counter semaphore for
45 * @defgroup user_semaphore_apis User mode semaphore APIs
53 * The semaphore can be accessed outside the module where it is defined using:
59 * @param _name Name of the semaphore.
60 * @param _initial_count Initial semaphore count.
61 * @param _count_limit Maximum permitted semaphore count.
85 * @brief Initialize a semaphore.
87 * This routine initializes a semaphore instance, prior to its first use.
89 * @param sem Address of the semaphore.
90 * @param initial_count Initial semaphore count.
[all …]
/Zephyr-latest/tests/benchmarks/latency_measure/src/
Dsema_test_signal_release.c11 * This file contains the test that measures semaphore give and take time
12 * in the kernel. There is no contention on the semaphore being tested.
33 * 2. Give the semaphore, thereby forcing a context switch back in alt_thread_entry()
68 * 1. Block on taking the semaphore and force a context switch in start_thread_entry()
137 /* Retrieve the number of cycles spent taking the semaphore */ in sema_context_switch()
143 "semaphore.take.blocking.%c_to_%c", in sema_context_switch()
147 "%-40s - Take a semaphore (context switch)", tag); in sema_context_switch()
155 /* Retrieve the number of cycles spent taking the semaphore */ in sema_context_switch()
161 "semaphore.give.wake+ctx.%c_to_%c", in sema_context_switch()
165 "%-40s - Give a semaphore (context switch)", tag); in sema_context_switch()
[all …]
/Zephyr-latest/subsys/rtio/
DKconfig10 bool "Use a semaphore when waiting for completions in rtio_submit"
14 When calling rtio_submit a semaphore is available to sleep the calling
16 adds a small RAM overhead for a single semaphore. By default wait_for will
22 bool "Use a semaphore when waiting for completions in rtio_cqe_consume_block"
26 When calling rtio_cqe_consume_block a semaphore is available to sleep the
28 This adds a small RAM overhead for a single semaphore. By default the call
/Zephyr-latest/tests/posix/headers/src/
Dsemaphore_h.c10 #include <semaphore.h>
12 #include <zephyr/posix/semaphore.h>
16 * @brief existence test for `<semaphore.h>`
18 …a href="https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/semaphore.h.html">semaphore.h</a>
/Zephyr-latest/tests/posix/semaphores/
DKconfig5 int "Number of loops in semaphore test"
9 This option is specific to semaphore.test_named_semaphore in semaphore.c
/Zephyr-latest/tests/posix/common/
DKconfig28 int "Number of loops in semaphore test"
32 This option is specific to semaphore.test_named_semaphore in semaphore.c
/Zephyr-latest/tests/benchmarks/latency_measure/
DREADME.rst11 * Time to signal a semaphore then test that semaphore
12 * Time to signal a semaphore then test that semaphore with a context switch
94semaphore.give.immediate.kernel - Give a semaphore (no waiters) : …
95semaphore.take.immediate.kernel - Take a semaphore (no blocking) : …
96semaphore.take.blocking.k_to_k - Take a semaphore (context switch) : …
97semaphore.give.wake+ctx.k_to_k - Give a semaphore (context switch) : …
147semaphore.give.immediate.kernel - Give a semaphore (no waiters) : …
148semaphore.take.immediate.kernel - Take a semaphore (no blocking) : …
149semaphore.take.blocking.k_to_k - Take a semaphore (context switch) : …
150semaphore.give.wake+ctx.k_to_k - Give a semaphore (context switch) : …
[all …]
/Zephyr-latest/drivers/ipm/
Dipm_stm32_hsem.c54 /* Check semaphore rx_semid interrupt status */ in stm32_hsem_mailbox_ipm_rx_isr()
64 /* Clear semaphore rx_semid interrupt status and masked status */ in stm32_hsem_mailbox_ipm_rx_isr()
97 /* Lock the semaphore tx_semid */ in stm32_hsem_mailbox_ipm_send()
101 * Release the semaphore tx_semid. in stm32_hsem_mailbox_ipm_send()
141 /* Clear semaphore rx_semid interrupt status and masked status */ in stm32_hsem_mailbox_ipm_set_enabled()
143 /* Enable semaphore rx_semid on HESMx interrupt */ in stm32_hsem_mailbox_ipm_set_enabled()
146 /* Disable semaphore rx_semid on HSEMx interrupt */ in stm32_hsem_mailbox_ipm_set_enabled()
159 /* Config transfer semaphore */ in stm32_hsem_mailbox_init()
206 * The ipm_stm32_hsem driver only picks up two semaphore IDs from stm32_hsem.h to simulate
/Zephyr-latest/tests/posix/semaphores/src/
Dmain.c11 #include <semaphore.h>
39 /* TESTPOINT: Check if semaphore value is as set */ in semaphore_test()
61 /* TESTPOINT: Semaphore is already acquired, check if in semaphore_test()
62 * no semaphore is available in semaphore_test()
67 zassert_equal(sem_destroy(sem), 0, "semaphore is not destroyed"); in semaphore_test()
75 "acquired semaphore" in semaphore_test()
79 /* TESTPOINT: take semaphore which is initialized with 1 */ in semaphore_test()
84 /* TESTPOINT: Wait and acquire semaphore till thread2 gives */ in semaphore_test()
99 " invalid semaphore object didn't fail"); in ZTEST()
105 " semaphore is destroyed"); in ZTEST()
[all …]
/Zephyr-latest/tests/kernel/semaphore/sys_sem/src/
Dmain.c30 * @defgroup kernel_sys_sem_tests Semaphore
69 * @brief Test semaphore usage with multiple thread
71 * @details Using semaphore with some situations
72 * - Use a uninitialized semaphore
73 * - Use semaphore normally
74 * - Use semaphore with different priority threads
82 /* Use a semaphore to synchronize processing between threads */ in ZTEST_USER()
163 * @brief Test max semaphore can be give and take with multiple thread
166 * - Define and initialize semaphore and thread.
168 * - Verify more than max count about semaphore can reach.
/Zephyr-latest/soc/st/stm32/stm32wbx/
Dpower.c47 /* Release ENTRY_STOP_MODE semaphore */ in lpm_hsem_lock()
83 /* Release RCC semaphore */ in pm_state_set()
91 * Release CLK48 semaphore to make sure M0 core can enable/disable in pm_state_set()
100 /* Release RCC semaphore */ in pm_state_set()
117 /* Release ENTRY_STOP_MODE semaphore */ in pm_state_exit_post_ops()
142 /* Release RCC semaphore */ in pm_state_exit_post_ops()
/Zephyr-latest/tests/kernel/mem_protect/sys_sem/src/
Dmain.c36 static void isr_sem_give(const void *semaphore) in isr_sem_give() argument
38 sys_sem_give((struct sys_sem *)semaphore); in isr_sem_give()
41 static void isr_sem_take(const void *semaphore) in isr_sem_take() argument
43 sys_sem_take((struct sys_sem *)semaphore, K_NO_WAIT); in isr_sem_take()
46 static void sem_give_from_isr(void *semaphore) in sem_give_from_isr() argument
48 irq_offload(isr_sem_give, (const void *)semaphore); in sem_give_from_isr()
51 static void sem_take_from_isr(void *semaphore) in sem_take_from_isr() argument
53 irq_offload(isr_sem_take, (const void *)semaphore); in sem_take_from_isr()
115 /* get blocked until the test thread gives the semaphore */ in sem_multiple_threads_wait_helper()
156 * @brief Test semaphore count when given by an ISR
[all …]
/Zephyr-latest/tests/benchmarks/sys_kernel/src/
Dsema.c28 * @brief Semaphore test thread
52 * @brief Semaphore test thread
76 * @brief Semaphore test thread
114 "Semaphore #1"); in sema_test()
137 "Semaphore #2"); in sema_test()
162 "Semaphore #3"); in sema_test()
/Zephyr-latest/samples/cpp/cpp_synchronization/
Dsample.yaml15 - "Create semaphore (.*)"
32 - "Create semaphore (.*)"

12345678910>>...14