heap_leak_mutex.c 804 B

12345678910111213141516171819202122232425262728293031323334
  1. #include <semLib.h>
  2. #include <private/semLibP.h>
  3. #include "../private.h"
  4. #include "../context.h"
  5. static SEMAPHORE leak_sem;
  6. /*--------------------------------------------------------- */
  7. static void meta_init(void)
  8. {
  9. static bool_t initialised = BOOL_FALSE;
  10. if (BOOL_FALSE == initialised) {
  11. initialised = BOOL_TRUE;
  12. /* initialise the semaphore for the partition */
  13. semMInit(&leak_sem,
  14. SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE);
  15. }
  16. }
  17. /*--------------------------------------------------------- */
  18. void lub_heap_leak_mutex_lock(void)
  19. {
  20. meta_init();
  21. semTake(&leak_sem, WAIT_FOREVER);
  22. }
  23. /*--------------------------------------------------------- */
  24. void lub_heap_leak_mutex_unlock(void)
  25. {
  26. semGive(&leak_sem);
  27. }
  28. /*--------------------------------------------------------- */