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
0024
0025
0026
0027
0028
0029 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032
0033 #include <tmacros.h>
0034 #include <unistd.h>
0035
0036
0037 rtems_task Init(rtems_task_argument argument);
0038 rtems_task Task_1(rtems_task_argument arg);
0039
0040 #if defined(INHERIT_CEILING)
0041 #define TEST_NAME "66"
0042 #define TASK_PRIORITY 2
0043 #else
0044 #define TEST_NAME "65"
0045 #define TASK_PRIORITY 1
0046 #endif
0047
0048 const char rtems_test_name[] = "SP " TEST_NAME;
0049
0050 static void assert_priority(rtems_task_priority expected)
0051 {
0052 rtems_status_code sc;
0053 rtems_task_priority prio;
0054
0055 sc = rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &prio);
0056 rtems_test_assert(sc == RTEMS_SUCCESSFUL);
0057
0058 rtems_test_assert(prio == expected);
0059 }
0060
0061 rtems_task Init(
0062 rtems_task_argument ignored
0063 )
0064 {
0065 int status;
0066 rtems_id Mutex_id, Task_id;
0067
0068 TEST_BEGIN();
0069
0070
0071
0072
0073
0074
0075 status = rtems_semaphore_create(
0076 rtems_build_name( 's','e','m','1' ),
0077 0,
0078 RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_PRIORITY_CEILING,
0079 1,
0080 &Mutex_id
0081 );
0082 rtems_test_assert(status == RTEMS_SUCCESSFUL);
0083
0084 assert_priority(1);
0085
0086 status = rtems_semaphore_release(Mutex_id);
0087 rtems_test_assert(status == RTEMS_SUCCESSFUL);
0088
0089 assert_priority(TASK_PRIORITY);
0090
0091 status = rtems_semaphore_delete(Mutex_id);
0092 rtems_test_assert(status == RTEMS_SUCCESSFUL);
0093
0094
0095
0096
0097
0098
0099 puts( "Creating semaphore" );
0100 status = rtems_semaphore_create(
0101 rtems_build_name( 's','e','m','1' ),
0102 1,
0103 RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_PRIORITY_CEILING,
0104 1,
0105 &Mutex_id
0106 );
0107 directive_failed( status, "rtems_semaphore_create" );
0108
0109 puts( "Calling rtems_semaphore_obtain" );
0110 status = rtems_semaphore_obtain( Mutex_id, RTEMS_DEFAULT_OPTIONS, 0 );
0111 directive_failed( status, "rtems_semaphore_obtain" );
0112
0113 puts( "Calling rtems_task_create" );
0114 status = rtems_task_create( rtems_build_name( 'T', 'A', 'S', '1' ),
0115 TASK_PRIORITY,
0116 RTEMS_MINIMUM_STACK_SIZE,
0117 RTEMS_DEFAULT_MODES,
0118 RTEMS_DEFAULT_ATTRIBUTES,
0119 &Task_id
0120 );
0121 directive_failed( status, "rtems_task_create" );
0122
0123 puts( "Calling rtems_task_start" );
0124 status = rtems_task_start( Task_id, Task_1, (rtems_task_argument)&Mutex_id );
0125 directive_failed( status, "rtems_task_start" );
0126
0127 sleep(1);
0128
0129 puts( "Calling semaphore release" );
0130 status = rtems_semaphore_release( Mutex_id );
0131 directive_failed( status, "rtems_semaphore_release" );
0132
0133 TEST_END();
0134
0135 rtems_test_exit(0);
0136 }
0137
0138 rtems_task Task_1(
0139 rtems_task_argument arg
0140 )
0141 {
0142 int status_in_task;
0143 rtems_id *Mutex_id = (rtems_id *)arg;
0144
0145 puts( "Init Task_1: Obtaining semaphore" );
0146 status_in_task = rtems_semaphore_obtain(
0147 *Mutex_id,
0148 RTEMS_DEFAULT_OPTIONS,
0149 0
0150 );
0151 directive_failed( status_in_task, "Task_1 rtems_semaphore_obtain" );
0152 return;
0153 }
0154
0155
0156
0157 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0158 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
0159
0160 #define CONFIGURE_MAXIMUM_TASKS 2
0161 #define CONFIGURE_MAXIMUM_SEMAPHORES 1
0162 #define CONFIGURE_INIT_TASK_PRIORITY TASK_PRIORITY
0163 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0164
0165 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0166
0167 #define CONFIGURE_INIT
0168 #include <rtems/confdefs.h>
0169
0170