⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mutex.h

📁 一个简单的小型操作系统
💻 H
字号:

/*****************************************************************************
 *
 * 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -