Projektarbeit Line Following Robot bei Prof. Chowanetz im WS22/23
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vcos_mutex.h 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. Copyright (c) 2012, Broadcom Europe Ltd
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are met:
  6. * Redistributions of source code must retain the above copyright
  7. notice, this list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. * Neither the name of the copyright holder nor the
  12. names of its contributors may be used to endorse or promote products
  13. derived from this software without specific prior written permission.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  15. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
  18. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. /*=============================================================================
  26. VideoCore OS Abstraction Layer - mutex public header file
  27. =============================================================================*/
  28. #ifndef VCOS_MUTEX_H
  29. #define VCOS_MUTEX_H
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. #include "vcos_types.h"
  34. #include "pthreads/vcos_platform.h"
  35. /**
  36. * \file vcos_mutex.h
  37. *
  38. * Mutex API. Mutexes are not re-entrant, as supporting this adds extra code
  39. * that slows down clients which have been written sensibly.
  40. *
  41. * \sa vcos_reentrant_mutex.h
  42. *
  43. */
  44. /** Create a mutex.
  45. *
  46. * @param m Filled in with mutex on return
  47. * @param name A non-null name for the mutex, used for diagnostics.
  48. *
  49. * @return VCOS_SUCCESS if mutex was created, or error code.
  50. */
  51. VCOS_INLINE_DECL
  52. VCOS_STATUS_T vcos_mutex_create(VCOS_MUTEX_T *m, const char *name);
  53. /** Delete the mutex.
  54. */
  55. VCOS_INLINE_DECL
  56. void vcos_mutex_delete(VCOS_MUTEX_T *m);
  57. /**
  58. * \brief Wait to claim the mutex.
  59. *
  60. * On most platforms this always returns VCOS_SUCCESS, and so would ideally be
  61. * a void function, however some platforms allow a wait to be interrupted so
  62. * it remains non-void.
  63. *
  64. * Try to obtain the mutex.
  65. * @param m Mutex to wait on
  66. * @return VCOS_SUCCESS - mutex was taken.
  67. * VCOS_EAGAIN - could not take mutex.
  68. */
  69. #ifndef vcos_mutex_lock
  70. VCOS_INLINE_DECL
  71. VCOS_STATUS_T vcos_mutex_lock(VCOS_MUTEX_T *m);
  72. /** Release the mutex.
  73. */
  74. VCOS_INLINE_DECL
  75. void vcos_mutex_unlock(VCOS_MUTEX_T *m);
  76. #endif
  77. /** Test if the mutex is already locked.
  78. *
  79. * @return 1 if mutex is locked, 0 if it is unlocked.
  80. */
  81. VCOS_INLINE_DECL
  82. int vcos_mutex_is_locked(VCOS_MUTEX_T *m);
  83. /** Obtain the mutex if possible.
  84. *
  85. * @param m the mutex to try to obtain
  86. *
  87. * @return VCOS_SUCCESS if mutex is succesfully obtained, or VCOS_EAGAIN
  88. * if it is already in use by another thread.
  89. */
  90. #ifndef vcos_mutex_trylock
  91. VCOS_INLINE_DECL
  92. VCOS_STATUS_T vcos_mutex_trylock(VCOS_MUTEX_T *m);
  93. #endif
  94. #ifdef __cplusplus
  95. }
  96. #endif
  97. #endif