コード例 #1
0
ファイル: webmain.c プロジェクト: SayCV/rtems-missing_cpukit
/*
 *	Main -- entry point from RTEMS
 */
int rtems_initialize_webserver(void)
{
  rtems_status_code   sc;
  rtems_id            tid;
  int		      priority;

  /***********************************************************************
   * Default HTTPD priority.
   **********************************************************************/
  priority = 40;
  
  sc = rtems_task_create(rtems_build_name('H', 'T', 'P', 'D'),
			 priority, 8*1024,
			 RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_NO_ASR |
			 RTEMS_INTERRUPT_LEVEL(0),
			 RTEMS_NO_FLOATING_POINT | RTEMS_LOCAL,
			 &tid);
   if (sc != RTEMS_SUCCESSFUL)
   {
      return(RTEMS_UNSATISFIED);
   }

   sc = rtems_task_start(tid, rtems_httpd_daemon, 0);
   if (sc != RTEMS_SUCCESSFUL)
   {
      return(RTEMS_UNSATISFIED);
   }   

   return(RTEMS_SUCCESSFUL);

}
コード例 #2
0
ファイル: rtemspppd.c プロジェクト: epicsdeb/rtems
int rtems_pppd_initialize(void)
{
  int                 iReturn  = (int)-1;
  rtems_task_priority priority = 100;
  rtems_status_code   status;
  rtems_name          taskName;

  /* determine priority value */
  if ( rtems_bsdnet_config.network_task_priority ) {
    priority = rtems_bsdnet_config.network_task_priority;
  }

  /* initialize the exit hook */
  rtems_pppd_exitfp = (rtems_pppd_hookfunction)0;

  /* create the rtems task */
  taskName = rtems_build_name( 'p', 'p', 'p', 'd' );
  status   = rtems_task_create(taskName, priority, 8192,
                               (RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0)),
                               RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL,
                               &rtems_pppd_taskid);
  if ( status == RTEMS_SUCCESSFUL ) {
    status = rtems_task_start(rtems_pppd_taskid, pppTask, 0);
    if ( status == RTEMS_SUCCESSFUL ) {
      iReturn = rtems_pppd_reset_options();
    }
  }

  return ( iReturn );
}
コード例 #3
0
/* test bodies */
void test_interrupt_inline(void)
{
  rtems_interrupt_level level;
  rtems_attribute level_attribute, level_attribute_macro;
  bool                  in_isr;

  puts( "interrupt is in progress (use body)" );
  in_isr = rtems_interrupt_is_in_progress();
  if ( in_isr ) {
    puts( "interrupt reported to be is in progress (body)" );
    rtems_test_exit( 0 );
  }

  puts( "interrupt disable (use inline)" );
  rtems_interrupt_disable( level );

  puts( "interrupt flash (use inline)" );
  rtems_interrupt_flash( level );

  puts( "interrupt enable (use inline)" );
  rtems_interrupt_enable( level );

  puts( "interrupt level attribute (use inline)" );
  level_attribute = rtems_interrupt_level_attribute( level );
  level_attribute_macro = RTEMS_INTERRUPT_LEVEL(level);
  if ( level_attribute_macro == level_attribute ) {
    puts( "test case working.." );
  }
}
コード例 #4
0
void test_delete_as_side_effect(void)
{
  rtems_status_code sc;
  rtems_id          deleter_task;

  test_dtor_ran = 0;

  sc = rtems_task_create(rtems_build_name ('O', 'T', 'H', 'R'),
    RTEMS_MAXIMUM_PRIORITY - 1u,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0),
    RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL,
    &deleter_task
  );
  directive_failed( sc, "task create deleter" );

  sc = rtems_task_start(deleter_task, Task_variable_deleter, 0);
  directive_failed( sc, "task start deleter" );

  rtems_task_wake_after( 100 );

  if ( test_dtor_ran != 2 ) {
    printf(
      "Test dtor ran %" PRIu32 " times not 2 times as expected\n",
      test_dtor_ran
    );
    rtems_test_exit(0);
  }
}
コード例 #5
0
void test_delete_from_other_task(void)
{
  rtems_status_code sc;

  test_dtor_ran = 0;

  sc = rtems_task_ident( RTEMS_SELF, 0, &main_task );
  directive_failed( sc, "task ident" );

  sc = rtems_task_variable_add(RTEMS_SELF, (void **)&taskvar1, test_dtor);
  directive_failed( sc, "add for other task case" );

  sc = rtems_task_create(rtems_build_name ('O', 'T', 'H', 'R'),
    RTEMS_MAXIMUM_PRIORITY - 1u,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0),
    RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL,
    &other_task
  );
  directive_failed( sc, "task create other" );

  sc = rtems_task_start(other_task, Other_Task, 0);
  directive_failed( sc, "task start other" );

  rtems_task_wake_after( 100 );

  if ( test_dtor_ran != 1 ) {
    printf(
      "Test dtor ran %" PRIu32 " times not 1 times as expected\n",
      test_dtor_ran
    );
    rtems_test_exit(0);
  }
}
コード例 #6
0
ファイル: osdThread.c プロジェクト: ukaea/epics
/*
 * Create and start a new thread
 */
