diff options
| author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2014-02-12 09:43:27 +0000 | 
|---|---|---|
| committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2014-02-12 09:43:27 +0000 | 
| commit | 6c90d27a46cfeb8970eec2cf9d41729202d0e40b (patch) | |
| tree | 75c38e7256a44bdbaeb3d11c1d5e9ca78c08c09b /os/rt/include | |
| parent | 1033792b73022cbf5a7ef741313ae18592306251 (diff) | |
| download | ChibiOS-6c90d27a46cfeb8970eec2cf9d41729202d0e40b.tar.gz ChibiOS-6c90d27a46cfeb8970eec2cf9d41729202d0e40b.tar.bz2 ChibiOS-6c90d27a46cfeb8970eec2cf9d41729202d0e40b.zip | |
Preparation to recursive mutexes, now unlock primitives have the mutex as parameter.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6706 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/rt/include')
| -rw-r--r-- | os/rt/include/chmtx.h | 22 | 
1 files changed, 20 insertions, 2 deletions
| diff --git a/os/rt/include/chmtx.h b/os/rt/include/chmtx.h index 0444d936c..a85fb84e7 100644 --- a/os/rt/include/chmtx.h +++ b/os/rt/include/chmtx.h @@ -62,6 +62,9 @@ struct mutex {                                                  @p NULL.                    */
    mutex_t               *m_next;    /**< @brief Next @p mutex_t into an
                                                  owner-list or @p NULL.      */
 +#if CH_CFG_USE_MUTEXES_RECURSIVE || defined(__DOXYGEN__)
 +  cnt_t                 m_taken;    /**< @brief Mutex recursion counter.    */
 +#endif
  };
  /*===========================================================================*/
 @@ -75,7 +78,11 @@ struct mutex {   *
   * @param[in] name      the name of the mutex variable
   */
 +#if CH_CFG_USE_MUTEXES_RECURSIVE || defined(__DOXYGEN__)
 +#define _MUTEX_DATA(name) {_threads_queue_t_DATA(name.m_queue), NULL, NULL, 0}
 +#else
  #define _MUTEX_DATA(name) {_threads_queue_t_DATA(name.m_queue), NULL, NULL}
 +#endif
  /**
   * @brief   Static mutex initializer.
 @@ -99,8 +106,8 @@ extern "C" {    void chMtxLockS(mutex_t *mp);
    bool chMtxTryLock(mutex_t *mp);
    bool chMtxTryLockS(mutex_t *mp);
 -  mutex_t *chMtxUnlock(void);
 -  mutex_t *chMtxUnlockS(void);
 +  void chMtxUnlock(mutex_t *mp);
 +  void chMtxUnlockS(mutex_t *mp);
    void chMtxUnlockAll(void);
  #ifdef __cplusplus
  }
 @@ -124,6 +131,17 @@ static inline bool chMtxQueueNotEmptyS(mutex_t *mp) {    return queue_notempty(&mp->m_queue);
  }
 +/**
 + * @brief   Returns the next mutex in the mutexes stack of the current thread.
 + *
 + * @return              A pointer to the next mutex in the stack.
 + * @retval NULL         if the stack is empty.
 + */
 +static inline mutex_t *chMtxGetNextMutex(void) {
 +
 +  return chThdGetSelfX()->p_mtxlist;
 +}
 +
  #endif /* CH_CFG_USE_MUTEXES */
  #endif /* _CHMTX_H_ */
 | 
