Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Condition variables #28406

Closed
carlescufi opened this issue Sep 15, 2020 · 1 comment · Fixed by #27732
Closed

Condition variables #28406

carlescufi opened this issue Sep 15, 2020 · 1 comment · Fixed by #27732
Assignees
Labels
area: Kernel Feature A planned feature with a milestone
Milestone

Comments

@carlescufi
Copy link
Member

Zephyr kernel APIs that cover:

pthread_cond_wait
pthread_cond_timedwait
pthread_cond_signal
pthread_cond_broadcast
@carlescufi carlescufi added Enhancement Changes/Updates/Additions to existing features area: Kernel labels Sep 15, 2020
@carlescufi carlescufi added this to the v2.5.0 milestone Sep 15, 2020
@nashif
Copy link
Member

nashif commented Sep 22, 2020

Draft API for condition variables...

/**
 * @brief Initialize a condition variable
 *
 * @param condvar pointer to a @p k_condvar structure
 * @retval 0 Condition variable created successfully
 */
__syscall int k_condvar_init(struct k_condvar *condvar);

/**
 * @brief Signals one thread that is pending on the condition variable
 *
 *
 * @param condvar pointer to a @p k_condvar structure
 * @retval 0 On success
 */
__syscall int k_condvar_signal(struct k_condvar *condvar);

/**
 * @brief Broadcast to all threads that are pending on the condition variable
 *
 * @param condvar pointer to a @p k_condvar structure
 * @retval 0 On success
 */
__syscall int k_condvar_broadcast(struct k_condvar *condvar);

/**
 * @brief Waits on the condition variable releasing the mutex lock
 *
 * Automically releases the currently owned mutex, blocks the current thread
 * waiting on the condition variable specified by @a condvar,
 * and finally acquires the mutex again.
 *
 * The waiting thread unblocks only after another thread calls k_condvar_signal, or
 * k_condvar_broadcast with the same condition variable.
 *
 * @param condvar pointer to a @p k_condvar structure
 * @param mutex Address of the mutex.
 * @param timeout Waiting period for the condition variable in ms
 *                or one of the special values K_NO_WAIT and K_FOREVER.
 * @return
 */
__syscall int k_condvar_wait(struct k_condvar *condvar, struct k_mutex *mutex,
			     k_timeout_t timeout);

/**
 * @brief Statically define and initialize a condition variable.
 *
 * The condition variable can be accessed outside the module where it is defined using:
 *
 * @code extern struct k_condvar <name>; @endcode
 *
 * @param name Name of the condition variable.
 */
#define K_CONDVAR_DEFINE(name)                                                 \
	Z_STRUCT_SECTION_ITERABLE(k_condvar, name) =                           \
		Z_CONDVAR_INITIALIZER(name);

@nashif nashif added Feature A planned feature with a milestone and removed Enhancement Changes/Updates/Additions to existing features labels Sep 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Kernel Feature A planned feature with a milestone
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants