mutex.h
来自「一个简单的小型操作系统」· C头文件 代码 · 共 61 行
H
61 行
/*****************************************************************************
*
* Module : mutex.h
* Description : Simple Mutual Exclusion module that allows
* critical sections of code to have access to
* shared memory.
* OS : SLOS 0.09
* Platform : e7t
* History :
*
* November 10th, 2001 Andrew N. Sloss
* - started
*
* Notes : none...
*
*****************************************************************************/
/*****************************************************************************
* MACROS
*****************************************************************************/
#define aWAIT while (semaphore==1) {} mutex_gatelock();
#define aSIGNAL mutex_gateunlock();
#define bWAIT while (semaphore==1||semaphore==2) {} \
mutex_gatelock();
#define bSIGNAL mutex_gateunlock();
/*****************************************************************************
* EXTERNAL
*****************************************************************************/
extern unsigned volatile int semaphore; /* do not direct access */
/* -- mutex_gatelock ----------------------------------------------------------
*
* Description : Locks the semaphore...
*
* Parameters : none...
* Return : none...
* Notes :
*
*/
void mutex_gatelock (void);
/* -- mutex_gateunlock --------------------------------------------------------
*
* Description : Unlocks the semaphore ...
*
* Parameters : none...
* Return : none...
* Notes :
*
*/
void mutex_gateunlock (void);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?