Ejemplo n.º 1
0
static void switch_priorities(test_context *self)
{
  rtems_status_code sc;
  size_t index = self->task_index;
  size_t next = (index + 1) & 0x1;
  size_t task_high = index;
  size_t task_low = next;
  rtems_task_priority priority;

  self->task_index = next;

  sc = rtems_task_set_priority(
    self->validate_tasks[task_high],
    PRIORITY_HIGH,
    &priority
  );
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_task_set_priority(
    self->validate_tasks[task_low],
    PRIORITY_LOW,
    &priority
  );
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
Ejemplo n.º 2
0
rtems_task BlockingTasks(rtems_task_argument arg)
{
  rtems_status_code   status;
  rtems_task_priority opri;
  rtems_task_priority npri;

  status = rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &opri);
  directive_failed( status, "rtems_task_set_priority" );

  printf(
    "semaphore_obtain -- BlockingTask %" PRIdrtems_task_argument
      " @ pri=%" PRIdrtems_task_priority ") blocks\n",
    arg,
    opri
  );
  status = rtems_semaphore_obtain(Semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
  directive_failed( status, "rtems_semaphore_obtain" );

  /* priority should have changed while blocked */
  status = rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &npri);
  directive_failed( status, "rtems_task_set_priority" );

  printf(
    "semaphore_obtain -- BlockingTask %" PRIdrtems_task_argument
      " @ pri=%" PRIdrtems_task_priority ") returns\n",
    arg,
    npri
  );

  (void) rtems_task_delete( RTEMS_SELF );
}
Ejemplo n.º 3
0
static void test_create_initially_locked_prio_inherit_sema(void)
{
  rtems_status_code   sc;
  rtems_id            id;
  rtems_task_priority prio_a;
  rtems_task_priority prio_b;
  rtems_task_priority prio_ceiling = 0;

  sc = rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &prio_a);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  rtems_test_assert(prio_a != prio_ceiling);

  sc = rtems_semaphore_create(
    rtems_build_name( 'S', 'E', 'M', 'A' ),
    0,
    RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY,
    prio_ceiling,
    &id
  );
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &prio_b);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  rtems_test_assert(prio_a == prio_b);

  sc = rtems_semaphore_release(id);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_semaphore_delete(id);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
Ejemplo n.º 4
0
/*
 * Test verifies priority,
 * Changes priority by obtaining a higher priority semaphore
 * Releases semaphore to return priority
 */
