OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [mptests/] [mp02/] [task1.c] - Blame information for rev 778

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  Test_task
2
 *
3
 *  This task tests the rtems_task_set_note directive on a remote task and that
4
 *  errors are returned when attempting to delete, start, or restart
5
 *  a remote task.
6
 *
7
 *  Input parameters:
8
 *    argument - task argument
9
 *
10
 *  Output parameters:  NONE
11
 *
12
 *  COPYRIGHT (c) 1989-1999.
13
 *  On-Line Applications Research Corporation (OAR).
14
 *
15
 *  The license and distribution terms for this file may be
16
 *  found in the file LICENSE in this distribution or at
17
 *  http://www.OARcorp.com/rtems/license.html.
18
 *
19
 *  $Id: task1.c,v 1.2 2001-09-27 12:02:17 chris Exp $
20
 */
21
 
22
#include "system.h"
23
 
24
extern rtems_multiprocessing_table Multiprocessing_configuration;
25
 
26
rtems_task Test_task(
27
  rtems_task_argument argument
28
)
29
{
30
  rtems_id          tid;
31
  rtems_status_code status;
32
  rtems_unsigned32  remote_node;
33
  rtems_id          remote_tid;
34
  rtems_id          test_tid;
35
  rtems_unsigned32  note;
36
 
37
  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
38
 
39
  remote_node = (Multiprocessing_configuration.node == 1) ? 2 : 1;
40
  printf( "Remote task's name is : " );
41
  put_name( Task_name[ remote_node ], TRUE );
42
 
43
  puts( "Getting TID of remote task (all nodes)" );
44
  do {
45
      status = rtems_task_ident(
46
          Task_name[ remote_node ],
47
          RTEMS_SEARCH_ALL_NODES,
48
          &remote_tid
49
          );
50
  } while ( status != RTEMS_SUCCESSFUL );
51
 
52
  directive_failed( status, "rtems_task_ident" );
53
 
54
  puts( "Getting TID of remote task (1 node)" );
55
  status = rtems_task_ident( Task_name[ remote_node ], remote_node, &test_tid );
56
  directive_failed( status, "rtems_task_ident" );
57
 
58
  if ( test_tid != remote_tid ) {
59
    puts( "rtems_task_ident tid's do not match!!" );
60
    rtems_fatal_error_occurred( status );
61
  }
62
 
63
  status = rtems_task_delete( remote_tid );
64
  fatal_directive_status(
65
    status,
66
    RTEMS_ILLEGAL_ON_REMOTE_OBJECT,
67
    "rtems_task_delete of remote task"
68
  );
69
  puts( "rtems_task_delete of remote task returned the correct error" );
70
 
71
  status = rtems_task_start( remote_tid, Test_task, 0 );
72
  fatal_directive_status(
73
    status,
74
    RTEMS_ILLEGAL_ON_REMOTE_OBJECT,
75
    "rtems_task_start of remote task"
76
  );
77
  puts( "rtems_task_start of remote task returned the correct error" );
78
 
79
  status = rtems_task_restart( remote_tid, 0 );
80
  fatal_directive_status(
81
    status,
82
    RTEMS_ILLEGAL_ON_REMOTE_OBJECT,
83
    "rtems_task_restart of remote task"
84
  );
85
  puts( "rtems_task_restart of remote task returned the correct error" );
86
 
87
  printf(
88
   "Setting notepad %d of the remote task to %d\n",
89
   rtems_get_node(tid),
90
   rtems_get_node(tid)
91
  );
92
  status = rtems_task_set_note(
93
    remote_tid,
94
    rtems_get_node(tid),
95
    rtems_get_node(tid)
96
  );
97
  directive_failed( status, "rtems_task_set_note" );
98
 
99
  puts( "Getting a notepad of the remote task" );
100
  status = rtems_task_get_note( remote_tid, rtems_get_node(tid), &note );
101
  directive_failed( status, "rtems_task_get_note" );
102
 
103
  if ( note == rtems_get_node(tid) )
104
    puts( "Remote notepad set and read correctly" );
105
  else
106
    printf(
107
      "FAILURE!! Remote notepad was not set and read correctly (%d, %d)\n",
108
      note,
109
      rtems_get_node( tid )
110
    );
111
 
112
  status = rtems_task_wake_after( TICKS_PER_SECOND );
113
  directive_failed( status, "rtems_task_wake_after" );
114
 
115
  puts( "*** END OF TEST 2 ***" );
116
  exit( 0 );
117
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.