main.c

来自「运行于T-Engine(使用T-Kernel操作系统)的实例源码」· C语言 代码 · 共 50 行

C
50
字号
/* * main.c - an entry point of the sample application * * Copyright (C) YRP Ubiquitous Networking Laboratory, 2005. */#include <basic.h>#include <tk/tkernel.h>#include "sample1.h"/* * main routine */EXPORT INT main(INT ac, UB *av[]){  T_CTSK ctsk;          /* information for creating a task */  T_RTSK rtsk;          /* task information */  static ID tskid = -1; /* task ID */  if (ac < 0) {         /* in case of 'unlspg' command */    if (tskid >= 0) {      tet_exit();      /* wait until the child task exited */      while (tk_ref_tsk(tskid, &rtsk) >= E_OK) {        tk_dly_tsk(1);      }    }    return 0;  }  /* creating a task */  ctsk.exinf   = NULL;                  /* extra information */  ctsk.tskatr  = TA_HLNG | TA_RNG0;     /* task attributes */  ctsk.task    = tet_task;              /* start address of the task */  ctsk.itskpri = TET_TASK_PRI;          /* task priority when starting */  ctsk.stksz   = 1024 * 4;              /* stack size */  tskid = tk_cre_tsk(&ctsk);            /* create a task */  if (tskid < E_OK) { goto EXIT; }      /* failed in creating a task */  /* starting the task */  tk_sta_tsk(tskid, tk_get_tid());      /* start a task */  /* sleep until the child wakes up this task */  tk_slp_tsk(TMO_FEVR);EXIT:  return 0;}

⌨️ 快捷键说明

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