epicsThreadId
epicsThreadCreate (const char *name,
    unsigned int priority, unsigned int stackSize,
    EPICSTHREADFUNC funptr,void *parm)
{
    rtems_id tid;
    rtems_status_code sc;
    char c[4];

    if (!initialized) epicsThreadInit();
    if (stackSize < RTEMS_MINIMUM_STACK_SIZE) {
        errlogPrintf ("Warning: epicsThreadCreate %s illegal stackSize %d\n",name,stackSize);
        stackSize = RTEMS_MINIMUM_STACK_SIZE;
    }
    strncpy (c, name, sizeof c);
    sc = rtems_task_create (rtems_build_name (c[0], c[1], c[2], c[3]),
         epicsThreadGetOssPriorityValue (priority),
         stackSize,
         RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0),
         RTEMS_FLOATING_POINT|RTEMS_LOCAL,
         &tid);
    if (sc !=  RTEMS_SUCCESSFUL) {
        errlogPrintf ("epicsThreadCreate create failure for %s: %s\n",name, rtems_status_text (sc));
        return 0;
    }
    setThreadInfo (tid, name, funptr,parm);
    return (epicsThreadId)tid;
}
コード例 #7
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_time_of_day time;
  rtems_status_code status;

  puts( "\n\n*** TEST 1 ***" );

  build_time( &time, 12, 31, 1988, 9, 0, 0, 0 );
  status = rtems_clock_set( &time );
  directive_failed( status, "rtems_clock_set" );

  Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' );
  Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' );
  Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' );

  status = rtems_task_create(
     Task_name[ 1 ],
     1,
     RTEMS_MINIMUM_STACK_SIZE * 2,
     RTEMS_INTERRUPT_LEVEL(31),
     RTEMS_DEFAULT_ATTRIBUTES,
     &Task_id[ 1 ]
  );
  directive_failed( status, "rtems_task_create of TA1" );

  status = rtems_task_create(
     Task_name[ 2 ],
     1,
     RTEMS_MINIMUM_STACK_SIZE * 2,
     RTEMS_DEFAULT_MODES,
     RTEMS_DEFAULT_ATTRIBUTES,
     &Task_id[ 2 ]
  );
  directive_failed( status, "rtems_task_create of TA2" );

  status = rtems_task_create(
     Task_name[ 3 ],
     1,
     RTEMS_MINIMUM_STACK_SIZE * 3,
     RTEMS_DEFAULT_MODES,
     RTEMS_DEFAULT_ATTRIBUTES,
     &Task_id[ 3 ]
  );
  directive_failed( status, "rtems_task_create of TA3" );

  status = rtems_task_start( Task_id[ 1 ], Task_1_through_3, 0 );
  directive_failed( status, "rtems_task_start of TA1" );

  status = rtems_task_start( Task_id[ 2 ], Task_1_through_3, 0 );
  directive_failed( status, "rtems_task_start of TA2" );

  status = rtems_task_start( Task_id[ 3 ], Task_1_through_3, 0 );
  directive_failed( status, "rtems_task_start of TA3" );

  status = rtems_task_delete( RTEMS_SELF );
  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
}
コード例 #8
0
ファイル: init.c プロジェクト: lanzhongheng/rtems
static void test_isr_level_for_new_threads( ISR_Level last_proper_level )
{
  ISR_Level mask = CPU_MODES_INTERRUPT_MASK;
  ISR_Level current;
  test_isr_level_context ctx = {
    .master_task_id = rtems_task_self()
  };

  for ( current = 0 ; current <= mask ; ++current ) {
    rtems_mode initial_modes = RTEMS_INTERRUPT_LEVEL(current);
    rtems_id id;
    rtems_status_code sc;
    rtems_event_set events;

    ctx.actual_level = 0xffffffff;

    sc = rtems_task_create(
      rtems_build_name('I', 'S', 'R', 'L'),
      RTEMS_MINIMUM_PRIORITY,
      RTEMS_MINIMUM_STACK_SIZE,
      initial_modes,
      RTEMS_DEFAULT_ATTRIBUTES,
      &id
    );
    rtems_test_assert( sc == RTEMS_SUCCESSFUL );

    sc = rtems_task_start(
      id,
      isr_level_check_task,
      (rtems_task_argument) &ctx
    );
    rtems_test_assert( sc == RTEMS_SUCCESSFUL );

    sc = rtems_event_receive(
      TEST_ISR_EVENT,
      RTEMS_EVENT_ALL | RTEMS_WAIT,
      RTEMS_NO_TIMEOUT,
      &events
    );
    rtems_test_assert( sc == RTEMS_SUCCESSFUL );
    rtems_test_assert( events == TEST_ISR_EVENT );

    if ( current <= last_proper_level ) {
      rtems_test_assert( ctx.actual_level == current );
    } else {
      rtems_test_assert( ctx.actual_level == last_proper_level );
    }

    sc = rtems_task_delete( id ) ;
    rtems_test_assert( sc == RTEMS_SUCCESSFUL );
  }
}
コード例 #9
0
static void
createTask (char c, rtems_id *tid)
{
  rtems_status_code sc;

  sc = rtems_task_create (rtems_build_name('S','u','b',c),
    RTEMS_MAXIMUM_PRIORITY - 1u,
    RTEMS_MINIMUM_STACK_SIZE * 4,
    RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0),
    RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL,
    tid);
  if (sc != RTEMS_SUCCESSFUL) {
    printf ("Can't create task (%d)\n", sc);
    rtems_task_suspend (RTEMS_SELF);
  }
}
コード例 #10
0
ファイル: init.c プロジェクト: vecnatechnologies/rtems
/*
 * Spawn a task
 */
