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

📄 zupdatethreadstatus.c

📁 zilog的实时操作系统RZK,可以移植到多种处理器上
💻 C
字号:
/*
* File				:	ZUpdateThreadStatus.c
*
* Description		:	This file contains definition of UpdateThreadStatus routine.
*
* Copyright 2004 ZiLOG Inc.  ALL RIGHTS RESERVED.
*
* This file contains unpublished confidential and proprietary information
* of ZiLOG, Inc.
* NO PART OF THIS WORK MAY BE DUPLICATED, STORED, PUBLISHED OR DISCLOSED 
* IN ANY FORM WITHOUT THE PRIOR WRITTEN CONSENT OF ZiLOG, INC.
* This is not a license and no use of any kind of this work is authorized
* in the absence of a written license granted by ZiLOG, Inc. in ZiLOG's 
* sole discretion 
*/
#include "ZSysgen.h"
#include "ZTypes.h"
#include "ZThread.h"
#include "ZQueue.h"
#include "ZInterrupt.h"

extern RZK_DISPATCHQ_t  DispatchQueue[DMAX_PRIORITY_P1];
extern const UINT32 pMap[32];
extern  volatile UINT32 DQPriorityBitMap;

/** extern functions */
extern void UpdateTQ2OnRemove(RZK_TCB_t    * pThreadToRemove);
extern void QueueAppend(RZK_TCB_t *pInsertionPosition ,RZK_TCB_t *pObjectToAppend);
extern void DispatchQueueNodeAppend(RZK_TCB_t *pObjectToAppend);

/* Function			:	UpdateThreadStatus
*
* Description		:	This function updates the various parameters for the thread such as
*					    uState and uBlockingReason. The errNum variable determines the
*						type of the error to be set in TCB.This function also removes the
*						thread from TimeQ2 if necessary and sets the appropriate flag in
*						the uState parameter of the thread.
*
* 
* Inputs			:	hThread - handle of the TCB to be updated.
*						errNum- The value of the error to be set in thread control block.
*
* Outputs			:	None.
*							
*
* Dependencies		:	None.
*/
void UpdateThreadStatus( RZK_TCB_t * hThread, RZK_STATUS_t errNum)	// IAR changed from UINT to RZK_STATUS_t
{
	/* change the uState of the thread to appropriate value */
	hThread->uState &= ~(THREAD_BLOCKEDSUSPEND);
	hThread->uBlockingReason = 0;
	hThread->errNum = ( RZK_ERROR_et ) errNum;
	if(hThread->uState & THREAD_TIMEDBLOCK)
	{
		/* This function both updates TQ2 and removes the thread from the TQ2 */
		UpdateTQ2OnRemove(hThread);
		/* Now reset the THREAD_TIMEDBLOCK bit in TCB*/
		hThread->uState &= ~(THREAD_TIMEDBLOCK);
		
	}
	/* If the thread is not infinitely suspended add the thread to the dispatch queue */
	if(!(hThread->uState & THREAD_INFINITESUSPEND))
	{
		UINTRMASK mInterruptMask;

		mInterruptMask = RZKDisableInterrupts();
		DispatchQueueNodeAppend(hThread);
		RZKEnableInterrupts(mInterruptMask);
		/* set the running bit for this thread */
		hThread->uState |= THREAD_RUNNING;
	}
} /* end of UpdateThreads */

⌨️ 快捷键说明

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