source: rtems/testsuites/mptests/mp04/task1.c

Last change on this file was 9b6362da, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 18, 2021 at 11:13:53 AM

rtems: Use RTEMS_WHO_AM_I for rtems_task_ident()

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*  Test_task
2 *
3 *  This task tests the rtems_task_set_priority directive on a remote task.
4 *
5 *  Input parameters:
6 *    argument - task argument
7 *
8 *  Output parameters:  NONE
9 *
10 *  COPYRIGHT (c) 1989-1999.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.org/license/LICENSE.
16 */
17
18#ifdef HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include "system.h"
23#include "tmacros.h"
24
25rtems_task Test_task(
26  rtems_task_argument argument
27)
28{
29  rtems_id            tid;
30  rtems_status_code   status;
31  uint32_t      remote_node;
32  rtems_id            remote_tid;
33  rtems_task_priority previous_priority;
34  rtems_task_priority previous_priority_1;
35
36  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid );
37  directive_failed( status, "rtems_task_ident" );
38
39  puts( "Getting TID of remote task" );
40  remote_node = (rtems_object_get_local_node() == 1) ? 2 : 1;
41  puts_nocr( "Remote task's name is : " );
42  put_name( Task_name[ remote_node ], TRUE );
43
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  status = rtems_task_set_priority(
55    remote_tid,
56    rtems_object_get_local_node(),
57    &previous_priority
58  );
59  directive_failed( status, "rtems_task_set_priority" );
60
61  if ( previous_priority != remote_node ) {
62    printf(
63      "Remote priority (0x%" PRIxrtems_task_priority ") does not match remote node (0x%" PRIx32 ")!!!\n",
64      previous_priority,
65      remote_node
66    );
67    rtems_test_exit( 0xf0000 );
68  }
69
70  do {
71    status = rtems_task_set_priority(
72      RTEMS_SELF,
73      RTEMS_CURRENT_PRIORITY,
74      &previous_priority_1
75    );
76    directive_failed( status, "rtems_task_set_priority" );
77  } while ( previous_priority_1 != remote_node );
78
79  puts( "Local task priority has been set" );
80
81  puts( "*** END OF TEST 4 ***" );
82  rtems_test_exit( 0 );
83}
Note: See TracBrowser for help on using the repository browser.