static void spawnTask(rtems_task_entry entryPoint, rtems_task_priority priority, rtems_task_argument arg)
{
    rtems_status_code sc;
    rtems_id tid;

    sc = rtems_task_create(rtems_build_name('t','a','s','k'),
                           priority,
                           RTEMS_MINIMUM_STACK_SIZE+(8*1024),
                           RTEMS_PREEMPT|RTEMS_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0),
                           RTEMS_FLOATING_POINT|RTEMS_LOCAL,
                           &tid);
    if (sc != RTEMS_SUCCESSFUL)
        rtems_panic("Can't create task: %s", rtems_status_text(sc));
    sc = rtems_task_start(tid, entryPoint, arg);
    if (sc != RTEMS_SUCCESSFUL)
        rtems_panic("Can't start task: %s", rtems_status_text(sc));
}
コード例 #11
0
void
starttask (int arg)
{
  rtems_id tid;
  rtems_status_code sc;

  sc = rtems_task_create(rtems_build_name ('S', 'R', 'V', arg + 'A'),
    RTEMS_MAXIMUM_PRIORITY - 1u,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0),
    RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL,
    &tid
  );
  directive_failed( sc, "task create" );

  sc = rtems_task_start(tid, subtask, arg);
  directive_failed( sc, "task start" );
}
コード例 #12
0
ファイル: init.c プロジェクト: AlexShiLucky/rtems
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_name        task_name;
  rtems_id          tid;
  rtems_status_code status;

  TEST_BEGIN();
  printf( "Creating and starting an application task\n" );
  task_name = rtems_build_name( 'T', 'A', '1', ' ' );
  status = rtems_task_create( task_name, 1, RTEMS_MINIMUM_STACK_SIZE,
             RTEMS_INTERRUPT_LEVEL(0), RTEMS_DEFAULT_ATTRIBUTES, &tid );
  status = rtems_task_start(
    tid,
    Application_task,
    Multiprocessing_configuration.node
  );
  status = rtems_task_delete( RTEMS_SELF );
}
コード例 #13
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_name        task_name;
  rtems_id          tid;
  rtems_status_code status;

  printf( "\n\n*** SAMPLE SINGLE PROCESSOR APPLICATION ***\n" );
  printf( "Creating and starting an application task\n" );

  task_name = rtems_build_name( 'T', 'A', '1', ' ' );

  status = rtems_task_create( task_name, 1, RTEMS_MINIMUM_STACK_SIZE,
             RTEMS_INTERRUPT_LEVEL(0), RTEMS_DEFAULT_ATTRIBUTES, &tid );

  status = rtems_task_start( tid, Application_task, ARGUMENT );

  status = rtems_task_delete( RTEMS_SELF );
}
コード例 #14
0
void starttask(
  int arg
)
{
  rtems_id tid;
  rtems_status_code sc;
  rtems_task_priority priority;

  rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &priority);
  sc = rtems_task_create(rtems_build_name('S', 'R', 'V', arg + 'A'),
    priority,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0),
    RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL,
    &tid);
  directive_failed( sc, "task create" );

  sc = rtems_task_start(tid, subtask, (rtems_task_argument) arg);
  directive_failed( sc, "task start" );
}
コード例 #15
0
ファイル: mon-editor.c プロジェクト: AoLaD/rtems
void
rtems_monitor_init(
    uint32_t   monitor_flags
)
{
    rtems_status_code status;

    rtems_monitor_kill();

    status = rtems_task_create(RTEMS_MONITOR_NAME,
                               1,
                               RTEMS_MINIMUM_STACK_SIZE * 2,
                               RTEMS_INTERRUPT_LEVEL(0),
                               RTEMS_DEFAULT_ATTRIBUTES,
                               &rtems_monitor_task_id);
    if (status != RTEMS_SUCCESSFUL)
    {
        rtems_error(status, "could not create monitor task");
        return;
    }

    rtems_monitor_node = rtems_object_id_get_node(rtems_monitor_task_id);
    rtems_monitor_default_node = rtems_monitor_node;

    rtems_monitor_server_init(monitor_flags);

    if (!(monitor_flags & RTEMS_MONITOR_NOTASK)) {
      /*
       * Start the monitor task itself
       */
      status = rtems_task_start(
        rtems_monitor_task_id, rtems_monitor_task, monitor_flags);
      if (status != RTEMS_SUCCESSFUL) {
        rtems_error(status, "could not start monitor");
        return;
      }
   }
}
コード例 #16
0
ファイル: init.c プロジェクト: 0871087123/rtems
void
startTask (rtems_id arg)
{
  rtems_id          tid;
  rtems_status_code sc;

  sc = rtems_task_create (rtems_build_name ('S', 'R', 'V', 'A'),
    RTEMS_MAXIMUM_PRIORITY - 1u,
    RTEMS_MINIMUM_STACK_SIZE * 2,
    RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0),
    RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL,
    &tid
  );
  if (sc != RTEMS_SUCCESSFUL) {
    printf ("Can't create task: %s\n", rtems_status_text (sc));
    rtems_task_suspend (RTEMS_SELF);
  }
  sc = rtems_task_start (tid, subtask, arg);
  if (sc != RTEMS_SUCCESSFUL) {
    printf ("Can't start task: %s\n", rtems_status_text (sc));
    rtems_task_suspend (RTEMS_SELF);
  }
}
コード例 #17
0
ファイル: init.c プロジェクト: AlexShiLucky/rtems
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_name        task_name;
  rtems_id          tid;
  rtems_status_code status;

  TEST_BEGIN();
  printf( "Creating and starting an application task\n" );

  task_name = rtems_build_name( 'T', 'A', '1', ' ' );

  status = rtems_task_create( task_name, 1, RTEMS_MINIMUM_STACK_SIZE,
             RTEMS_INTERRUPT_LEVEL(0), RTEMS_DEFAULT_ATTRIBUTES, &tid );
  directive_failed( status, "create" ); 

  status = rtems_task_start( tid, Application_task, ARGUMENT );
  directive_failed( status, "start" ); 

  status = rtems_task_delete( RTEMS_SELF );
  directive_failed( status, "delete" ); 
}
コード例 #18
0
ファイル: init.c プロジェクト: lanzhongheng/rtems
void test_interrupt_inline(void)
{
  rtems_interrupt_level level;
  rtems_mode            level_mode_body;
  rtems_mode            level_mode_macro;
  bool                  in_isr;

  puts( "interrupt is in progress (use body)" );
  in_isr = rtems_interrupt_is_in_progress();
  if ( in_isr ) {
    puts( "interrupt reported to be is in progress (body)" );
    rtems_test_exit( 0 );
  }

  puts( "interrupt disable (use inline)" );
  _Thread_Disable_dispatch();
  rtems_interrupt_disable( level );
  _Thread_Enable_dispatch();

  puts( "interrupt flash (use inline)" );
  _Thread_Disable_dispatch();
  rtems_interrupt_flash( level );
  _Thread_Enable_dispatch();

  puts( "interrupt enable (use inline)" );
  _Thread_Disable_dispatch();
  rtems_interrupt_enable( level );
  _Thread_Enable_dispatch();

  puts( "interrupt level mode (use inline)" );
  level_mode_body = rtems_interrupt_level_body( level );
  level_mode_macro = RTEMS_INTERRUPT_LEVEL(level);
  if ( level_mode_macro == level_mode_body ) {
    puts( "test case working.." );
  }
}
コード例 #19
0
ファイル: init.c プロジェクト: medivhc/rtems
void test_main(void) //Also acts as the write task
{

  rtems_id readTaskID;

  rtems_name readTaskName;

  char sendBuf_r1[SEND_RCV_BUFSIZ] = {0};
  char sendBuf_r2[SEND_RCV_BUFSIZ] = {0};
  int status = -1;
  int fd = 0;


  strcpy( sendBuf_r1, "SendBuffer1" );
  strcpy( sendBuf_r2, "SendBuffer2" );

  memset( &Barrier, 0, sizeof(Barrier) );
  status = rtems_barrier_create (
    rtems_build_name ( 'B', 'A', 'R', 't' ),
    RTEMS_BARRIER_AUTOMATIC_RELEASE,
    2,
    &Barrier
    );

  rtems_test_assert( status == RTEMS_SUCCESSFUL );

  puts("\n\n*** FIFO / PIPE OPEN TEST - 6 ***");

  puts("\nCreating a task name and a task");
  readTaskName = rtems_build_name('T','A','r',' ');

  status = rtems_task_create(
			     readTaskName,
			     1,
			     RTEMS_MINIMUM_STACK_SIZE * 2,
			     RTEMS_INTERRUPT_LEVEL(31),
			     RTEMS_DEFAULT_ATTRIBUTES,
			     &readTaskID
			     );
  
  rtems_test_assert( status == RTEMS_SUCCESSFUL );

  puts("\ncreating directory /tmp");
  status = mkdir("/tmp", 0777);
  rtems_test_assert(status == 0);

  puts("\ncreating fifo file /tmp/fifo01");
  status = mkfifo("/tmp/fifo01", 0777);
  rtems_test_assert(status == 0);

  puts("\nStarting the read task");
  status = rtems_task_start(readTaskID, read_task, 0);
  rtems_test_assert(status == 0);

  status = rtems_barrier_wait( Barrier, RTEMS_NO_TIMEOUT );
  rtems_test_assert( status == RTEMS_SUCCESSFUL );

  puts("\nWriter opening file(1)");
  fd = open("/tmp/fifo01", O_WRONLY);
  if(fd <= 0) {
    printf("Error opening file: (%d) :: %s", errno, strerror(errno));
    rtems_test_assert(0);
  }

  
  printf("\n@ sender: %s", sendBuf_r1);
  status = write(fd, sendBuf_r1, sizeof(sendBuf_r1)-1);
  rtems_test_assert(status == sizeof(sendBuf_r1)-1);

  status = close(fd);
  rtems_test_assert(status == 0);
  
  status = rtems_barrier_wait( Barrier, RTEMS_NO_TIMEOUT );
  rtems_test_assert( status == RTEMS_SUCCESSFUL );

  sleep(1);

  // Reader would have blocked by now
  puts("\nWriter opening file(2)");
  fd = open("/tmp/fifo01", O_WRONLY);
  if(fd <= 0) {
    printf("Error opening file: (%d) :: %s", errno, strerror(errno));
    rtems_test_assert(0);
  }

  printf("\n@ sender: %s", sendBuf_r2);
  status = write(fd, sendBuf_r2, sizeof(sendBuf_r2)-1);
  rtems_test_assert(status == sizeof(sendBuf_r2)-1);

  status = close(fd);
  rtems_test_assert(status == 0);

  status = rtems_barrier_wait( Barrier, RTEMS_NO_TIMEOUT );
  rtems_test_assert( status == RTEMS_SUCCESSFUL );

  puts( "Removing the fifo" );
  status = unlink("/tmp/fifo01");
  rtems_test_assert(status == 0);
  
  puts( "Removing /tmp" );
  status = rmdir("/tmp");
  rtems_test_assert(status == 0);
  
  puts("\n*** END OF FIFO / PIPE OPEN TEST - 6 ***");
}
コード例 #20
0
ファイル: mon-server.c プロジェクト: 0871087123/rtems
void
rtems_monitor_server_init(
    uint32_t   monitor_flags __attribute__((unused))
)
{
    #if defined(RTEMS_MULTIPROCESSING)
    rtems_status_code status;

    if (_System_state_Is_multiprocessing    &&
        (_Configuration_MP_table->maximum_nodes > 1))
    {
        uint32_t   maximum_nodes = _Configuration_MP_table->maximum_nodes;

        /*
         * create the msg que our server will listen
         * Since we only get msgs from other RTEMS monitors, we just
         * need reserve space for 1 msg from each node.
         */

        status = rtems_message_queue_create(
                       RTEMS_MONITOR_QUEUE_NAME,
                       maximum_nodes,
                       sizeof(rtems_monitor_server_request_t),
                       RTEMS_GLOBAL,
                       &rtems_monitor_server_request_queue_id);

        if (status != RTEMS_SUCCESSFUL)
        {
            rtems_error(status, "could not create monitor server message queue");
            goto done;
        }

        /*
         * create the msg que our responses will come on
         * Since monitor just does one thing at a time, we only need 1 item
         * message queue.
         */

        status = rtems_message_queue_create(
                       RTEMS_MONITOR_RESPONSE_QUEUE_NAME,
                       1, /* depth */
                       sizeof(rtems_monitor_server_response_t),
                       RTEMS_GLOBAL,
                       &rtems_monitor_server_response_queue_id);

        if (status != RTEMS_SUCCESSFUL)
        {
            rtems_error(status, "could not create monitor response message queue");
            goto done;
        }

        /* need an id for queue of each other server we might talk to */
        /* indexed by node, so add 1 to maximum_nodes */
        rtems_monitor_server_request_queue_ids =
                   (rtems_id *) malloc((maximum_nodes + 1) * sizeof(rtems_id));
        (void) memset(rtems_monitor_server_request_queue_ids,
                      0,
                      (maximum_nodes + 1) * sizeof(rtems_id));

        rtems_monitor_server_request_queue_ids[rtems_monitor_node] =
                   rtems_monitor_server_request_queue_id;

        /*
         * create the server task
         */
        status = rtems_task_create(RTEMS_MONITOR_SERVER_NAME,
                                   1,
                                   0 /* default stack */,
                                   RTEMS_INTERRUPT_LEVEL(0),
                                   RTEMS_DEFAULT_ATTRIBUTES,
                                   &rtems_monitor_server_task_id);
        if (status != RTEMS_SUCCESSFUL)
        {
            rtems_error(status, "could not create monitor server task");
            goto done;
        }

        /*
         * Start the server task
         */
        status = rtems_task_start(rtems_monitor_server_task_id,
                                  rtems_monitor_server_task,
                                  monitor_flags);
        if (status != RTEMS_SUCCESSFUL)
        {
            rtems_error(status, "could not start monitor server");
            goto done;
        }
    }

done:
    #endif
    return;
}
コード例 #21
0
rtems_task test_task(
  rtems_task_argument argument
)
{
  rtems_status_code   status;
  uint32_t      index;
  rtems_task_priority old_priority;
  rtems_time_of_day   time;
  uint32_t      old_note;
  uint32_t      old_mode;

  benchmark_timer_initialize();
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
      (void) benchmark_timer_empty_function();
  overhead = benchmark_timer_read();

  benchmark_timer_initialize();
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
      (void) rtems_task_set_priority(
               Test_task_id,
               RTEMS_CURRENT_PRIORITY,
               &old_priority
             );
  end_time = benchmark_timer_read();

  put_time(
    "rtems_task_set_priority: obtain current priority",
    end_time,
    OPERATION_COUNT,
    overhead,
    CALLING_OVERHEAD_TASK_SET_PRIORITY
  );

  benchmark_timer_initialize();
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
      (void) rtems_task_set_priority(
        Test_task_id,
        RTEMS_MAXIMUM_PRIORITY - 2u,
        &old_priority
      );

  end_time = benchmark_timer_read();

  put_time(
    "rtems_task_set_priority: returns to caller",
    end_time,
    OPERATION_COUNT,
    overhead,
    CALLING_OVERHEAD_TASK_SET_PRIORITY
  );

  benchmark_timer_initialize();
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
      (void) rtems_task_mode(
        RTEMS_CURRENT_MODE,
        RTEMS_CURRENT_MODE,
        &old_mode
      );
  end_time = benchmark_timer_read();

  put_time(
    "rtems_task_mode: obtain current mode",
    end_time,
    OPERATION_COUNT,
    overhead,
    CALLING_OVERHEAD_TASK_MODE
  );

  benchmark_timer_initialize();
    for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
      (void) rtems_task_mode(
        RTEMS_INTERRUPT_LEVEL(1),
        RTEMS_INTERRUPT_MASK,
        &old_mode
      );
      (void) rtems_task_mode(
        RTEMS_INTERRUPT_LEVEL(0),
        RTEMS_INTERRUPT_MASK,
        &old_mode
      );
    }
  end_time = benchmark_timer_read();

  put_time(
    "rtems_task_mode: no reschedule",
    end_time,
    OPERATION_COUNT * 2,
    overhead,
    CALLING_OVERHEAD_TASK_MODE
  );

  benchmark_timer_initialize();                 /* must be one host */
    (void) rtems_task_mode( RTEMS_NO_ASR, RTEMS_ASR_MASK, &old_mode );
  end_time = benchmark_timer_read();

  put_time(
    "rtems_task_mode: reschedule -- returns to caller",
    end_time,
    1,
    0,
    CALLING_OVERHEAD_TASK_MODE
  );

  status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode );
  directive_failed( status, "rtems_task_mode" );

  status = rtems_task_set_priority( Test_task_id, 1, &old_priority );
  directive_failed( status, "rtems_task_set_priority" );

  /* preempted by test_task1 */
  benchmark_timer_initialize();
    (void)  rtems_task_mode( RTEMS_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode );

  benchmark_timer_initialize();
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
      (void) rtems_task_set_note( Test_task_id, 8, 10 );
  end_time = benchmark_timer_read();

  put_time(
    "rtems_task_set_note",
    end_time,
    OPERATION_COUNT,
    overhead,
    CALLING_OVERHEAD_TASK_SET_NOTE
  );

  benchmark_timer_initialize();
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
      (void) rtems_task_get_note( Test_task_id, 8, &old_note );
  end_time = benchmark_timer_read();

  put_time(
    "rtems_task_get_note",
    end_time,
    OPERATION_COUNT,
    overhead,
    CALLING_OVERHEAD_TASK_GET_NOTE
  );

  build_time( &time, 1, 1, 1988, 0, 0, 0, 0 );

  benchmark_timer_initialize();
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
      (void) rtems_clock_set( &time );
  end_time = benchmark_timer_read();

  put_time(
    "rtems_clock_set",
    end_time,
    OPERATION_COUNT,
    overhead,
    CALLING_OVERHEAD_CLOCK_SET
  );

  benchmark_timer_initialize();
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
      (void) rtems_clock_get_tod( &time );
  end_time = benchmark_timer_read();

  put_time(
    "rtems_clock_get_tod",
    end_time,
    OPERATION_COUNT,
    overhead,
    CALLING_OVERHEAD_CLOCK_GET
  );

  puts( "*** END OF TEST 8 ***" );
  rtems_test_exit( 0 );
}
コード例 #22
0
ファイル: init.c プロジェクト: lanzhongheng/rtems
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_time_of_day     time;
  rtems_status_code     status;
  rtems_interrupt_level level;
  rtems_mode            level_mode_body;
  rtems_mode            level_mode_macro;
  bool                  in_isr;
  rtems_id              timer;
  int                   i;

  puts( "\n\n*** TEST 37 ***" );

  test_isr_level();
  test_isr_locks();
  test_interrupt_locks();

  build_time( &time, 12, 31, 1988, 9, 0, 0, 0 );
  status = rtems_clock_set( &time );
  directive_failed( status, "rtems_clock_set" );

  /*
   *  Timer used in multiple ways
   */
  status = rtems_timer_create( 1, &timer );
  directive_failed( status, "rtems_timer_create" );

  /*
   *  Test clock tick from outside ISR
   */
  status = rtems_clock_tick();
  directive_failed( status, "rtems_clock_tick" );
  puts( "clock_tick from task level" );

  /*
   *  Now do a dispatch directly out of a clock tick that is
   *  called from a task.  We need to create a task that will
   *  block so we have one to unblock.  Then we schedule a TSR
   *  to run in the clock tick but it has to be careful to
   *  make sure it is not called from an ISR and that the
   *  dispatching critical section is managed properly to
   *  make the dispatch happen.
   */

  blocked_task_status = -1;

  status = rtems_task_create(
    rtems_build_name( 'T', 'A', '1', ' ' ),
    1,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES,
    &blocked_task_id
  );
  directive_failed( status, "rtems_task_create" );

  status = rtems_task_start( blocked_task_id, blocked_task, 0 );
  directive_failed( status, "rtems_task_start" );

  status = rtems_task_wake_after( 10 );
  directive_failed( status, "rtems_task_wake_after" );

  status = rtems_timer_fire_after( timer, 1, test_unblock_task, NULL );
  directive_failed( status, "timer_fire_after failed" );

  /* we expect to be preempted from this call */
  for ( i=0 ; i<100 && blocked_task_status != 3 ; i++ ) {
    status = rtems_clock_tick();
    directive_failed( status, "rtems_clock_tick" );
  }
  switch ( blocked_task_status ) {
     case -1:
       puts(
         "clock_tick with task preempt -- task blocked, timer did not fire"
       );
       rtems_test_exit(0);
       break;
     case 1:
       puts( "clock_tick with task preempt -- timer fired case 1" );
       rtems_test_exit(0);
       break;
     case 2:
       puts( "clock_tick with task preempt -- timer fired case 2" );
       rtems_test_exit(0);
       break;
     case 3:
       puts( "clock_tick from task level with preempt -- OK" );
       break;
  }

  /*
   *  Test interrupt inline versions
   */
  test_interrupt_inline();

  /*
   *  Test interrupt bodies
   */
  puts( "interrupt is in progress (use body)" );
  in_isr = rtems_interrupt_is_in_progress();
  if ( in_isr ) {
    puts( "interrupt reported to be is in progress (body)" );
    rtems_test_exit( 0 );
  }

  puts( "interrupt disable (use body)" );
  _Thread_Disable_dispatch();
  level = rtems_interrupt_disable();
  _Thread_Enable_dispatch();

  puts( "interrupt disable (use body)" );
  _Thread_Disable_dispatch();
  level = rtems_interrupt_disable();
  _Thread_Enable_dispatch();

  puts( "interrupt flash (use body)" );
  _Thread_Disable_dispatch();
  rtems_interrupt_flash( level );
  _Thread_Enable_dispatch();

  puts( "interrupt enable (use body)" );
  _Thread_Disable_dispatch();
  rtems_interrupt_enable( level );
  _Thread_Enable_dispatch();

  puts( "interrupt level mode (use body)" );
  level_mode_body = rtems_interrupt_level_body( level );
  level_mode_macro = RTEMS_INTERRUPT_LEVEL(level);
  if ( level_mode_macro == level_mode_body ) {
    puts("test seems to work");
  }

  /*
   * Test ISR in progress from actual ISR
   */
  isr_in_progress_body   = -1;
  isr_in_progress_inline = -1;

  status = rtems_timer_fire_after( timer, 10, test_isr_in_progress, NULL );
  directive_failed( status, "timer_fire_after failed" );

  status = rtems_task_wake_after( 100 );
  directive_failed( status, "wake_after failed" );

  check_isr_worked( "inline", isr_in_progress_body );

  check_isr_worked( "body", isr_in_progress_body );

  puts( "*** END OF TEST 37 ***" );
  rtems_test_exit( 0 );
}
コード例 #23
0
ファイル: ftpd.c プロジェクト: epicsdeb/rtems
static int
task_pool_init(int count, rtems_task_priority priority)
{
  int i;
  rtems_status_code sc;
  char id = 'a';

  task_pool.count = 0;
  task_pool.head = task_pool.tail = 0;
  task_pool.mutex = (rtems_id)-1;
  task_pool.sem   = (rtems_id)-1;

  sc = rtems_semaphore_create(
    rtems_build_name('F', 'T', 'P', 'M'),
    1,
    RTEMS_DEFAULT_ATTRIBUTES
    | RTEMS_BINARY_SEMAPHORE
    | RTEMS_INHERIT_PRIORITY
    | RTEMS_PRIORITY,
    RTEMS_NO_PRIORITY,
    &task_pool.mutex);

  if(sc == RTEMS_SUCCESSFUL)
    sc = rtems_semaphore_create(
      rtems_build_name('F', 'T', 'P', 'S'),
      count,
      RTEMS_DEFAULT_ATTRIBUTES,
      RTEMS_NO_PRIORITY,
      &task_pool.sem);

  if(sc != RTEMS_SUCCESSFUL) {
    task_pool_done(0);
    syslog(LOG_ERR, "ftpd: Can not create semaphores");
    return 0;
  }

  task_pool.info = (FTPD_SessionInfo_t*)
    malloc(sizeof(FTPD_SessionInfo_t) * count);
  task_pool.queue = (FTPD_SessionInfo_t**)
    malloc(sizeof(FTPD_SessionInfo_t*) * count);
  if (NULL == task_pool.info || NULL == task_pool.queue)
  {
    task_pool_done(0);
    syslog(LOG_ERR, "ftpd: Not enough memory");
    return 0;
  }

  for(i = 0; i < count; ++i)
  {
    FTPD_SessionInfo_t *info = &task_pool.info[i];
    sc = rtems_task_create(rtems_build_name('F', 'T', 'P', id),
      priority, FTPD_STACKSIZE,
      RTEMS_PREEMPT | RTEMS_NO_TIMESLICE |
      RTEMS_NO_ASR | RTEMS_INTERRUPT_LEVEL(0),
      RTEMS_NO_FLOATING_POINT | RTEMS_LOCAL,
      &info->tid);
    if (sc == RTEMS_SUCCESSFUL)
    {
      sc = rtems_task_start(
        info->tid, session, (rtems_task_argument)info);
      if (sc != RTEMS_SUCCESSFUL)
        task_pool_done(i);
    }
    else
      task_pool_done(i + 1);
    if (sc != RTEMS_SUCCESSFUL)
    {
      syslog(LOG_ERR, "ftpd: Could not create/start FTPD session: %s",
        rtems_status_text(sc));
      return 0;
    }
    task_pool.queue[i] = task_pool.info + i;
    if (++id > 'z')
      id = 'a';
  }
  task_pool.count = count;
  return 1;
}
コード例 #24
0
ファイル: init.c プロジェクト: aniwang2013/leon-rtems
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_status_code       sc;
  void                   *opaque;
  rtems_id                current_task_id;
  rtems_id                task_id;
  rtems_name              another_task_name;
  Heap_Information_block  Info;
  
  puts( "\n\n*** TEST USER ENVIRONMENT ROUTINE - 01 ***" );

  puts( "Init - allocating most of heap -- OK" );
  opaque = rtems_heap_greedy_allocate( 0 );

  puts( "Init - attempt to reset env - expect RTEMS_NO_MEMORY" );
  sc = rtems_libio_set_private_env();
  rtems_test_assert( sc == RTEMS_NO_MEMORY );

  puts( "Init - freeing the allocated memory" );
  rtems_heap_greedy_free( opaque );

  puts( "Init - allocating most of workspace memory" );
  opaque = rtems_workspace_greedy_allocate( 0 );
  
  puts( "Init - attempt to reset env - expect RTEMS_TOO_MANY" );
  sc = rtems_libio_set_private_env();
  rtems_test_assert( sc == RTEMS_TOO_MANY );

  puts( "Init - freeing the workspace memory" );
  rtems_workspace_greedy_free( opaque );

  puts( "Init - creating a task name and a task -- OK" );

  another_task_name = 
    rtems_build_name( 'T','S','K','D' );

  sc = rtems_task_create( another_task_name,
			  1,
			  RTEMS_MINIMUM_STACK_SIZE * 2,
			  RTEMS_INTERRUPT_LEVEL(31),
			  RTEMS_DEFAULT_ATTRIBUTES,
			  &task_id
			  );

  puts( "Init - starting the task_routine, to set its private environment" );
  sc = rtems_task_start( task_id, task_routine, 0);
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );

  puts( "Init - attempt to share the env with another task -- Expect error" );
  sc = rtems_libio_share_private_env( task_id );
  rtems_test_assert( sc == RTEMS_UNSATISFIED );

  sleep( 1 );

  puts( "Init - attempt to share the env with another task -- OK" );
  sc = rtems_libio_share_private_env( task_id );
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
  rtems_test_assert( rtems_current_user_env->task_id == task_id );

  puts( "Init - Get current task id" );
  current_task_id = rtems_task_self();

  puts( "Init - Attempt to reset current task's environment" );
  sc = rtems_libio_set_private_env();
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
  rtems_test_assert( rtems_current_user_env->task_id == current_task_id );
  
  puts( "Init - attempt to share the env with another task -- OK" );
  sc = rtems_libio_share_private_env( task_id );
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
  rtems_test_assert( rtems_current_user_env->task_id == task_id );

  puts( "Init - attempt to share with self -- OK" );
  sc = rtems_libio_share_private_env( task_id );
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );

  puts( "*** END OF TEST USER ENVIRONMENT ROUTINE - 01 ***" );

  rtems_test_exit(0);
}
コード例 #25
0
ファイル: init.c プロジェクト: medivhc/rtems
rtems_task Init(
  rtems_task_argument not_used
)
{
  rtems_id readTaskID;

  rtems_name readTaskName;

  int status = -1;
  int fd = 0;
  uint32_t released = 0;
  int flag = 1;

  puts("\n*** FIFO / PIPE TESTS - 5 ***");

  memset( sendBuf, '1', SEND_RCV_BUFSIZ - 30 );
  memset( sendBuf, '2', 29 );
  sendBuf[SEND_RCV_BUFSIZ-1] = 0;

  memset( &rBarrier, 0, sizeof(rBarrier) );
  status = rtems_barrier_create (
    rtems_build_name ( 'B', 'A', 'R', 'r' ),
    RTEMS_BARRIER_MANUAL_RELEASE,
    2,
    &rBarrier
    );

  rtems_test_assert( status == RTEMS_SUCCESSFUL );

  memset( &wBarrier, 0, sizeof( wBarrier ) );
  status = rtems_barrier_create (
    rtems_build_name ( 'B', 'A', 'R', 'w' ),
    RTEMS_BARRIER_MANUAL_RELEASE,
    2,
    &wBarrier
    );
  rtems_test_assert( status == RTEMS_SUCCESSFUL );

  readTaskName = rtems_build_name( 'T','A','r',' ' );
  status = rtems_task_create(
			     readTaskName,
			     1,
			     RTEMS_MINIMUM_STACK_SIZE * 2,
			     RTEMS_INTERRUPT_LEVEL(31),
			     RTEMS_DEFAULT_ATTRIBUTES,
			     &readTaskID
			     );
  
  rtems_test_assert( status == RTEMS_SUCCESSFUL );

  puts( "Init - Creating fifo file /fifo" );
  status = mkfifo( "/fifo", 0777 );
  rtems_test_assert( status == 0 );

  puts( "Init - starting the read task" );
  status = rtems_task_start( readTaskID, read_task, 0 );
  rtems_test_assert( status == 0 );

  puts( "Init - waiting at a barrier" );
  status = rtems_barrier_wait( wBarrier, RTEMS_NO_TIMEOUT );
  rtems_test_assert( status == RTEMS_SUCCESSFUL );

  puts("Init - opening the fifo in write only mode -- OK");
  fd = open("/fifo", O_WRONLY);
  if(fd <= 0) {
    printf("Error opening file: (%d) :: %s\n", errno, strerror(errno));
    rtems_test_assert(0);
  }

  puts( "Init - writing to /fifo" );
  status = write(fd, sendBuf, 0 );
  rtems_test_assert( status == 0 );

  puts( "Init - releasing the read_task" );
  status = rtems_barrier_release( rBarrier, &released );
  rtems_test_assert( status == 0 );

  puts( "Init - waiting at a barrier" );
  status = rtems_barrier_wait( wBarrier, RTEMS_NO_TIMEOUT );
  rtems_test_assert( status == RTEMS_SUCCESSFUL );
  
  puts( "Init - writing to /fifo - OK" );
  status = write(fd, sendBuf, SEND_RCV_BUFSIZ - 30 );
  rtems_test_assert( status == SEND_RCV_BUFSIZ - 30 );

  puts( "Init - writing to /fifo - OK" );
  status = write(fd, sendBuf+SEND_RCV_BUFSIZ - 30, 30 );
  rtems_test_assert( status == 30 );

  puts( "Init - releasing the read_task" );
  status = rtems_barrier_release( rBarrier, &released );
  rtems_test_assert( status == 0 );

  puts( "Init - waiting at a barrier" );
  status = rtems_barrier_wait( wBarrier, RTEMS_NO_TIMEOUT );
  rtems_test_assert( status == RTEMS_SUCCESSFUL );  

  puts( "Init - converting the write-mode to non-block" );
  status = ioctl( fd, FIONBIO, &flag );
  rtems_test_assert( status == 0 );

  puts( "Init - writing to /fifo - OK" );
  status = write(fd, sendBuf, SEND_RCV_BUFSIZ - 30 );
  rtems_test_assert( status == SEND_RCV_BUFSIZ - 30 );
  
  puts( "Init - writing to /fifo - Expect EAGAIN" );
  status = write(fd, sendBuf, SEND_RCV_BUFSIZ - 30 );
  rtems_test_assert( status == -1 );
  rtems_test_assert( errno == EAGAIN );

  puts( "Init - releasing the read_task" );
  status = rtems_barrier_release( rBarrier, &released );
  rtems_test_assert( status == 0 );

  puts( "Init - waiting at a barrier" );
  status = rtems_barrier_wait( wBarrier, RTEMS_NO_TIMEOUT );
  rtems_test_assert( status == RTEMS_SUCCESSFUL );  

  puts( "Init - writing to /fifo - Expect EPIPE" );
  status = write(fd, sendBuf, SEND_RCV_BUFSIZ - 30 );
  rtems_test_assert( status == -1 );
  rtems_test_assert( errno == EPIPE );

  status = close( fd );
  rtems_test_assert( status == 0 );

  puts( "Removing the fifo" );
  status = unlink("/fifo");
  rtems_test_assert(status == 0);
  
  puts("*** END OF FIFO / PIPE OPEN TEST - 6 ***");
  rtems_test_exit(0);
}
コード例 #26
0
ファイル: task1.c プロジェクト: fsmd/RTEMS
rtems_task test_task(
  rtems_task_argument argument
)
{
  rtems_status_code   status;
  uint32_t      index;
  rtems_task_priority old_priority;
  rtems_time_of_day   time;
  uint32_t      old_note;
  uint32_t      old_mode;

  benchmark_timer_initialize();
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
      (void) benchmark_timer_empty_function();
  overhead = benchmark_timer_read();

  benchmark_timer_initialize();
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
      (void) rtems_task_set_priority(
               Test_task_id,
               RTEMS_CURRENT_PRIORITY,
               &old_priority
             );
  end_time = benchmark_timer_read();

  put_time(
    "rtems_task_set_priority: obtain current priority",
    end_time,
    OPERATION_COUNT,
    overhead,
    CALLING_OVERHEAD_TASK_SET_PRIORITY
  );

  benchmark_timer_initialize();
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
      (void) rtems_task_set_priority(
        Test_task_id,
        RTEMS_MAXIMUM_PRIORITY - 2u,
        &old_priority
      );

  end_time = benchmark_timer_read();

  put_time(
    "rtems_task_set_priority: returns to caller",
    end_time,
    OPERATION_COUNT,
    overhead,
    CALLING_OVERHEAD_TASK_SET_PRIORITY
  );

  benchmark_timer_initialize();
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
      (void) rtems_task_mode(
        RTEMS_CURRENT_MODE,
        RTEMS_CURRENT_MODE,
        &old_mode
      );
  end_time = benchmark_timer_read();

  put_time(
    "rtems_task_mode: obtain current mode",
    end_time,
    OPERATION_COUNT,
    overhead,
    CALLING_OVERHEAD_TASK_MODE
  );

  benchmark_timer_initialize();
    for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
      (void) rtems_task_mode(
        RTEMS_INTERRUPT_LEVEL(1),
        RTEMS_INTERRUPT_MASK,
        &old_mode
      );
      (void) rtems_task_mode(
        RTEMS_INTERRUPT_LEVEL(0),
        RTEMS_INTERRUPT_MASK,
        &old_mode
      );
    }
  end_time = benchmark_timer_read();

  put_time(
    "rtems_task_mode: no reschedule",
    end_time,
    OPERATION_COUNT * 2,
    overhead,
    CALLING_OVERHEAD_TASK_MODE
  );

  benchmark_timer_initialize();                 /* must be one host */
    (void) rtems_task_mode( RTEMS_NO_ASR, RTEMS_ASR_MASK, &old_mode );
  end_time = benchmark_timer_read();

  put_time(
    "rtems_task_mode: reschedule returns to caller",
    end_time,
    1,
    0,
    CALLING_OVERHEAD_TASK_MODE
  );

  status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode );
  directive_failed( status, "rtems_task_mode" );

  status = rtems_task_set_priority( Test_task_id, 1, &old_priority );
  directive_failed( status, "rtems_task_set_priority" );

  /* preempted by test_task1 */
  benchmark_timer_initialize();
    (void)  rtems_task_mode( RTEMS_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode );

  /** START OF NOTEPAD TESTS **/

  /*
   * We know this is deprecated and don't want a warning on every BSP built.
   */
  #pragma GCC diagnostic push
  #pragma GCC diagnostic ignored "-Wdeprecated-declarations"

    benchmark_timer_initialize();
      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
        (void) rtems_task_set_note( Test_task_id, 8, 10 );
    end_time = benchmark_timer_read();

    put_time(
      "rtems_task_set_note: only case",
      end_time,
      OPERATION_COUNT,
      overhead,
      CALLING_OVERHEAD_TASK_SET_NOTE
    );

    benchmark_timer_initialize();
      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
        (void) rtems_task_get_note( Test_task_id, 8, &old_note );
    end_time = benchmark_timer_read();

    put_time(
      "rtems_task_get_note: only case",
      end_time,
      OPERATION_COUNT,
      overhead,
      CALLING_OVERHEAD_TASK_GET_NOTE
    );

  #pragma GCC diagnostic pop

  /** END OF NOTEPAD TESTS **/

  build_time( &time, 1, 1, 1988, 0, 0, 0, 0 );

  benchmark_timer_initialize();
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
      (void) rtems_clock_set( &time );
  end_time = benchmark_timer_read();

  put_time(
    "rtems_clock_set: only case",
    end_time,
    OPERATION_COUNT,
    overhead,
    CALLING_OVERHEAD_CLOCK_SET
  );

  benchmark_timer_initialize();
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
      (void) rtems_clock_get_tod( &time );
  end_time = benchmark_timer_read();

  put_time(
    "rtems_clock_get_tod: only case",
    end_time,
    OPERATION_COUNT,
    overhead,
    CALLING_OVERHEAD_CLOCK_GET
  );

  TEST_END();
  rtems_test_exit( 0 );
}
コード例 #27
0
rtems_task Task_1(
  rtems_task_argument argument
)
{
  rtems_mode        previous_mode;
  rtems_status_code status;

  puts( "TA1 - rtems_signal_catch - RTEMS_INTERRUPT_LEVEL( 3 )" );
  status = rtems_signal_catch( Process_asr, RTEMS_INTERRUPT_LEVEL(3) );
  directive_failed( status, "rtems_signal_catch" );

  puts( "TA1 - rtems_signal_send - RTEMS_SIGNAL_16 to self" );
  status = rtems_signal_send( RTEMS_SELF, RTEMS_SIGNAL_16 );
  directive_failed( status, "rtems_signal_send" );

  puts( "TA1 - rtems_signal_send - RTEMS_SIGNAL_0 to self" );
  status = rtems_signal_send( RTEMS_SELF, RTEMS_SIGNAL_0 );
  directive_failed( status, "rtems_signal_send" );

  puts( "TA1 - rtems_signal_catch - RTEMS_NO_ASR" );
  status = rtems_signal_catch( Process_asr, RTEMS_NO_ASR );
  directive_failed( status, "rtems_signal_catch" );

  FLUSH_OUTPUT();

rtems_test_pause();

  puts( "TA1 - rtems_signal_send - RTEMS_SIGNAL_1 to self" );
  status = rtems_signal_send( RTEMS_SELF, RTEMS_SIGNAL_1 );
  directive_failed( status, "rtems_signal_send" );

  puts( "TA1 - rtems_task_mode - disable ASRs" );
  status = rtems_task_mode( RTEMS_NO_ASR, RTEMS_ASR_MASK, &previous_mode );
  directive_failed( status, "rtems_task_mode" );

  Timer_got_this_id = 0;
  Timer_got_this_pointer = NULL;

  puts( "TA1 - sending signal to RTEMS_SELF from timer" );
  status = rtems_timer_fire_after(
    Timer_id[ 1 ],
    rtems_clock_get_ticks_per_second() / 2,
    Signal_3_to_task_1,
    (void *) Task_1
  );
  directive_failed( status, "rtems_timer_fire_after" );

  puts( "TA1 - waiting for signal to arrive" );

  Signals_sent = FALSE;
  Asr_fired    = FALSE;

  while ( Signals_sent == FALSE )
    ;

  if ( Timer_got_this_id == Timer_id[ 1 ] &&
       Timer_got_this_pointer == Task_1 )
    puts( "TA1 - timer routine got the correct arguments" );
  else
    printf(
      "TA1 - timer got (0x%" PRIxrtems_id ", %p) instead of (0x%" PRIxrtems_id ", %p)!!!!\n",
      Timer_got_this_id,
      Timer_got_this_pointer,
      Timer_id[ 1 ],
      Task_1
    );

  puts( "TA1 - rtems_task_mode - enable ASRs" );
  FLUSH_OUTPUT();
  status = rtems_task_mode( RTEMS_ASR, RTEMS_ASR_MASK, &previous_mode );
  directive_failed( status, "rtems_task_mode" );

  status = rtems_task_wake_after(2 * rtems_clock_get_ticks_per_second());
  directive_failed( status, "rtems_task_wake_after" );

  puts( "TA1 - rtems_signal_catch - asraddr of NULL" );
  status = rtems_signal_catch( NULL, RTEMS_DEFAULT_MODES );
  directive_failed( status, "rtems_signal_catch" );

  puts( "TA1 - rtems_task_delete - delete self" );
  status = rtems_task_delete( RTEMS_SELF );
  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
}
コード例 #28
0
rtems_attribute rtems_interrupt_level_attribute(
  uint32_t   level
)
{
  return RTEMS_INTERRUPT_LEVEL(level);
}
コード例 #29
0
ファイル: ftpd.c プロジェクト: epicsdeb/rtems
/*PAGE
 *
 * rtems_ftpd_start
 *
 * Here, we start the FTPD task which waits for FTP requests and services
 * them.  This procedure returns to its caller once the task is started.
 *
 *
 * Input parameters:
 *
 * Output parameters:
 *    returns RTEMS_SUCCESSFUL on successful start of the daemon.
 */
