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

📄 cxtcre1.c

📁 上传一个带源代码的嵌入式实时多任务操作系统CMX
💻 C
字号:
/*********************************************************

Copyright (c) CMX Company. 1999. All rights reserved

*********************************************************/
/* version 5.30 */

#define CMXMODULE 1

#include <cxfuncs.h>	/* get cmx include header file */
#include <cxextern.h>	/* get cmx include header file */

#if (defined(CMXTRACKER) || defined(WINTRACKER))
#include <cmxtrack.h>	/* get cmx include header file */
#endif

/************************************************************
The following has been added, so user can pass the starting
address of a task, so as to allow multiple creations and
removing of tasks stacks, for when a task is removed after
using the 'normal' K_Task_Create function, the stack area is NOT
reclaimed.

This will allow stack area to be reclaimed if need be and if
user wants, also the ability to have different task use same
stack area, as long as they be CAREFUL to ensure that the tasks
sharing same stack do not run concurrently.
************************************************************/

byte K_Task_Create_Stack(byte priority,byte *tskid,CMX_FP task_addr,word16 *stack_start)
{
	tcbpointer tcbptr;
	byte i;

	K_I_Disable_Sched();	/* set task block */
	tcbptr = cmx_tcb;	/* start at beginning of linked list. */
	for (i = 0; ;i++)
		{
		if (tcbptr->nxttcb)	/* not NULL */
			{
			if ((++tcbptr) > &cmx_tcb[MAX_TASKS])	/* past MAXIMUM? */
				{
#if (defined(CMXTRACKER) || defined(WINTRACKER))
		if (CMXTRACKER_ON)
			{
			cmxtracker_in1(CXTCRE_K_ERROR);
			}
#endif
				K_I_Func_Return();	/* yes, return because no more room. */
				return(K_ERROR);	/* return ERROR. */
				}
			}
		else
			{
			break;	/* OK, exit out of for loop. */
			}
		}
	K_I_Priority_In(tcbptr,priority);	/* go load in task into priority chain */
	*tskid = i;	/* load in slot number */

	tcbptr->task_addr = task_addr;	/* load in task's CODE address */
	tcbptr->stk_start = stack_start;
	tcbptr->tcbstate = IDLE;	/* put the task into the IDLE state */
	tcbptr->trig = 0; /* load the start counter with 0, no starts */
#if (defined(CMXTRACKER) || defined(WINTRACKER))
		if (CMXTRACKER_ON)
			{
#if (defined(WINTRACKER))
			cmxtracker_in2(CXTCRE_K_OK,*tskid);
#else
			cmxtracker_in1(CXTCRE_K_OK);
#endif
			}
#endif
	K_I_Func_Return();	/* release task block */
	return(K_OK);	/* return good status */
}


⌨️ 快捷键说明

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