File indexing completed on 2025-05-11 08:24:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #ifdef HAVE_CONFIG_H
0024 #include "config.h"
0025 #endif
0026
0027 #include <tmacros.h>
0028 #include <rtems.h>
0029 #include <stdio.h>
0030 #include <stdlib.h>
0031
0032 const char rtems_test_name[] = "SP 44";
0033
0034 rtems_task Init(rtems_task_argument ignored);
0035 rtems_task TaskAB_entry(rtems_task_argument me);
0036
0037
0038 #define TASK_A_PRIORITY 10
0039 #define TASK_B_PRIORITY 10
0040
0041
0042 #define TASK_A_NAME 1
0043 #define TASK_B_NAME 2
0044
0045
0046 #define TASK_A_INITMODE RTEMS_DEFAULT_MODES
0047 #define TASK_B_INITMODE RTEMS_DEFAULT_MODES
0048
0049
0050 #define TASK_A_STACKSIZE RTEMS_MINIMUM_STACK_SIZE
0051 #define TASK_A_MODEATTR RTEMS_DEFAULT_ATTRIBUTES
0052 #define TASK_B_STACKSIZE RTEMS_MINIMUM_STACK_SIZE
0053 #define TASK_B_MODEATTR RTEMS_DEFAULT_ATTRIBUTES
0054
0055 volatile uint32_t turn;
0056 rtems_id TaskA_id, TaskB_id;
0057
0058
0059 rtems_task TaskAB_entry(rtems_task_argument me)
0060 {
0061 static rtems_mode previous_mode_set;
0062 rtems_status_code status;
0063 uint32_t iterations = 0;
0064
0065 status = rtems_task_mode(
0066 RTEMS_PREEMPT | RTEMS_TIMESLICE,
0067 RTEMS_PREEMPT_MASK | RTEMS_TIMESLICE_MASK,
0068 &previous_mode_set
0069 );
0070 directive_failed(status, "Unable to change task mode.");
0071
0072 while(1) {
0073 if (turn == me) {
0074 printf(
0075 "Task #%" PRIdrtems_task_argument "'s turn. Now setting turn to %"
0076 PRIdrtems_task_argument "\n",
0077 me,
0078 1 - me
0079 );
0080
0081 if ( ++iterations == 10 ) {
0082 TEST_END();
0083 exit( 0 );
0084 }
0085
0086 turn = 1 - me;
0087 }
0088 }
0089 }
0090
0091 rtems_task Init(rtems_task_argument ignored)
0092 {
0093 static rtems_status_code status;
0094
0095 TEST_BEGIN();
0096
0097
0098 status = rtems_task_create(
0099 TASK_A_NAME,
0100 TASK_A_PRIORITY,
0101 TASK_A_STACKSIZE,
0102 TASK_A_INITMODE,
0103 TASK_A_MODEATTR,
0104 &TaskA_id
0105 );
0106 directive_failed(status,"rtems_task_create");
0107
0108
0109 status = rtems_task_start(TaskA_id, TaskAB_entry, 0);
0110 directive_failed(status,"rtems_task_start");
0111
0112
0113 status = rtems_task_create(
0114 TASK_B_NAME,
0115 TASK_B_PRIORITY,
0116 TASK_B_STACKSIZE,
0117 TASK_B_INITMODE,
0118 TASK_B_MODEATTR,
0119 &TaskB_id
0120 );
0121 directive_failed( status, "rtems_task_create" );
0122
0123
0124 status = rtems_task_start(TaskB_id, TaskAB_entry, 1);
0125 directive_failed( status, "rtems_task_start" );
0126
0127
0128 status = rtems_task_suspend(RTEMS_SELF);
0129 directive_failed( status, "rtems_task_suspend" );
0130
0131
0132 printf("\nNOT SUPOSED TO RETURN HERE...\n");
0133 rtems_test_exit(1);
0134 }
0135
0136
0137
0138 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
0139 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0140
0141 #define CONFIGURE_MICROSECONDS_PER_TICK 1000
0142 #define CONFIGURE_TICKS_PER_TIMESLICE 10
0143 #define CONFIGURE_MAXIMUM_TASKS 3
0144
0145 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0146
0147 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0148
0149 #define CONFIGURE_INIT
0150
0151 #include <rtems/confdefs.h>