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

📄 cxsempst.c

📁 CMEX source code RTOS for atmel atmega128
💻 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 */

#ifdef CMXTRACKER
#include <cmxtrack.h>	/* get cmx include header file */
#endif

byte K_Semaphore_Post(byte sem_num)	
{
	SEM *sem_ptr;
	tcbpointer tp;

	if (sem_num >= MAX_SEMAPHORES)
		{
		return(K_ERROR);	/* return good status to caller */
		}
	K_I_Disable_Sched();
	sem_ptr = &sem_array[sem_num];	/* CMX semaphore handler. */
	if (sem_ptr->fwlink == NULL)
		{
		K_I_Func_Return();	/* release task block */
		return(K_ERROR);	/* return good status to caller */
		}
	++sem_ptr->sem_count;
	if (sem_ptr->fwlink != (tcbpointer)sem_ptr)	/* does a task own this semaphore */
		{
		sem_ptr->fwlink->tcbstate = RESUME;	/* allow task to run again */
		if (sem_ptr->fwlink->priority < active_priority)
			PREEMPTED;	/* yes, so set the preempted scheduling flag */
		tp = sem_ptr->fwlink;
		tp->fwlink->bwlink = tp->bwlink;
		sem_ptr->fwlink = tp->fwlink;
		--sem_ptr->sem_count; /* reduce count again, because this task now
										 has semaphore */
		}
	K_I_Func_Return();	/* release task block */
	return(K_OK);	/* return good status to caller */
}	/* K_Semaphore_Post */

⌨️ 快捷键说明

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