completion.h 904 B

12345678910111213141516171819202122232425262728293031323334353637
  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. */
  9. #ifndef COMPLETION_H_
  10. #define COMPLETION_H_
  11. #include <rtdef.h>
  12. #include <rtconfig.h>
  13. /**
  14. * Completion - A tiny IPC implementation for resource-constrained scenarios
  15. *
  16. * It's an IPC using one CPU word with the encoding:
  17. *
  18. * BIT | MAX-1 ----------------- 1 | 0 |
  19. * CONTENT | suspended_thread & ~1 | completed flag |
  20. */
  21. struct rt_completion
  22. {
  23. /* suspended thread, and completed flag */
  24. rt_base_t susp_thread_n_flag;
  25. };
  26. #define RT_COMPLETION_INIT(comp) {0}
  27. void rt_completion_init(struct rt_completion *completion);
  28. rt_err_t rt_completion_wait(struct rt_completion *completion,
  29. rt_int32_t timeout);
  30. void rt_completion_done(struct rt_completion *completion);
  31. #endif