]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - apps/tidep0084.git/blob - components/common/inc/mutex.h
0f6809fb2bbdb7b6d2dda27b2b4a8d5a81230b1d
[apps/tidep0084.git] / components / common / inc / mutex.h
1 /******************************************************************************
2  @file mutex.h
4  @brief TIMAC 2.0 API generic abstract mutex implimentation
6  Group: WCS LPC
7  $Target Devices: Linux: AM335x, Embedded Devices: CC1310, CC1350$
9  ******************************************************************************
10  $License: BSD3 2016 $
11   
12    Copyright (c) 2015, Texas Instruments Incorporated
13    All rights reserved.
14   
15    Redistribution and use in source and binary forms, with or without
16    modification, are permitted provided that the following conditions
17    are met:
18   
19    *  Redistributions of source code must retain the above copyright
20       notice, this list of conditions and the following disclaimer.
21   
22    *  Redistributions in binary form must reproduce the above copyright
23       notice, this list of conditions and the following disclaimer in the
24       documentation and/or other materials provided with the distribution.
25   
26    *  Neither the name of Texas Instruments Incorporated nor the names of
27       its contributors may be used to endorse or promote products derived
28       from this software without specific prior written permission.
29   
30    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
32    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
33    PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
34    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
35    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
37    OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
38    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
39    OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
40    EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41  ******************************************************************************
42  $Release Name: TI-15.4Stack Linux x64 SDK$
43  $Release Date: Jun 28, 2017 (2.02.00.03)$
44  *****************************************************************************/
46 #if !defined(MUTEX_H)
47 #define MUTEX_H
49 #include <stdbool.h>
50 #include <stdint.h>
52 /*!
53  * @brief Create a mutex
54  * @param name - for debug purposes
55  * @returns mutex handle for later use
56  *
57  * Implimentation note: this is not a named Linux semaphore
58  */
59 intptr_t MUTEX_create(const char *name);
60 /*!
61  * @brief release resources associated with a mutex
62  * @param h - mutex handle from MUTEX_Create()
63  */
64 void MUTEX_destroy(intptr_t h);
66 /*!
67  * @brief Lock a mutex with timeout
68  * @param h - mutex handle from MUTEX_create()
69  * @param mSecTimeout - negative=forever, 0=non-blocking >0 timeout value
70  *
71  * @returns If timeout=0, then 1=success, 0=fail, -1=other error
72  * @returns If timeout > 0, then 1 success, other failure
73  */
74 int MUTEX_lock(intptr_t h, int mSecTimeout);
76 /*!
77  * @brief Unlock a mutex
78  * @param h - mutex handle from MUTEX_create()
79  * @returns 0 success, negative if not a valid mutex handle
80  */
81 int MUTEX_unLock(intptr_t h);
83 /*!
84  * @brief test, determine if a mutex is locked or not
85  *
86  * @param h - mutex handle from MUTEX_create()
87  * @return boolean, true if locked
88  */
90 bool MUTEX_isLocked(intptr_t h);
92 /*!
93  * @brief returns the name of the current locker
94  *
95  * Or if not locked, the string "none"
96  */
97 const char *MUTEX_lockerName(intptr_t h);
99 #endif
101 /*
102  *  ========================================
103  *  Texas Instruments Micro Controller Style
104  *  ========================================
105  *  Local Variables:
106  *  mode: c
107  *  c-file-style: "bsd"
108  *  tab-width: 4
109  *  c-basic-offset: 4
110  *  indent-tabs-mode: nil
111  *  End:
112  *  vim:set  filetype=c tabstop=4 shiftwidth=4 expandtab=true
113  */