gl_mutex.h 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef __GSL_MUTEX_H__
  2. #define __GSL_MUTEX_H__
  3. #include "gl_types.h"
  4. /******************************************************************************/
  5. /*!
  6. * @brief Create and initialize a mutex for use.
  7. *
  8. * @param szName string identifier for the interrupt.
  9. * @param pMutexId Mutex object identifier returned by the API (on success)
  10. *
  11. * @return GL_SUCCESS on success
  12. * @return GL_FAILURE on failure
  13. *
  14. * @note None
  15. *******************************************************************************/
  16. GL_Status_t GL_MutexCreate(char *szName, GL_Mutex_t * pMutexId);
  17. /*******************************************************************************************
  18. * Function: void GL_MutexCreateRecursive(char *szName, GL_Mutex_t * pMutexId)
  19. *
  20. * Parameters:
  21. * szName: string identifier for the interrupt. Up to 16 characters.
  22. * pMutexId: Mutex object identifier returned by the API (on success)
  23. *
  24. *
  25. * Returns: GL_SUCCESS on success
  26. * GL_FAILURE on failure
  27. *
  28. * Description: Create and initialize a mutex with recursive type for use.
  29. * Restrictions:None
  30. ******************************************************************************************/
  31. GL_Status_t GL_MutexCreateRecursive(char *szName, GL_Mutex_t * pMutexId);
  32. /******************************************************************************/
  33. /*!
  34. * @brief Used to delete a Mutex. Regarding tasks waiting on a deleted Mutex, the behavior depends on the underlying OS; the GSL does not guarantee a default behavior (hence, applications should avoid this scenario). Typically, an error is returned to the waiting tasks.
  35. *
  36. * @param pMutexId Mutex object identifier returned by the API (on success)
  37. *
  38. * @return GL_SUCCESS on success
  39. * @return GL_FAILURE on failure
  40. *
  41. * @note None
  42. *******************************************************************************/
  43. GL_Status_t GL_MutexDelete(GL_Mutex_t mutexId);
  44. /******************************************************************************/
  45. /*!
  46. * @brief This locks a mutex. If the mutex is not available, the thread should be blocked until the mutex is available or the thread is awaken by a signal The behavior depends on the underlying OS; the GSL does not guarantee a default behavior (hence, applications should avoid this scenario). Typically, an error is returned to the waiting tasks.
  47. *
  48. * @param mutexId Mutex object identifier
  49. *
  50. * @return GL_SUCCESS on success
  51. * @return GL_FAILURE on failure
  52. *
  53. * @note Cannot be used from ISR.
  54. *******************************************************************************/
  55. GL_Status_t GL_MutexLock(GL_Mutex_t mutexId);
  56. /******************************************************************************/
  57. /*!
  58. * @brief To lock a mutex. If the mutex is not available, an error is is returned.
  59. *
  60. * @param mutexId Mutex object identifier
  61. *
  62. * @return GL_SUCCESS on success
  63. * @return GL_FAILURE on failure
  64. *
  65. * @note Cannot be used from ISR.
  66. *******************************************************************************/
  67. GL_Status_t GL_MutexTryLock(GL_Mutex_t mutexId);
  68. /******************************************************************************/
  69. /*!
  70. * @brief To unlock a mutex. Note that it is undefined behavior to unlock a mutex that is in an unlocked state, or to unlock a mutex that was locked by another thread.
  71. *
  72. * @param mutexId Mutex object identifier
  73. *
  74. * @return GL_SUCCESS on success
  75. * @return GL_FAILURE on failure
  76. *
  77. * @note Cannot be used from ISR.
  78. *******************************************************************************/
  79. GL_Status_t GL_MutexUnlock(GL_Mutex_t mutexId);
  80. #endif // __GL_MUTEX_H__