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

📄 rzkgetsemaphoreparameters.c

📁 zilog的实时操作系统RZK,可以移植到多种处理器上
💻 C
字号:
/*
* File			:	RZKGetSemaphoreParameters.c
*
* Description	:	This file contains the RZKGetSemaphoreParameters 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 "ZSemaphore.h"

#define pSemaphore ((RZK_SEMAPHORE_t *) hSemaphore)

/** extern functions */
extern UINT GetMaxCount(RZK_TCB_t *hThread);



/*
* Function		:	RZKGetSemaphoreParameters
*
* Description	:	Get the parameters from Semaphore 
*					control block to the user specified Semaphoreparams_t structure.
* 
* Inputs		:	hSemaphore - Specifies a handle to semaphore whose parameters 
*								are to be retrieved
*					pSemaphoreParams - Specifies a pointer to the semaphore 
*								parameter structure
*
* Outputs		:	RZKERR_SUCCESS - If the parameters are successfully set.
*					RZKERR_INVALID_HANDLE -If the specified handle was invalid.
*					RZKERR_INVALID_ARGUMENTS -If the specified address of the structure was invalid.
*					RZKERR_CB_BUSY - Specifies that the object is in exclusively used.
*
* Dependencies	:	None
*/

RZK_STATUS_t RZKGetSemaphoreParameters
		( 
		RZK_SEMAPHOREHANDLE_t hSemaphore,
		RZK_SEMAPHOREPARAMS_t *pSemaphoreParams
		)

{
 	
/* check the validity of the arguments */
#ifdef RZK_DEBUG 
	if ((pSemaphore == NULL)||(pSemaphore->uState == 0) ||
			(pSemaphore->magic_num != MAGIC_NUM_SEMAPHORE)) 
 		return RZKERR_INVALID_HANDLE;

	/*If the passed variable is NULL return invalid argument error*/
	if(pSemaphoreParams == NULL)
		return RZKERR_INVALID_ARGUMENTS;	  

#endif /* RZK_DEBUG */
	
	/*If the created bit is set then return busy status*/
#ifndef RZK_PERFORMANCE
	if(!(pSemaphore->uState & OBJECT_CREATED))
		return RZKERR_CB_BUSY;
#endif

	/* copy all the parameters from the Semaphore control block to the semaphore parameter
		structure */
	pSemaphoreParams->uState = pSemaphore->uState;
	pSemaphoreParams->uInitialCount = pSemaphore->uInitialCount;
	pSemaphoreParams->uDynamicCount = pSemaphore->uDynamicCount;
	pSemaphoreParams->nNumThreads = GetMaxCount(pSemaphore->pResNext); 
	
	return RZKERR_SUCCESS;

} /* End of RZKGetSemaphoreParams */

⌨️ 快捷键说明

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