static void test(void)
{
  rtems_status_code   sc;
  rtems_task_priority priority;
  rtems_id            task_sem;

  sc = rtems_semaphore_create(  
    rtems_build_name('S', 'E', 'M', '0'),
    1,
    RTEMS_BINARY_SEMAPHORE |
    RTEMS_PRIORITY     |
    RTEMS_PRIORITY_CEILING, 
    5,
    &task_sem
  );  
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &priority);
  printf("Init: priority %d expected %d\n",(int)priority, TASK_PRIORITY );
  rtems_test_assert( priority == TASK_PRIORITY );

  printf("Init: Obtain Semaphore\n");
  sc = rtems_semaphore_obtain (task_sem, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
  rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &priority);
  printf("Init: priority %d expected %d\n",(int)priority, SEM_PRIORITY );
  rtems_test_assert( priority == SEM_PRIORITY );

  printf("Init: Release Semaphore\n");
  rtems_semaphore_release(task_sem);
  rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &priority);
  printf("Init: priority %d expected %d\n",(int)priority, TASK_PRIORITY );
  rtems_test_assert( priority == TASK_PRIORITY );
}
Ejemplo n.º 5
0
rtems_task Task_2(
  rtems_task_argument argument
)
{
  rtems_status_code   status;
  rtems_task_priority the_priority;
  rtems_task_priority previous_priority;

  while( FOREVER ) {

    status = rtems_task_get_note( RTEMS_SELF, RTEMS_NOTEPAD_8, &the_priority );
    directive_failed( status, "rtems_task_get_note" );
    printf(
"TA2 - rtems_task_get_note - get RTEMS_NOTEPAD_8 - current priority: %02" PRIdrtems_task_priority "\n",
      the_priority
    );

    if ( --the_priority == 0 ) {
      puts( "TA2 - rtems_task_suspend - suspend TA1" );
      status = rtems_task_suspend( Task_id[ 1 ] );
      directive_failed( status, "rtems_task_suspend" );

      puts( "TA2 - rtems_task_set_priority - set priority of TA1 ( blocked )" );
      status = rtems_task_set_priority( Task_id[ 1 ], 5, &previous_priority );
      directive_failed( status, "rtems_task_set_priority" );

      status = rtems_task_delete( Task_id[ 1 ] );          /* TA1 is blocked */
      directive_failed( status, "rtems_task_delete of TA1" );

      status = rtems_task_delete( Task_id[ 3 ] );          /* TA3 is ready   */
      directive_failed( status, "rtems_task_delete of TA3" );

      status = rtems_task_delete( RTEMS_SELF );
      directive_failed( status, "rtems_task_delete of SELD" );

    } else {

      printf( "TA2 - rtems_task_set_note - set TA1's RTEMS_NOTEPAD_8: %02" PRIdrtems_task_priority "\n",
              the_priority
      );
      status = rtems_task_set_note(Task_id[ 1 ], RTEMS_NOTEPAD_8, the_priority);
      directive_failed( status, "rtems_task_set_note" );

      printf( "TA2 - rtems_task_set_priority - set TA1's priority: %02" PRIdrtems_task_priority "\n",
              the_priority
      );
      status = rtems_task_set_priority(
                 Task_id[ 1 ],
                 the_priority,
                 &previous_priority
      );
      directive_failed( status, "rtems_task_set_priority" );
    }
  }
}
Ejemplo n.º 6
0
rtems_task Task_1(
  rtems_task_argument argument
)
{
  rtems_status_code   status;
  rtems_task_priority the_priority;
  rtems_task_priority previous_priority;

  rtems_test_pause();

  status = rtems_task_set_priority(
    RTEMS_SELF,
    RTEMS_CURRENT_PRIORITY,
    &the_priority
  );
  directive_failed( status, "rtems_task_set_priority" );
  printf(
    "TA1 - rtems_task_set_priority - get initial "
       "priority of self: %02" PRIdrtems_task_priority "\n",
    the_priority
  );

  while( FOREVER ) {
    if ( --the_priority == 0 ) {
      puts( "TA1 - rtems_task_suspend - suspend TA2" );
      status = rtems_task_suspend( Task_id[ 2 ] );
      directive_failed( status, "rtems_task_suspend" );

      puts( "TA1 - rtems_task_set_priority - set priority of TA2 ( blocked )" );
      status = rtems_task_set_priority( Task_id[ 2 ], 5, &previous_priority );
      directive_failed( status, "rtems_task_set_priority" );

      status = rtems_task_delete( Task_id[ 2 ] );
      directive_failed( status, "rtems_task_delete of TA2" );

      status = rtems_task_delete( RTEMS_SELF );
      directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
    }

    printf(
      "TA1 - rtems_task_set_priority - set TA2's priority: "
          "%02" PRIdrtems_task_priority "\n",
      the_priority
    );
    status = rtems_task_set_priority(
               Task_id[ 2 ],
               the_priority,
               &previous_priority
    );
    directive_failed( status, "rtems_task_set_priority" );
  }
}
Ejemplo n.º 7
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_status_code   status;
  rtems_task_priority previous_priority;

  TEST_BEGIN();

  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', ' ' );

  Argument = 0;
  Restart_argument = 1;

  status = rtems_task_create(
     Task_name[ 1 ],
     1,
     RTEMS_MINIMUM_STACK_SIZE,
     RTEMS_DEFAULT_MODES,
     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,
     RTEMS_DEFAULT_MODES,
     RTEMS_DEFAULT_ATTRIBUTES,
     &Task_id[ 2 ]
  );
  directive_failed( status, "rtems_task_create of TA2" );

  status = rtems_task_create(
     Task_name[ 3 ],
     10,
     RTEMS_MINIMUM_STACK_SIZE,
     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, 0 );
  directive_failed( status, "rtems_task_start of TA1" );

  status = rtems_task_start( Task_id[ 2 ], Task_2, Argument );
  directive_failed( status, "rtems_task_start of TA2" );

  status = rtems_task_start( Task_id[ 3 ], Task_3, Argument );
  directive_failed( status, "rtems_task_start of TA3" );

  status = rtems_task_set_priority( Task_id[ 3 ], 5, &previous_priority );

  status = rtems_task_delete( RTEMS_SELF );
  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
}
Ejemplo n.º 8
0
static void initialize_ftpfs(void)
{
  rtems_status_code sc = RTEMS_SUCCESSFUL;
  int rv = 0;
  struct timeval to = {
    .tv_sec = 10,
    .tv_usec = 0
  };
  const char *target = RTEMS_FTPFS_MOUNT_POINT_DEFAULT;

  rv = mount_and_make_target_path(
    NULL,
    target,
    RTEMS_FILESYSTEM_TYPE_FTPFS,
    RTEMS_FILESYSTEM_READ_WRITE,
    NULL
  );
  rtems_test_assert(rv == 0);

  sc = rtems_ftpfs_set_verbose(target, true);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_ftpfs_set_timeout(target, &to);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}

