📄 zwaitonresourcequeue.c
字号:
/*
* File : ZWaitOnResourceQueue.c
*
* Description : This file contains definition of WaitOnResourceQueue 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"
#define pCurrentThread ((RZK_TCB_t *) hCurrentThread)
extern RZK_HANDLE_t hCurrentThread;
extern volatile UINT32 DQPriorityBitMap;
extern RZK_DISPATCHQ_t DispatchQueue[DMAX_PRIORITY_P1];
extern const UINT32 pMap[32];
/** extern functions */
extern void QueueNodeRemove(RZK_TCB_t *pObjectToRemove );
extern void AddToTimeQ2(RZK_TCB_t *hObjectToAdd);
/* Function : WaitOnResourceQueue
*
* Description : This function sets the uState,blocking reason and blocking resource
* of the thread.If the block time is maximum infinite suspend add the thread to the
* time queue2 and removes it from the dispatch Queue.
*
* Inputs : hControlBlock - Specifies a
* handle to the control block.
* uBlockingReason - Specifies
* the blocking reason.
* tBlockTime - Specifies the
* maximum blocking Time.
*
* Outputs : None.
*
*
* Dependencies : hCurrentThread.
*/
void WaitOnResourceQueue( RZK_HANDLE_t hControlBlock,UINT16 uBlockingReason,
TICK_t tBlockTime)
{
UINTRMASK mInterruptMask;
/* Set the uState and the blocking reason for this thread */
pCurrentThread ->uState |= THREAD_BLOCKEDSUSPEND;
pCurrentThread ->uBlockingReason = uBlockingReason;
pCurrentThread ->pBlockingResource = hControlBlock;
/* Remove from dispatch queue */
mInterruptMask = RZKDisableInterrupts();
DispatchQueueNodeRemove(pCurrentThread);
RZKEnableInterrupts(mInterruptMask);
if (tBlockTime != MAX_INFINITE_SUSPEND)
{
/* set the uState in the TCB to appropriate value*/
pCurrentThread -> uState |= THREAD_TIMEDBLOCK;
/* Add to time queue2 */
pCurrentThread -> tWaitTime = tBlockTime;
AddToTimeQ2( ( RZK_TCB_t * ) hCurrentThread);
}
pCurrentThread -> errNum = RZKERR_SUCCESS;
} /* end of WaitOnResourceQueue */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -