source: rtems/testsuites/samples/unlimited/init.c @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 2.1 KB
RevLine 
[5f0cd34]1/*
2 *  COPYRIGHT (c) 1989-2012.
[f4a8ee1]3 *  On-Line Applications Research Corporation (OAR).
4 *
[5f0cd34]5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
[c499856]7 *  http://www.rtems.org/license/LICENSE.
[f4a8ee1]8 */
9
[e313551]10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
[df49c60]14#define CONFIGURE_INIT
[f4a8ee1]15
16#include "system.h"
[732276e]17#include "tmacros.h"
[f4a8ee1]18#include <stdio.h>
[d25d17b]19#include <stdlib.h>
[f4a8ee1]20
[9391f6d]21const char rtems_test_name[] = "UNLIMITED TASK";
22
[f4a8ee1]23rtems_id task_id[MAX_TASKS];
24
25rtems_task Init(
26  rtems_task_argument ignored
27)
28{
29  rtems_task_priority old_priority;
30  rtems_mode          old_mode;
[de48cb67]31  uint32_t            task;
[f4a8ee1]32
[9391f6d]33  TEST_BEGIN();
34
[f4a8ee1]35  /* lower the task priority to allow created tasks to execute */
[8f71a36]36
[de48cb67]37  rtems_task_set_priority(
38    RTEMS_SELF, RTEMS_MAXIMUM_PRIORITY - 1, &old_priority);
[f4a8ee1]39  rtems_task_mode(RTEMS_PREEMPT,  RTEMS_PREEMPT_MASK, &old_mode);
[8f71a36]40
[f4a8ee1]41  /*
42   * Invalid state if the task id is 0
43   */
[8f71a36]44
[f4a8ee1]45  for (task = 0; task < MAX_TASKS; task++)
46    task_id[task] = 0;
47
48  test1();
49  test2();
50  test3();
[8f71a36]51
[9391f6d]52  TEST_END();
[f4a8ee1]53  exit( 0 );
54}
55
56rtems_task test_task(
57  rtems_task_argument my_number
58  )
59{
60  rtems_event_set out;
[8f71a36]61
[073dff3]62  printf( "task %" PRIdrtems_task_argument " has started.\n",  my_number);
[f4a8ee1]63
64  rtems_event_receive(1, RTEMS_WAIT | RTEMS_EVENT_ANY, 0, &out);
[8f71a36]65
[073dff3]66  printf( "task %" PRIdrtems_task_argument " ending.\n",  my_number);
[f4a8ee1]67
68  rtems_task_delete(RTEMS_SELF);
69}
70
71void destory_all_tasks(
72  const char *who
73)
74{
[4c84d7b]75  uint32_t   task;
[8f71a36]76
[f4a8ee1]77  /*
78   *  If the id is not zero, signal the task to delete.
79   */
[8f71a36]80
[f4a8ee1]81  for (task = 0; task < MAX_TASKS; task++)
82    if (task_id[task])
83    {
[732276e]84      printf(" %s : signal task %08" PRIxrtems_id " to delete, ", who, task_id[task]);
[f59df6b2]85      fflush(stdout);
[f4a8ee1]86      rtems_event_send(task_id[task], 1);
87      task_id[task] = 0;
88    }
89}
90
[f0157b8]91bool status_code_bad(
[f4a8ee1]92  rtems_status_code status_code
93  )
94{
95  if (status_code != RTEMS_SUCCESSFUL)
96  {
97    printf("failure, ");
[8f71a36]98
[f4a8ee1]99    if (status_code == RTEMS_TOO_MANY)
100    {
[8f71a36]101      printf("too many.\n");
[f4a8ee1]102      return TRUE;
103    }
104    if (status_code == RTEMS_UNSATISFIED)
105    {
[8f71a36]106      printf("unsatisfied.\n");
[f4a8ee1]107      return TRUE;
108    }
109
110    printf("error code = %i\n", status_code);
111    exit( 1 );
112  }
113  return FALSE;
114}
Note: See TracBrowser for help on using the repository browser.