condvar.h 854 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2023-11-20 Shell Add cond var API in kernel
  9. */
  10. #ifndef IPC_CONDVAR_H__
  11. #define IPC_CONDVAR_H__
  12. #include <rtthread.h>
  13. typedef struct rt_condvar
  14. {
  15. #ifdef USING_RT_OBJECT
  16. struct rt_object parent;
  17. #endif
  18. rt_atomic_t waiters_cnt;
  19. rt_atomic_t waiting_mtx;
  20. struct rt_wqueue event;
  21. } *rt_condvar_t;
  22. void rt_condvar_init(rt_condvar_t cv, char *name);
  23. int rt_condvar_timedwait(rt_condvar_t cv, rt_mutex_t mtx, int suspend_flag,
  24. rt_tick_t timeout);
  25. int rt_condvar_signal(rt_condvar_t cv);
  26. int rt_condvar_broadcast(rt_condvar_t cv);
  27. rt_inline void rt_condvar_detach(rt_condvar_t cv)
  28. {
  29. RT_UNUSED(cv);
  30. return ;
  31. }
  32. #endif /* IPC_CONDVAR_H__ */