📄 rzkdeletequeue.c
字号:
/*
* File : RZKDeleteQueue.c
*
*
* Description : This file contains RZKDeleteQueue function which deletes
* a MQ.
*
* 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"
#include "ZMessageQ.h"
#include "ZScheduler.h"
#define pMessageQueue ((RZK_MESSAGEQUEUE_t *) hMessageQueue)
extern RZK_THREADHANDLE_t hCurrentThread;
//extern void RZKScheduler();
//extern void UpdateThreadStatus( RZK_TCB_t * hThread, RZK_STATUS_t errNum); // IAR changed from UINT to RZK_STATUS_t
extern void InitializeCircularBuffer(RZK_MESSAGEQUEUE_t * );
UINT8 ERR_CHECK ;
/*
* Function : RZKDeleteQueue
*
* Description : Invalidates an existing message queue and resumes all the waiting threads
* on this queue with appropriate status and makes the queue available
* for further RZKCreateQueue call.
*
* Inputs : hMessageQueue - handle to the control block which is to be deleted.
*
* Outputs : RZKERR_SUCCESS - If the message queue was successfully deleted.
* RZKERR_INVALID_HANDLE - If the hMessageQueue parameter is invalid.
* RZKERR_CB_BUSY - If the control block is being exclusively used by another thread.
*
* Dependencies : hCurrentThread
*/
RZK_STATUS_t RZKDeleteQueue( RZK_MESSAGEQHANDLE_t hMessageQueue)
{
/* Local Variable */
RZK_TCB_t * pTemp;
RZK_STATE_t uState;
/* validate the handle passed */
if( ERR_CHECK != 1 )
{
#ifndef RZK_EFFICIENTQUEUE
#ifdef RZK_DEBUG
if((pMessageQueue==NULL) || ( pMessageQueue ->uState == 0 ) ||
( pMessageQueue ->magic_num != MAGIC_NUM_MESSAGEQ))
return RZKERR_INVALID_HANDLE;
#endif
#ifndef RZK_PERFORMANCE
if(!(pMessageQueue ->uState & OBJECT_CREATED))
return RZKERR_CB_BUSY;
#endif
#endif
}
/* Reset the created bit of uState */
uState = RZKDisablePreemption();
pMessageQueue ->uState &= ~(OBJECT_CREATED);
pTemp = pMessageQueue->pResNext;
/* update the status of all the threads that are waiting on the resource queue */
while ( pTemp != NULL)
{
UpdateThreadStatus(pTemp, RZKERR_OBJECT_DELETED);
pTemp = pTemp->pResNext;
}
/* Free message queue control block by setting the uState parameter to 0 */
pMessageQueue->uState = 0;
RZKRestorePreemption(uState);
return RZKERR_SUCCESS;
} /* end of RZKDeleteQueue */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -