📄 zacquirecontrolblock.c
字号:
/*
* File : ZAcquireControlBlock.c
*
* Description : This file contains definition of AcquireControlBlock function
*
* 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 "ZMachine.h" // IAR port not needed
#include "ZInterrupt.h"
/** extern functions */
extern UINTRMASK RZKDisableInterrupts();
extern void RZKEnableInterrupts(UINTRMASK);
/* Function : AcquireControlBlock
*
* Description : Allocates an empty control block for the required object.
*
* Inputs : hControlBlock - The base address of the object
* uMaxCB - Specifies the maximum number of objects.
* uSizeOfCB - Specifies the size of the control block.
*
* Outputs : returns the hControlBlock on success.
* returns NULL on failure.
*
* Dependencies : None
*/
RZK_HANDLE_t AcquireControlBlock
(
RZK_TCB_t *pControlBlock,
UINT uMaxCB,
UINT uSizeOfCB
)
{
/* Local Variables */
UINT index;
UINTRMASK mInterruptMask;
CADDR_t pTemp = (CADDR_t) pControlBlock;
/* Look for a free control block */
for( index = 0;index < uMaxCB;index++)
{
mInterruptMask = RZKDisableInterrupts();
if( pControlBlock->uState == 0)
{
pControlBlock->uState = OBJECT_BUSY;
RZKEnableInterrupts(mInterruptMask);
return (RZK_HANDLE_t) pControlBlock;
}
RZKEnableInterrupts(mInterruptMask);
pTemp += uSizeOfCB;
pControlBlock = (RZK_TCB_t *) pTemp;
}
return NULL;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -