os_sign.c

来自「引入事件驱动观念的抢占式多任务微型实时内核——MicroStar的设计与实现;提」· C语言 代码 · 共 79 行

C
79
字号
/**************** os_sign.c**************/
/*            MacroStar 1.0a            */
/*          Zhengyuquan,2003.7,Beijing  */
/*           All rights reserved        */
/****************************************/
#include "mStar.h"

/*
************************************************************
*
*
*
************************************************************
*/
void STDCALL _FAR os_WaitORSignal( volatile uint_16 *pSignal,uint_16 acceptMask,uint_16 urgentMask )
{
	uint_16 temp;
	LOCK_INT( );
	while( !( temp = (*pSignal)&acceptMask ) )
	{
        os_rdyState &= ~os_curPrioMask; 
		os_rdyhState&= ~os_curPrioMask;
		UNLOCK_INT( );
		os_Schedule( );
		LOCK_INT( );
	}
	if( !(temp & urgentMask) )
	{
		os_rdyState |= os_curPrioMask;/*robust code*/
		os_rdyhState &= ~os_curPrioMask;
	}
	UNLOCK_INT( );
}

/*
************************************************************
*
*
*
************************************************************
*/
void STDCALL _FAR os_Notify( uchar taskId,BOOL isUrgent )
{
	uint_16 taskMask;

	os_WARNING( !(os_tcbState&os_maskTable[taskId]),NOTIFY_NULL);

	LOCK_INT_EX( );
	taskMask = os_maskTable[ os_tcbs[taskId].priority ];
	if( isUrgent )
		os_rdyhState |= taskMask;
	else
		os_rdyState  |= taskMask;
	UNLOCK_INT_EX( );
	os_SetSwitchFlag( );
}

/*
************************************************************
*
*
*
************************************************************
*/
void STDCALL _FAR os_WaitANDSignal(volatile uint_16 *pSignal,uint_16 acceptMask )
{
	LOCK_INT( );
    while( (*pSignal & acceptMask) != acceptMask  )
	{   
		os_rdyState &= ~os_curPrioMask;
		os_rdyhState&= ~os_curPrioMask;
		UNLOCK_INT( );
		os_Schedule( );
		LOCK_INT( );
	}
	UNLOCK_INT( );
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?