static void change_self_priority(void)
{
  rtems_status_code sc = RTEMS_SUCCESSFUL;
  rtems_task_priority cur = 0;

  sc = rtems_task_set_priority(RTEMS_SUCCESSFUL, 110, &cur);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
Ejemplo n.º 9
0
rtems_task Init(
  rtems_task_argument ignored
)
{
  rtems_task_priority old_priority;
  rtems_mode          old_mode;
  uint32_t            task;

  /* lower the task priority to allow created tasks to execute */

  rtems_task_set_priority(
    RTEMS_SELF, RTEMS_MAXIMUM_PRIORITY - 1, &old_priority);
  rtems_task_mode(RTEMS_PREEMPT,  RTEMS_PREEMPT_MASK, &old_mode);

  printf( "\n*** UNLIMITED TASK TEST ***\n" );

  /*
   * Invalid state if the task id is 0
   */

  for (task = 0; task < MAX_TASKS; task++)
    task_id[task] = 0;

  test1();
  test2();
  test3();

  printf( "\n*** END OF UNLIMITED TASK TEST ***\n" );
  exit( 0 );
}
Ejemplo n.º 10
0
/*
 * Server Task
 */
static rtems_task serverTask(rtems_task_argument arg)
{
    int s, s1;
    socklen_t addrlen;
    struct sockaddr_in myAddr, farAddr;
    rtems_task_priority myPriority;

    printf("Create socket.\n");
    s = socket(AF_INET, SOCK_STREAM, 0);
    if (s < 0)
        rtems_panic("Can't create socket: %s\n", strerror(errno));
    memset(&myAddr, 0, sizeof myAddr);
    myAddr.sin_family = AF_INET;
    myAddr.sin_port = htons(1234);
    myAddr.sin_addr.s_addr = htonl(INADDR_ANY);
    printf("Bind socket.\n");
    if (bind(s, (struct sockaddr *)&myAddr, sizeof myAddr) < 0)
        rtems_panic("Can't bind socket: %s\n", strerror(errno));
    if (listen(s, 5) < 0)
        printf("Can't listen on socket: %s\n", strerror(errno));
    rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &myPriority);
    for(;;) {
        addrlen = sizeof farAddr;
        s1 = accept(s, (struct sockaddr *)&farAddr, &addrlen);
        if (s1 < 0)
            if (errno == ENXIO)
                rtems_task_delete(RTEMS_SELF);
            else
                rtems_panic("Can't accept connection: %s", strerror(errno));
        else
            printf("ACCEPTED:%lX\n", ntohl(farAddr.sin_addr.s_addr));
        spawnTask(workerTask, myPriority, s1);
    }
}
Ejemplo n.º 11
0
Archivo: init.c Proyecto: gedare/rtems
static void set_priority(rtems_id id, rtems_task_priority prio)
{
  rtems_status_code sc;

  sc = rtems_task_set_priority(id, prio, &prio);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
Ejemplo n.º 12
0
static void change_prio(rtems_id task, rtems_task_priority prio)
{
  rtems_status_code sc;
  rtems_task_priority unused;

  sc = rtems_task_set_priority(task, prio, &unused);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
Ejemplo n.º 13
0
static void set_task_prio(rtems_id task, rtems_task_priority prio)
{
  rtems_status_code sc = RTEMS_SUCCESSFUL;
  rtems_task_priority cur = 0;

  sc = rtems_task_set_priority(task, prio, &cur);
  ASSERT_SC(sc);
}
Ejemplo n.º 14
0
Archivo: init.c Proyecto: gedare/rtems
static void assert_prio(rtems_id task_id, rtems_task_priority expected_prio)
{
  rtems_status_code sc;
  rtems_task_priority prio;

  sc = rtems_task_set_priority(task_id, RTEMS_CURRENT_PRIORITY, &prio);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
  rtems_test_assert(prio == expected_prio);
}
Ejemplo n.º 15
0
rtems_task_priority Get_current_pri(void)
{
    rtems_status_code status;
    rtems_task_priority pri;

    status = rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &pri);
    directive_failed( status, " rtems_task_set_priority ");
    return pri;
}
Ejemplo n.º 16
0
Archivo: init.c Proyecto: gedare/rtems
static int getprio(void)
{
  rtems_status_code status;
  rtems_task_priority pri;

  status = rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &pri);
  directive_failed( status, "rtems_task_set_priority");
  return (int)pri;
}
Ejemplo n.º 17
0
void
epicsThreadSetPriority (epicsThreadId id,unsigned int osip)
{
    rtems_id tid = (rtems_id)id;
    rtems_status_code sc;
    rtems_task_priority pri = epicsThreadGetOssPriorityValue(osip);

    sc = rtems_task_set_priority (tid, pri, &pri);
    if (sc != RTEMS_SUCCESSFUL)
        errlogPrintf("epicsThreadSetPriority failed: %s\n", rtems_status_text (sc));
}
Ejemplo n.º 18
0
unsigned int epicsThreadGetPriority(epicsThreadId id)
{
    rtems_id tid = (rtems_id)id;
    rtems_status_code sc;
    rtems_task_priority pri;

    sc = rtems_task_set_priority (tid, RTEMS_CURRENT_PRIORITY, &pri);
    if (sc != RTEMS_SUCCESSFUL)
        errlogPrintf("epicsThreadGetPriority failed: %s\n", rtems_status_text (sc));
    return epicsThreadGetOsiPriorityValue (pri);
}
Ejemplo n.º 19
0
static rtems_task_priority set_prio(rtems_id id, rtems_task_priority prio)
{
  rtems_status_code sc;
  rtems_task_priority old_prio;

  old_prio = 0xffffffff;
  sc = rtems_task_set_priority(id, prio, &old_prio);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  return old_prio;
}
Ejemplo n.º 20
0
rtems_task Task_1(
  rtems_task_argument argument
)
{
  rtems_id          tid2;
  rtems_id          tid3;
  rtems_status_code status;
  rtems_name        tid2_name;
  uint32_t    previous_priority;

  puts( "TA1 - rtems_task_wake_after - sleep 1 second" );
  status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
  directive_failed( status, "rtems_task_wake_after" );

  status = rtems_task_ident( Task_name[ 2 ], RTEMS_SEARCH_ALL_NODES, &tid2 );
  directive_failed( status, "rtems_task_ident of TA2" );

  printf(
    "TA1 - rtems_task_ident - tid of TA2 (0x%.8" PRIxrtems_id ")\n", tid2
  );
  status = rtems_object_get_classic_name( tid2, &tid2_name );
  directive_failed( status, "rtems_object_get_classic_name of TA2" );

  printf( "TA1 - rtems_get_classic_name - id -> name of TA2 %sOK\n",
    (tid2_name != Task_name[2]) ? "NOT " : "" );

  status = rtems_task_ident( Task_name[ 3 ], RTEMS_SEARCH_ALL_NODES, &tid3 );
  directive_failed( status, "rtems_task_ident of TA3" );

  printf(
    "TA1 - rtems_task_ident - tid of TA3 (0x%.8" PRIxrtems_id ")\n", tid3
  );

  status = rtems_task_set_priority( tid3, 2, &previous_priority );
  directive_failed( status, "rtems_task_set_priority" );

  puts( "TA1 - rtems_task_set_priority - set TA3's priority to 2" );

  puts( "TA1 - rtems_task_suspend - suspend TA2" );
  status = rtems_task_suspend( tid2 );
  directive_failed( status, "rtems_task_suspend of TA2" );

  puts( "TA1 - rtems_task_delete - delete TA2" );
  status = rtems_task_delete( tid2 );
  directive_failed( status, "rtems_task_delete of TA2" );

  puts( "TA1 - rtems_task_wake_after - sleep for 5 seconds" );
  status = rtems_task_wake_after( 5 * rtems_clock_get_ticks_per_second() );
  directive_failed( status, "rtems_task_wake_after" );

  puts( "*** END OF TEST 2 ***" );
  rtems_test_exit( 0 );
}
Ejemplo n.º 21
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_status_code     status;
  rtems_id              id;
  rtems_task_priority 	old;

  puts( "\n\n*** SP76 (YIELD) TEST ***" );

  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &id );
  directive_failed( status, "task ident" );

  /* to make sure it is equal to TA2 */
  puts( "Set Init task priority = 2" );
  status = rtems_task_set_priority( id, 2, &old );
  directive_failed( status, "task priority" );

  puts( "Create TA1 at higher priority task" );
  status = rtems_task_create(
    rtems_build_name( 'T', 'A', '1', ' ' ),
    1,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES,
    &id
  );
  directive_failed( status, "create 1" );

  status = rtems_task_start( id, Test_task, 1 );
  directive_failed( status, "start 1" );

  puts( "Create TA2 at equal priority task" );
  status = rtems_task_create(
    rtems_build_name( 'T', 'A', '2', ' ' ),
    2,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES,
    &id
  );
  directive_failed( status, "create 2" );

  status = rtems_task_start( id, Test_task, 1 );
  directive_failed( status, "start 2" );

  puts( "Yield to TA1" );
  status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
  directive_failed( status, "yield" );

  puts( "*** should now get here ***" );
}
Ejemplo n.º 22
0
static rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_task_priority prio;
  rtems_status_code status;

  TEST_BEGIN();

  Master = rtems_task_self();

  if (RTEMS_MAXIMUM_PRIORITY >= 255)
    Priorities = Priorities_High;
  else if (RTEMS_MAXIMUM_PRIORITY >= 15)
    Priorities = Priorities_Low;
  else {
    puts( "Test needs at least 16 configured priority levels" );
    rtems_test_exit( 0 );
  }

  prio = RTEMS_MAXIMUM_PRIORITY - 1;
  status = rtems_task_set_priority(RTEMS_SELF, prio, &prio);
  directive_failed( status, "rtems_task_set_priority" );

  if ( sizeof(Priorities_Low) / sizeof(rtems_task_priority) != MAX_TASKS ) {
    puts( "Priorities_Low table does not have right number of entries" );
    rtems_test_exit( 0 );
  }

  if ( sizeof(Priorities_High) / sizeof(rtems_task_priority) != MAX_TASKS ) {
    puts( "Priorities_High table does not have right number of entries" );
    rtems_test_exit( 0 );
  }

  puts( "Exercising blocking discipline w/extract in FIFO order " );
  do_test( RTEMS_FIFO, TRUE );

  puts( "Exercising blocking discipline w/unblock in FIFO order" );
  do_test( RTEMS_FIFO, FALSE );

  rtems_test_pause_and_screen_number( 2 );

  puts( "Exercising blocking discipline w/extract in priority order " );
  do_test( RTEMS_PRIORITY, TRUE );

  puts( "Exercising blocking discipline w/unblock in priority order" );
  do_test( RTEMS_PRIORITY, FALSE );

  TEST_END();
  rtems_test_exit(0);
}
Ejemplo n.º 23
0
static void thread_delete_hook(
  Thread_Control *executing,
  Thread_Control *deleted
)
{
  rtems_status_code sc = RTEMS_SUCCESSFUL;

  if (deleted->Object.id == task_0) {
    rtems_task_priority old = 0;

    sc = rtems_task_set_priority(task_1, 2, &old);
    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
  }
}
Ejemplo n.º 24
0
Archivo: init.c Proyecto: gedare/rtems
static void *thread_b(void *arg)
{
  test_context *ctx;
  rtems_id scheduler_b_id;
  rtems_status_code sc;
  rtems_task_priority prio;
  int prio_ceiling;
  int eno;

  ctx = arg;

  rtems_test_assert(rtems_get_current_processor() == 0);

  sc = rtems_scheduler_ident(SCHED_B, &scheduler_b_id);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_task_set_priority(pthread_self(), RTEMS_CURRENT_PRIORITY, &prio);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_task_set_scheduler(pthread_self(), scheduler_b_id, prio);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  rtems_test_assert(rtems_get_current_processor() == 1);

  eno = pthread_mutex_init(&ctx->mtx_b, &ctx->mtx_attr);
  rtems_test_assert(eno == 0);

  eno = pthread_mutex_getprioceiling(&ctx->mtx_b, &prio_ceiling);
  rtems_test_assert(eno == 0);
  rtems_test_assert(prio_ceiling == 254);

  eno = pthread_mutex_lock(&ctx->mtx_b);
  rtems_test_assert(eno == 0);

  eno = pthread_mutex_unlock(&ctx->mtx_b);
  rtems_test_assert(eno == 0);

  eno = pthread_mutex_destroy(&ctx->mtx_b);
  rtems_test_assert(eno == 0);

  eno = pthread_mutex_getprioceiling(&ctx->mtx_a, &prio_ceiling);
  rtems_test_assert(eno == 0);
  rtems_test_assert(prio_ceiling == 126);

  eno = pthread_mutex_lock(&ctx->mtx_a);
  rtems_test_assert(eno == EINVAL);

  return ctx;
}
Ejemplo n.º 25
0
rtems_task Middle_tasks(
  rtems_task_argument argument
)
{
  rtems_task_priority previous_priority;

  Task_priority--;
  Task_count++;

  (void) rtems_task_set_priority(
           Task_id[ Task_count ],
           Task_priority,
           &previous_priority
         );
}
Ejemplo n.º 26
0
rtems_task First_task(
  rtems_task_argument argument
)
{
  rtems_task_priority previous_priority;

  benchmark_timer_initialize();

  Task_priority--;
  Task_count++;

  (void) rtems_task_set_priority(
           Task_id[ Task_count ],
           Task_priority,
           &previous_priority
         );
}
Ejemplo n.º 27
0
static void assert_prio(
  test_context *ctx,
  task_id id,
  rtems_task_priority expected
)
{
  rtems_task_priority actual;
  rtems_status_code sc;

  sc = rtems_task_set_priority(
    ctx->tasks[id],
    RTEMS_CURRENT_PRIORITY,
    &actual
  );
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
  rtems_test_assert(expected == actual);
}
Ejemplo n.º 28
0
/*
 * OS-dependent initialization
 * No need to worry about making this thread-safe since
 * it must be called before epicsThreadCreate creates
 * any new threads.
 */
