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

📄 cxesig.c

📁 上传一个带源代码的嵌入式实时多任务操作系统CMX
💻 C
字号:
/*********************************************************

Copyright (c) CMX Company. 1999. All rights reserved

*********************************************************/
/* version 5.30 */

#define CMXMODULE 1

#include <cxfuncs.h>	/* get cmx include header file */
#include <cxextern.h>	/* get cmx include header file */

#if (defined(CMXTRACKER) || defined(WINTRACKER))
#include <cmxtrack.h>	/* get cmx include header file */
#endif

/**********************************************************************
 The following function will set possibly set an event.

byte mode: 	0 = specific task
				1 = highest priority (single task even if more then one of same)
				2 = highest priority waiting task on THIS EVENT
				3 = all tasks
				4 = all waiting tasks THIS EVENT
				5 = all with same priority (specify priority)
				6 = all waiting with same priority (specify priority) THIS EVENT
************************************************************************/
byte K_Event_Signal(byte mode, byte tskid_pri,word16 flag)
{
	tcbpointer tcbptr;
#if (defined(CMXTRACKER) || defined(WINTRACKER))
	byte cmxtracker_sent;
#endif

	if (mode > 0x06)	/* see if mode greater then maximum allowed. */
		{
#if (defined(CMXTRACKER) || defined(WINTRACKER))
		if (CMXTRACKER_ON)
			{
			cmxtracker_in2(CXESIG_MODE,mode);
			}
#endif
		return(K_ERROR);
		}
	K_I_Disable_Sched();	/* set task block */
#if (defined(CMXTRACKER) || defined(WINTRACKER))
	cmxtracker_sent = 0;
#endif
	if (!mode)	/* is mode 0. */
		{
		if(K_I_Get_Ptr(tskid_pri,&tcbptr))	/* send address of pointer */
			{
#if (defined(CMXTRACKER) || defined(WINTRACKER))
		if (CMXTRACKER_ON)
			{
			cmxtracker_in2(CXESIG_K_ERROR,tskid_pri);
			}
#endif
			K_I_Func_Return();
			return(K_ERROR);
			}
		goto test_event;
		}
	else
		{
		tcbptr = timertask->nxttcb;	/* start at head of linked list. */
		}
	for (; tcbptr != cmx_tcb; tcbptr = tcbptr->nxttcb) /* see if we tested all. */
		{
		if (mode > 0x04)	/* is mode greater then 4? */
			{
			if (tcbptr->priority != tskid_pri)	/* see if priority match. */
				continue;
			}
		if (!(mode & 0x01))	/* see if task must be waiting on this EVENT */
			{
			if (!((tcbptr->e_match & flag) &&
				(tcbptr->tcbstate & FLAGS)))
				{
				continue;	/* continue if task was not. */
				}
			}
test_event:
#if (defined(CMXTRACKER) || defined(WINTRACKER))
		if (CMXTRACKER_ON)
			{
			if (!cmxtracker_sent)
				{
				cmxtracker_sent = tcbptr - cmx_tcb;
				}
			}
#endif
		/* see if task event(s) match. */
		if (tcbptr->e_match & (tcbptr->e_flags |= flag))
			{
			if (tcbptr->tcbstate & FLAGS)	/* see if task was waiting on EVENT. */
				{
				tcbptr->tcbstate = RESUME; /* yes, the task may now resume. */
				
				if (TEST_NOT_PREEMPTED)	/* see if preempted flag not set yet. */
					{
					if (tcbptr->priority < active_priority)
						PREEMPTED;	/* yes, set the preempted scheduling flag */
					}
				if (mode < 0x03)	/* see if we should exit function. */
					break;
				}
			}
		if (mode < 0x02)	/* see if we should exit function. */
			break;
		}
#if (defined(CMXTRACKER) || defined(WINTRACKER))
 	if (CMXTRACKER_ON)
		{
		cmxtracker_in3(CXESIG_K_OK,mode,cmxtracker_sent);
		}
#endif
	K_I_Func_Return();	/* call CMX function, that will release task block */	
	return(K_OK);	/* return good status */
}

⌨️ 快捷键说明

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