heap_leak_mutex.c 834 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
  8. meta_init(void)
  9. {
  10. static bool_t initialised = BOOL_FALSE;
  11. if(BOOL_FALSE == initialised)
  12. {
  13. initialised = BOOL_TRUE;
  14. /* initialise the semaphore for the partition */
  15. semMInit(&leak_sem,SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE);
  16. }
  17. }
  18. /*--------------------------------------------------------- */
  19. void
  20. lub_heap_leak_mutex_lock(void)
  21. {
  22. meta_init();
  23. semTake(&leak_sem,WAIT_FOREVER);
  24. }
  25. /*--------------------------------------------------------- */
  26. void
  27. lub_heap_leak_mutex_unlock(void)
  28. {
  29. semGive(&leak_sem);
  30. }
  31. /*--------------------------------------------------------- */