atdelctx.c

来自「T-kernel 的extension源代码」· C语言 代码 · 共 71 行

C
71
字号
/* *---------------------------------------------------------------------- *    T-Kernel / Standard Extension * *    Copyright (C) 2006 by Ken Sakamura. All rights reserved. *    T-Kernel / Standard Extension is distributed  *      under the T-License for T-Kernel / Standard Extension. *---------------------------------------------------------------------- * *    Version:   1.00.00 *    Released by T-Engine Forum(http://www.t-engine.org) at 2006/8/11. * *---------------------------------------------------------------------- *//* *	atdelctx.c (libtkse) * *	Discard the task context * *	The processing within library when task context is unnecessary  *      such as the task exit time, etc. */#include <tk/tkernel.h>#include <sys/libs.h>LOCAL void atdelctx_exec( ID tskid );IMPORT FP __atdelctx_entry;	/* delctx.c */#define	NENT	8#define TSD_ADC_RTN_M1	(-1)LOCAL void (*delctx_func[NENT])( ID tskid );/* * Execute the processing function when task context is discarded. */LOCAL void atdelctx_exec( ID tskid ){	W	i;	for ( i = NENT - 1; i >= 0; --i ) {		if ( delctx_func[i] != NULL ) {			(*delctx_func[i])(tskid);		}	}}/* * Register the processing when task context is discarded. */EXPORT int __atdelctx( void (*func)( ID tskid ) ){	W	i;	(void)_lib_lock(_LL_MISC, TRUE);	for ( i = 0; i < NENT; ++i ) {		if ( delctx_func[i] == NULL ) {			delctx_func[i] = func;			__atdelctx_entry = atdelctx_exec;			break;		}	}	_lib_unlock(_LL_MISC);	return ( i < NENT )? 0: TSD_ADC_RTN_M1;}

⌨️ 快捷键说明

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