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_quickslow_mutex.h 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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_QUICKSLOW_MUTEX_H
  29. #define VCOS_QUICKSLOW_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_quickslow_mutex.h
  37. *
  38. * "Quick/Slow" Mutex API. This is a mutex which supports an additional "quick"
  39. * (spinlock-based) locking mechanism. While in this quick locked state, other
  40. * operating system commands will be unavailable and the caller should complete
  41. * whatever it has to do in a short, bounded length of time (as the spinlock
  42. * completely locks out other system activity).
  43. *
  44. * \sa vcos_mutex.h
  45. *
  46. */
  47. /** Create a mutex.
  48. *
  49. * @param m Filled in with mutex on return
  50. * @param name A non-null name for the mutex, used for diagnostics.
  51. *
  52. * @return VCOS_SUCCESS if mutex was created, or error code.
  53. */
  54. VCOS_INLINE_DECL
  55. VCOS_STATUS_T vcos_quickslow_mutex_create(VCOS_QUICKSLOW_MUTEX_T *m, const char *name);
  56. /** Delete the mutex.
  57. */
  58. VCOS_INLINE_DECL
  59. void vcos_quickslow_mutex_delete(VCOS_QUICKSLOW_MUTEX_T *m);
  60. /**
  61. * \brief Wait to claim the mutex ("slow" mode).
  62. *
  63. * Obtain the mutex.
  64. */
  65. VCOS_INLINE_DECL
  66. void vcos_quickslow_mutex_lock(VCOS_QUICKSLOW_MUTEX_T *m);
  67. /** Release the mutex ("slow" mode).
  68. */
  69. VCOS_INLINE_DECL
  70. void vcos_quickslow_mutex_unlock(VCOS_QUICKSLOW_MUTEX_T *m);
  71. /**
  72. * \brief Wait to claim the mutex ("quick" mode).
  73. *
  74. * Obtain the mutex. The caller must not call any OS functions or do anything
  75. * "slow" before the corresponding call to vcos_mutex_quickslow_unlock_quick.
  76. */
  77. VCOS_INLINE_DECL
  78. void vcos_quickslow_mutex_lock_quick(VCOS_QUICKSLOW_MUTEX_T *m);
  79. /** Release the mutex ("quick" mode).
  80. */
  81. VCOS_INLINE_DECL
  82. void vcos_quickslow_mutex_unlock_quick(VCOS_QUICKSLOW_MUTEX_T *m);
  83. #ifdef __cplusplus
  84. }
  85. #endif
  86. #endif