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

📄 getthreadparams.c

📁 zilog的实时操作系统RZK,可以移植到多种处理器上
💻 C
字号:
/*
* File			:	GetThreadParameters.c
*
* Description	:	This file contains the GetThreadParameters function 
*					which reads thread parameters into a user specified structure
* 
* 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 <string.h>	

#include "ZSysgen.h"
#include "ZTypes.h"
#include "ZThread.h"


#define pThread ((RZK_TCB_t *) hThread)

extern void* RZKMemcpy(void *, const void *, RZK_LENGTH_t); // IAR port, UINT changed to RZK_LENGTH_t
extern UINT8 cDebug;

/*
* Function		:	GetThreadParameters
*
* Description	:	This function reads the thread parameters into the user specified structure.
* 
* Inputs		:	hThread - Thread Handle,
*					pThreadParams  - Pointer to RZK_THREADPARAMS_t  structure that receives the thread parameters.
*
* Outputs		:	RZKERR_INVALID_HANDLE -if the specified thread handle is invalid
*					RZKERR_INVALID_ARGUMENTS - if the specified address of the structure is NULL. 
*
* Dependencies	:	All externs
*/

RZK_STATUS_t  RZKGetThreadParameters 
( 
	RZK_THREADHANDLE_t hThread, 
	RZK_THREADPARAMS_t *pThreadParams
														)
{
	/* check for the given ThreadHandle */ 
	
#ifdef RZK_DEBUG	/* Check for INVALID_HANDLE */
	if ( (pThread == NULL) || ( pThread->uState == 0 ) || ( pThread->magic_num != MAGIC_NUM_THREAD))
		return RZKERR_INVALID_HANDLE;

	if (pThreadParams == NULL)
		return RZKERR_INVALID_ARGUMENTS;
#endif /* RZK_DEBUG */

#ifndef	RZK_PERFORMANCE
	if ( ! (pThread->uState & OBJECT_CREATED) )
		return RZKERR_CB_BUSY;
#endif	/* RZK_PERFORMANCE */

   		if( pThread->uState & THREAD_TERMINATED ) 
			return RZKERR_INVALID_OPERATION;
		/*Copy all the parameters from the TCB to
		user specified structure   */	

#ifdef RZK_KERNEL_AWARE	/* Check for INVALID_HANDLE */
		RZKMemcpy(pThreadParams->szName, pThread->szName, MAX_OBJECT_NAME_LEN);
#else/* RZK_DEBUG */
		memset(pThreadParams->szName, 0x00, MAX_OBJECT_NAME_LEN);
#endif			

		pThreadParams->cPriority = pThread->cDispPriority;
		pThreadParams->uState = pThread->uState; 
		pThreadParams->tQuantum = pThread->tQuantum;
		pThreadParams->uBankSelector = pThread->uBankSelector;						
		pThreadParams->uOperationMode = pThread->uOperationMode;
		return RZKERR_SUCCESS;
}

⌨️ 快捷键说明

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