int
rtems_initialize_ftpd(void)
{
  rtems_status_code   sc;
  rtems_id            tid;
  rtems_task_priority priority;
  int count;

  if (rtems_ftpd_configuration.port == 0)
  {
    rtems_ftpd_configuration.port = FTPD_CONTROL_PORT;
  }

  if (rtems_ftpd_configuration.priority == 0)
  {
    rtems_ftpd_configuration.priority = 40;
  }
  priority = rtems_ftpd_configuration.priority;

  ftpd_timeout = rtems_ftpd_configuration.idle;
  if (ftpd_timeout < 0)
    ftpd_timeout = 0;
  rtems_ftpd_configuration.idle = ftpd_timeout;

  ftpd_access = rtems_ftpd_configuration.access;

  if (rtems_ftpd_configuration.tasks_count <= 0)
    rtems_ftpd_configuration.tasks_count = 1;
  count = rtems_ftpd_configuration.tasks_count;

  if (!task_pool_init(count, priority))
  {
    syslog(LOG_ERR, "ftpd: Could not initialize task pool.");
    return RTEMS_UNSATISFIED;
  }

  sc = rtems_task_create(rtems_build_name('F', 'T', 'P', 'D'),
    priority, FTPD_STACKSIZE,
    RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_NO_ASR |
    RTEMS_INTERRUPT_LEVEL(0),
    RTEMS_NO_FLOATING_POINT | RTEMS_LOCAL,
    &tid);

  if (sc == RTEMS_SUCCESSFUL)
  {
    sc = rtems_task_start(tid, daemon, 0);
    if (sc != RTEMS_SUCCESSFUL)
      rtems_task_delete(tid);
  }

  if (sc != RTEMS_SUCCESSFUL)
  {
    task_pool_done(count);
    syslog(LOG_ERR, "ftpd: Could not create/start FTP daemon: %s",
      rtems_status_text(sc));
    return RTEMS_UNSATISFIED;
  }

  ftpd_root = "/";
  if (
    rtems_ftpd_configuration.root &&
    rtems_ftpd_configuration.root[0] == '/'
  )
    ftpd_root = rtems_ftpd_configuration.root;

  rtems_ftpd_configuration.root = ftpd_root;

  syslog(LOG_INFO, "ftpd: FTP daemon started (%d session%s max)",
    count, ((count > 1) ? "s" : ""));

  return RTEMS_SUCCESSFUL;
}