Nut/OS  4.10.3
API Reference
mutex.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2000-2004 by ETH Zurich
00003  *
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions
00006  * are met:
00007  *
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 3. Neither the name of the copyright holders nor the names of
00014  *    contributors may be used to endorse or promote products derived
00015  *    from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY ETH ZURICH AND CONTRIBUTORS
00018  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00019  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00020  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ETH ZURICH
00021  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00022  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00023  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00024  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00025  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00026  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00027  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00028  * SUCH DAMAGE.
00029  *
00030  * For additional information see http://www.ethernut.de/
00031  *
00032  */
00033 
00034 /* mutex.c - a nut/os implementation of recursive mutex functions
00035  *
00036  * 2004.05.06 Matthias Ringwald <matthias.ringwald@inf.ethz.ch>
00037  *
00038  */
00039 /*
00040  * $Log$
00041  * Revision 1.6  2008/08/11 07:00:26  haraldkipp
00042  * BSD types replaced by stdint types (feature request #1282721).
00043  *
00044  * Revision 1.5  2007/08/29 07:43:54  haraldkipp
00045  * Documentation updated and corrected.
00046  *
00047  * Revision 1.4  2005/12/22 09:36:25  freckle
00048  * added missing prototype for NutMutexDestroy
00049  *
00050  * Revision 1.3  2005/08/02 17:46:49  haraldkipp
00051  * Major API documentation update.
00052  *
00053  * Revision 1.2  2004/05/18 18:38:14  drsung
00054  * Added $Log keyword for CVS and avoid multiple inclusion of header file.
00055  *
00056  */
00057 
00058 #ifndef _SYS_MUTEX_H
00059 #define _SYS_MUTEX_H
00060 
00061 #include <compiler.h>
00062 #include <sys/types.h>
00063 #include <sys/thread.h>
00064 
00069 
00070 __BEGIN_DECLS
00071 
00075 typedef struct _MUTEX MUTEX;
00076 
00082 struct _MUTEX {
00083     HANDLE qhp;             
00084     NUTTHREADINFO *thread;  
00085     uint16_t count;          
00086 };
00087 
00088 extern void NutMutexInit(MUTEX * mutex);
00089 extern void NutMutexLock(MUTEX * mutex);
00090 extern int NutMutexUnlock(MUTEX * mutex);
00091 extern int NutMutexTrylock(MUTEX * mutex);
00092 extern int NutMutexDestroy(MUTEX * mutex);
00093 __END_DECLS
00094 
00097 #endif /* #ifndef _SYS_MUTEX_H */
00098