[42d4ebe] | 1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
| 2 | |
---|
[ac7d5ef0] | 3 | /* Test_task |
---|
| 4 | * |
---|
| 5 | * This task tests the rtems_task_set_priority directive on a remote task. |
---|
| 6 | * |
---|
| 7 | * Input parameters: |
---|
| 8 | * argument - task argument |
---|
| 9 | * |
---|
| 10 | * Output parameters: NONE |
---|
| 11 | * |
---|
[08311cc3] | 12 | * COPYRIGHT (c) 1989-1999. |
---|
[ac7d5ef0] | 13 | * On-Line Applications Research Corporation (OAR). |
---|
| 14 | * |
---|
[42d4ebe] | 15 | * Redistribution and use in source and binary forms, with or without |
---|
| 16 | * modification, are permitted provided that the following conditions |
---|
| 17 | * are met: |
---|
| 18 | * 1. Redistributions of source code must retain the above copyright |
---|
| 19 | * notice, this list of conditions and the following disclaimer. |
---|
| 20 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
| 21 | * notice, this list of conditions and the following disclaimer in the |
---|
| 22 | * documentation and/or other materials provided with the distribution. |
---|
| 23 | * |
---|
| 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
| 28 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 29 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 30 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 31 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 32 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
| 34 | * POSSIBILITY OF SUCH DAMAGE. |
---|
[ac7d5ef0] | 35 | */ |
---|
| 36 | |
---|
[a4bc4d6e] | 37 | #ifdef HAVE_CONFIG_H |
---|
| 38 | #include "config.h" |
---|
| 39 | #endif |
---|
| 40 | |
---|
[ac7d5ef0] | 41 | #include "system.h" |
---|
[e0f5e98] | 42 | #include "tmacros.h" |
---|
[ac7d5ef0] | 43 | |
---|
| 44 | rtems_task Test_task( |
---|
| 45 | rtems_task_argument argument |
---|
| 46 | ) |
---|
| 47 | { |
---|
| 48 | rtems_id tid; |
---|
| 49 | rtems_status_code status; |
---|
[d8e681e] | 50 | uint32_t remote_node; |
---|
[ac7d5ef0] | 51 | rtems_id remote_tid; |
---|
| 52 | rtems_task_priority previous_priority; |
---|
| 53 | rtems_task_priority previous_priority_1; |
---|
| 54 | |
---|
[9b6362da] | 55 | status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid ); |
---|
[ac7d5ef0] | 56 | directive_failed( status, "rtems_task_ident" ); |
---|
| 57 | |
---|
| 58 | puts( "Getting TID of remote task" ); |
---|
[a00dff42] | 59 | remote_node = (rtems_object_get_local_node() == 1) ? 2 : 1; |
---|
[ac7d5ef0] | 60 | puts_nocr( "Remote task's name is : " ); |
---|
| 61 | put_name( Task_name[ remote_node ], TRUE ); |
---|
| 62 | |
---|
| 63 | do { |
---|
| 64 | status = rtems_task_ident( |
---|
| 65 | Task_name[ remote_node ], |
---|
| 66 | RTEMS_SEARCH_ALL_NODES, |
---|
| 67 | &remote_tid |
---|
| 68 | ); |
---|
| 69 | } while ( status != RTEMS_SUCCESSFUL ); |
---|
| 70 | |
---|
| 71 | directive_failed( status, "rtems_task_ident" ); |
---|
| 72 | |
---|
| 73 | status = rtems_task_set_priority( |
---|
| 74 | remote_tid, |
---|
[a00dff42] | 75 | rtems_object_get_local_node(), |
---|
[ac7d5ef0] | 76 | &previous_priority |
---|
| 77 | ); |
---|
| 78 | directive_failed( status, "rtems_task_set_priority" ); |
---|
| 79 | |
---|
| 80 | if ( previous_priority != remote_node ) { |
---|
| 81 | printf( |
---|
[e0f5e98] | 82 | "Remote priority (0x%" PRIxrtems_task_priority ") does not match remote node (0x%" PRIx32 ")!!!\n", |
---|
[ac7d5ef0] | 83 | previous_priority, |
---|
| 84 | remote_node |
---|
| 85 | ); |
---|
[116845e8] | 86 | rtems_test_exit( 0xf0000 ); |
---|
[ac7d5ef0] | 87 | } |
---|
| 88 | |
---|
| 89 | do { |
---|
| 90 | status = rtems_task_set_priority( |
---|
| 91 | RTEMS_SELF, |
---|
| 92 | RTEMS_CURRENT_PRIORITY, |
---|
| 93 | &previous_priority_1 |
---|
| 94 | ); |
---|
| 95 | directive_failed( status, "rtems_task_set_priority" ); |
---|
| 96 | } while ( previous_priority_1 != remote_node ); |
---|
| 97 | |
---|
| 98 | puts( "Local task priority has been set" ); |
---|
| 99 | |
---|
| 100 | puts( "*** END OF TEST 4 ***" ); |
---|
[116845e8] | 101 | rtems_test_exit( 0 ); |
---|
[ac7d5ef0] | 102 | } |
---|