gonzui


Format: Advanced Search

mtkernel_3/kernel/tkernel/mutex.hbare sourcepermlink (0.01 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    micro T-Kernel 3.00.00
    4:  *
    5:  *    Copyright (C) 2006-2019 by Ken Sakamura.
    6:  *    This software is distributed under the T-License 2.1.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by TRON Forum(http://www.tron.org) at 2019/12/11.
   10:  *
   11:  *----------------------------------------------------------------------
   12:  */
   13: 
   14: /*
   15:  *      mutex.h
   16:  *      Mutex
   17:  */
   18: 
   19: #ifndef _MUTEX_H_
   20: #define _MUTEX_H_
   21: 
   22: typedef struct mutex_control_block      MTXCB;
   23: 
   24: /*
   25:  * Mutex control block
   26:  */
   27: struct mutex_control_block {
   28:         QUEUE  wait_queue;      /* Mutex wait queue */
   29:         ID     mtxid;              /* Mutex ID */
   30:         void   *exinf;           /* Extended information */
   31:         ATR    mtxatr;            /* Mutex attribute */
   32:         UB     ceilpri;    /* Highest priority limit of mutex */
   33:         TCB    *mtxtsk;   /* Mutex get task */
   34:         MTXCB  *mtxlist;        /* Mutex get list */
   35: #if USE_OBJECT_NAME
   36:         UB     name[OBJECT_NAME_LENGTH];   /* name */
   37: #endif
   38: };
   39: 
   40: IMPORT MTXCB knl_mtxcb_table[]; /* Mutex control block */
   41: IMPORT QUEUE knl_free_mtxcb;    /* FreeQue */
   42: 
   43: #define get_mtxcb(id)   ( &knl_mtxcb_table[INDEX_MTX(id)] )
   44: 
   45: 
   46: /*
   47:  * If there is a mutex 'mtxcb' with the task of lock wait, it is TRUE
   48:  */
   49: #define mtx_waited(mtxcb)       ( !isQueEmpty(&(mtxcb)->wait_queue) )
   50: 
   51: /*
   52:  * Return the highest priority in the task of lock wait at mutex 'mtxcb'
   53:  */
   54: #define mtx_head_pri(mtxcb)     ( ((TCB*)(mtxcb)->wait_queue.next)->priority )
   55: 
   56: /*
   57:  * Reset priority of lock get task (For TA_INHERIT only)
   58:  */
   59: #define reset_priority(tcb)     knl_release_mutex((tcb), NULL)
   60: 
   61: 
   62: IMPORT void knl_release_mutex( TCB *tcb, MTXCB *relmtxcb );
   63: 
   64: #endif /* _MUTEX_H_ */