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

📄 init.c

📁 RTEMS (Real-Time Executive for Multiprocessor Systems) is a free open source real-time operating sys
💻 C
📖 第 1 页 / 共 2 页
字号:
/*  Init * *  This routine is the initialization task for this test program. *  It is called from init_exec and has the responsibility for creating *  and starting the tasks that make up the test.  If the time of day *  clock is required for the test, it should also be set to a known *  value by this function. * *  Input parameters:  NONE * *  Output parameters:  NONE * *  COPYRIGHT (c) 1989-1999. *  On-Line Applications Research Corporation (OAR). * *  The license and distribution terms for this file may be *  found in the file LICENSE in this distribution or at *  http://www.rtems.com/license/LICENSE. * *  $Id: init.c,v 1.10.2.1 2003/09/04 18:46:11 joel Exp $ */#define TEST_INIT#include "system.h"#include <stdio.h>#include <assert.h>void ITRON_Init( void ){  /*   *  Status Codes for these errors   *   *   *  E_OK - Normal Completion    *   *  E_NOMEM - Insufficient memory (Memory for control block and/or user   *            stack cannot be allocated)    *   *  E_ID - Invalid ID Number (tskid was invalid or could not be used)    *   *  E_RSATR - Reserved attribute (tskatr was invalid or could not be used)    *   *  E_OBJ - Invalid object state (a task of the same ID already exists)    *   *  E_OACV - Object access violation (A tskid less than -4 was specified    *           from a user task. This is implementation dependent.)    *   *  E_PAR - Parameter error (pk_ctsk, task, itskpri and/or stksz is invalid)    *   *  E_NOEXS - Object does not exist (the task specified by tskid does not   *            exist)    *   *  E_CTX - Context error (issued from task-independent portions or a task    *          in dispatch disabled state)    *   *   *   *  Network Specific Errors  (ITRON calls these Connection Function Errors)   *   *  EN_OBJNO - An object number which could not be accessed on the target   *             node is specified.    *   *  EN_CTXID - Specified an object on another node when the system call   *             was issued from a task in dispatch disabled state or from   *             a task-independent portion    *   *  EN_PAR - A value outside the range supported by the target node and/or    *           transmission packet format was specified as a parameter   *           (a value outside supported range was specified for exinf,   *           tskatr, task, itskpri and/or stksz)    *   *  EN_RPAR - A value outside the range supported by the requesting node    *            and/or transmission packet format was returned as a return    *            parameter (a value outside supported range was returned for   *            exinf, tskpri and/or tskstat)    *   */  rtems_time_of_day  time;  ER                 status;  T_CTSK             pk_ctsk;  T_RTSK             pk_rtsk;   /* Reference Task Packet */   puts( "\n\n*** ITRON TASK TEST 2 ***\n" );  build_time( &time, 12, 31, 1988, 9, 0, 0, 0 );  status = rtems_clock_set( &time );  directive_failed( status, "rtems_clock_set" );  /*   * Set My priority to 8 so that dummy tasks will be   * forced to run when started.   */    status = chg_pri( TSK_SELF, 8 );  fatal_directive_status( status, E_OK, "chg_pri of TSK_SELF");  status = ref_tsk( &pk_rtsk, TSK_SELF );  fatal_directive_status( status, E_OK, "ref_tsk of TSK_SELF");  fatal_directive_status( pk_rtsk.tskpri, 8, "task priority of SELF");    /*   * Create and verify a DORMANT task.   */  pk_ctsk.exinf    = NULL;  pk_ctsk.tskatr   = TA_HLNG;  pk_ctsk.itskpri  = 1;  pk_ctsk.task     = Dormant_task;  pk_ctsk.stksz    = RTEMS_MINIMUM_STACK_SIZE;   puts( "Init - cre_tsk - Dormant Task" );  status = cre_tsk( DORMANT_TASK_ID, &pk_ctsk );  fatal_directive_status( status, E_OK, "cre_tsk of DORMANT");  status = ref_tsk( &pk_rtsk, DORMANT_TASK_ID );  fatal_directive_status( status, E_OK, "ref_tsk of DORMANT");  fatal_directive_status( pk_rtsk.tskstat, TTS_DMT, "task state of DORMANT");  /*   * Create, Start and verify a not DORMANT task.   */    pk_ctsk.task     = Non_Dormant_task;  puts( "Init - cre_tsk - Non-Dormant Task" );  status = cre_tsk( NON_DORMANT_TASK_ID, &pk_ctsk );  fatal_directive_status( status, E_OK, "cre_tsk of NON_DORMANT");  status = sta_tsk( NON_DORMANT_TASK_ID, 1 );  status = ref_tsk( &pk_rtsk, NON_DORMANT_TASK_ID );  fatal_directive_status( status, E_OK, "ref_tsk of NON_DORMANT");  fatal_directive_status( pk_rtsk.tskstat,TTS_WAI,"task state of NON_DORMANT");        /*   *  Bad ID errors   */  puts( "\n*** Create Task Errors ***" );  puts( "Init - cre_tsk - access violation ( id less than -4) - E_OACV" );  status = cre_tsk( -5, &pk_ctsk );  fatal_directive_status( status, E_OACV, "cre_tsk of -5");  puts( "Init - cre_tsk - bad id (between 0 and -4) - E_ID" );  status = cre_tsk( -2, &pk_ctsk );  fatal_directive_status( status, E_ID, "cre_tsk of -2");  puts( "Init - cre_tsk - cannot create TSK_SELF  - E_ID" );  status = cre_tsk( TSK_SELF, &pk_ctsk );  fatal_directive_status( status, E_ID, "cre_tsk of TSK_SELF");  puts( "Init - cre_tsk - invalid id; id already exists  - E_OBJ" );  status = cre_tsk( 1, &pk_ctsk );  fatal_directive_status( status, E_OBJ, "cre_tsk of 1");  /*   *  Bad task attribute errors   */  pk_ctsk.tskatr = -1;  puts( "Init - cre_tsk - tskatr is invalid - E_RSATR" );  status = cre_tsk( 5, &pk_ctsk );  fatal_directive_status( status, E_RSATR, "cre_tsk with tskatr of -1");  puts( "Init - cre_tsk - pk_ctsk is invalid - E_PAR" );  status = cre_tsk( 5, NULL );  fatal_directive_status( status, E_PAR, "cre_tsk with NULL discription");  pk_ctsk.tskatr = TA_HLNG;  pk_ctsk.itskpri = 0;  puts( "Init - cre_tsk - itskpri is 0 - E_PAR" );  status = cre_tsk( 5, &pk_ctsk );  fatal_directive_status( status, E_PAR, "cre_tsk with priority of 0");  pk_ctsk.itskpri = 257;         /* XXX Design parameter not requirement. */  puts( "Init - cre_tsk - itskpri is 257 - E_PAR" );  status = cre_tsk( 5, &pk_ctsk );  fatal_directive_status( status, E_PAR, "cre_tsk with priority of 257");  pk_ctsk.stksz = -1;  puts( "Init - cre_tsk - stksz is invalid - E_PAR" );  status = cre_tsk( 5, &pk_ctsk );  fatal_directive_status( status, E_PAR, "cre_tsk with size of -1");  pk_ctsk.task = NULL;  puts( "Init - cre_tsk - task is invalid - E_PAR" );  status = cre_tsk( 5, &pk_ctsk );  fatal_directive_status( status, E_PAR, "cre_tsk with null task identifier");#if (0)  /* these errors can not be generated for cre_tsk at this time */  fatal_directive_status( status, E_NOMEM, "");  fatal_directive_status( status, EN_OBJNO, "");  fatal_directive_status( status, EN_CTXID, "");  fatal_directive_status( status, EN_PAR, "");#endif  puts( "\n\n*** Delete Task Errors ***" );  /*    *  Reset structure   */  pk_ctsk.exinf    = NULL;  pk_ctsk.tskatr   = TA_HLNG;  pk_ctsk.itskpri  = 1;   pk_ctsk.task     = Dormant_task;  pk_ctsk.stksz    = RTEMS_MINIMUM_STACK_SIZE;   puts( "Init - del_tsk - cannot delete TSK_SELF - E_OBJ" );  status = del_tsk( TSK_SELF );  fatal_directive_status( status, E_OBJ, "del_tsk with SELF");  puts( "Init - del_tsk - task is not DORMANT - E_OBJ" );  status = del_tsk( NON_DORMANT_TASK_ID );  fatal_directive_status( status, E_OBJ, "del_tsk NON_DORMANT");  puts( "Init - del_tsk - task does not exist - E_NOEXS" );  status = del_tsk( 5 );  fatal_directive_status( status, E_NOEXS, "del_tsk 5");  puts( "Init - del_tsk - access violation ( id less than -4) - E_OACV" );  status =  del_tsk( -5 );  fatal_directive_status( status, E_OACV, "del_tsk -5");  puts( "Init - del_tsk - cannot delete TSK_SELF - E_OBJ" );  status = del_tsk( TSK_SELF );  fatal_directive_status( status, E_OBJ, "del_tsk self");  puts( "Init - del_tsk - bad id (between 0 and -4) - E_ID" );  status = del_tsk( -3 );  fatal_directive_status( status, E_ID, "del_tsk -3");#if (0)  /* these errors can not be generated for del_tsk at this time */  fatal_directive_status( status, EN_OBJNO, "del_tsk ");  fatal_directive_status( status, EN_CTXID, "del_tsk ");#endif  puts( "\n\n*** Start Task Errors ***" );  puts( "Init - sta_tsk - access violation ( id less than -4) - E_OACV" );  status = sta_tsk( -5, 1 );  fatal_directive_status( status, E_OACV, "sta_tsk of -5");  puts( "Init - sta_tsk - bad id (between 0 and -4) - E_ID" );  status = sta_tsk( -2, 1 );  fatal_directive_status( status, E_ID, "sta_tsk of -2");  puts( "Init - sta_tsk - cannot start TSK_SELF - E_OBJ" );  status = sta_tsk( TSK_SELF, 1 );  fatal_directive_status( status, E_OBJ, "sta_tsk of self");  puts( "Init - sta_tsk - task is not DORMANT  - E_OBJ" );  status = sta_tsk( NON_DORMANT_TASK_ID, 1 );  fatal_directive_status( status, E_OBJ, "sta_tsk NON_DORMANT");  puts( "Init - sta_tsk - task does not exist  - E_NOEXS" );  status = sta_tsk( 5, 1 );  fatal_directive_status( status, E_NOEXS, "5");#if (0)  /* these errors can not be generated for sta_tsk at this time */  fatal_directive_status( status, EN_OBJNO, "sta_tsk");  fatal_directive_status( status, EN_CTXID, "sta_tsk");  fatal_directive_status( status, EN_PAR, "sta_tsk");#endif#if (0)  /* these errors can not be tested at this time */  puts( "\n\n*** Exit Task Errors ***" );  puts( "Init - ext_tsk - context error - E_CTX" );  status = ext_tsk(  );  fatal_directive_status( status, E_CTX, "ext_tsk ");  puts( "\n\n*** Exit and Delete Task Errors ***" );  puts( "Init - exd_tsk - context error - E_CTX" );  status = exd_tsk(  );  fatal_directive_status( status, E_CTX, "exd_tsk");#endif  puts( "\n\n*** Terminate Other Task Errors ***" );  puts( "Init - ter_tsk - bad id (between 0 and -4) - E_ID" );  status = ter_tsk( -2 );

⌨️ 快捷键说明

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