static void
epicsThreadInit (void)
{
    if (!initialized) {
        rtems_id tid;
        rtems_task_priority old;

        rtems_task_set_priority (RTEMS_SELF, epicsThreadGetOssPriorityValue(99), &old);
        onceMutex = epicsMutexMustCreate();
        taskVarMutex = epicsMutexMustCreate ();
        rtems_task_ident (RTEMS_SELF, 0, &tid);
        setThreadInfo (tid, "_main_", NULL, NULL);
        initialized = 1;
        epicsThreadCreate ("ImsgDaemon", 99,
                epicsThreadGetStackSize (epicsThreadStackSmall),
                InterruptContextMessageDaemon, NULL);
    }
}
Ejemplo n.º 29
0
Archivo: init.c Proyecto: medivhc/rtems
rtems_task Init(
  rtems_task_argument ignored
)
{
#if BSP_SMALL_MEMORY
  printf("NO Capture Engine. MEMORY TOO SMALL");
#else
  rtems_status_code   status;
  rtems_task_priority old_priority;
  rtems_mode          old_mode;

  puts( "\n\n*** TEST CAPTURE ENGINE ***" );

  status = rtems_shell_wait_for_input(
    STDIN_FILENO,
    20,
    notification,
    NULL
  );
  if (status == RTEMS_SUCCESSFUL) {
    /* lower the task priority to allow created tasks to execute */

    rtems_task_set_priority(RTEMS_SELF, 20, &old_priority);
    rtems_task_mode(RTEMS_PREEMPT,  RTEMS_PREEMPT_MASK, &old_mode);

    while (!can_proceed)
    {
      printf ("Sleeping\n");
      usleep (1000000);
    }

    rtems_monitor_init (0);
    rtems_capture_cli_init (0);

    setup_tasks_to_watch ();

    rtems_task_delete (RTEMS_SELF);
  } else {
    puts( "*** END OF TEST CAPTURE ENGINE ***" );

    exit( 0 );
  }
#endif
}
Ejemplo n.º 30
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" );
}