File indexing completed on 2025-05-11 08:24:43
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032
0033 #include <rtems.h>
0034
0035 #include "tmacros.h"
0036
0037 const char rtems_test_name[] = "SMPSCHEDSEM 01";
0038
0039 #define NUM_CPUS 1
0040 #define TASK_COUNT 2
0041 #define TASK_PRIORITY 8
0042 #define SEM_PRIORITY 5
0043
0044
0045
0046
0047
0048
0049 static void test(void)
0050 {
0051 rtems_status_code sc;
0052 rtems_task_priority priority;
0053 rtems_id task_sem;
0054
0055 sc = rtems_semaphore_create(
0056 rtems_build_name('S', 'E', 'M', '0'),
0057 1,
0058 RTEMS_BINARY_SEMAPHORE |
0059 RTEMS_PRIORITY |
0060 RTEMS_PRIORITY_CEILING,
0061 5,
0062 &task_sem
0063 );
0064 rtems_test_assert(sc == RTEMS_SUCCESSFUL);
0065
0066 rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &priority);
0067 printf("Init: priority %d expected %d\n",(int)priority, TASK_PRIORITY );
0068 rtems_test_assert( priority == TASK_PRIORITY );
0069
0070 printf("Init: Obtain Semaphore\n");
0071 sc = rtems_semaphore_obtain (task_sem, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
0072 rtems_test_assert(sc == RTEMS_SUCCESSFUL);
0073 rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &priority);
0074 printf("Init: priority %d expected %d\n",(int)priority, SEM_PRIORITY );
0075 rtems_test_assert( priority == SEM_PRIORITY );
0076
0077 printf("Init: Release Semaphore\n");
0078 rtems_semaphore_release(task_sem);
0079 rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &priority);
0080 printf("Init: priority %d expected %d\n",(int)priority, TASK_PRIORITY );
0081 rtems_test_assert( priority == TASK_PRIORITY );
0082 }
0083
0084 static void Init(rtems_task_argument arg)
0085 {
0086 TEST_BEGIN();
0087
0088 test();
0089
0090 TEST_END();
0091 rtems_test_exit(0);
0092 }
0093
0094 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
0095 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0096
0097 #define CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP
0098
0099 #define CONFIGURE_MAXIMUM_PROCESSORS NUM_CPUS
0100
0101 #define CONFIGURE_MAXIMUM_TASKS TASK_COUNT
0102 #define CONFIGURE_MAXIMUM_SEMAPHORES 1
0103
0104 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0105
0106 #define CONFIGURE_INIT_TASK_PRIORITY TASK_PRIORITY
0107 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0108
0109 #define CONFIGURE_INIT
0110
0111 #include <rtems/confdefs.h>