condition.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef _SYS_CONDITION_H_
  2. #define _SYS_CONDITION_H_
  3. /*
  4. * Copyright (C) 2008 by EmbeddedIT,
  5. * Ole Reinhardt <ole.reinhardt@embedded-it.de> All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. * 3. Neither the name of the copyright holders nor the names of
  17. * contributors may be used to endorse or promote products derived
  18. * from this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY EMBEDDED IT AND CONTRIBUTORS
  21. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  23. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EMBEDDED IT
  24. * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  25. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  26. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  27. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  28. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  29. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  30. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. *
  34. */
  35. /*
  36. * $Log$
  37. * Revision 1.2 2008/04/29 01:51:52 thiagocorrea
  38. * Compile fix
  39. *
  40. * Revision 1.1 2008/04/21 22:24:53 olereinhardt
  41. * Implemented condition variables to use with NutOS as an application candy
  42. *
  43. */
  44. #include <sys/atom.h>
  45. #include <sys/mutex.h>
  46. #include <sys/types.h>
  47. /*!
  48. * \addtogroup xgConditionVariables
  49. */
  50. /*@{*/
  51. /*!
  52. * \brief Condition variable type.
  53. */
  54. typedef struct _CONDITION CONDITION;
  55. /*!
  56. * \struct _CONDITION condition.h sys/condition.h
  57. * \brief Condition variable
  58. *
  59. */
  60. struct _CONDITION {
  61. HANDLE event; /*!< \brief Event queue used for signaling */
  62. MUTEX mutex; /*!< \brief Mutex used for locking */
  63. };
  64. extern int NutConditionInit(CONDITION * cond);
  65. extern void NutConditionLock(CONDITION * cond);
  66. extern void NutConditionUnlock(CONDITION * cond);
  67. extern int NutConditionWait(CONDITION * cond);
  68. extern int NutConditionSignal(CONDITION * cond);
  69. extern int NutConditionBroadcast(CONDITION * cond);
  70. extern void NutConditionFree(CONDITION * cond);
  71. /*@}*/
  72. #endif