source: rtems/testsuites/sptests/sp65/init.c @ a5b04da

4.104.115
Last change on this file since a5b04da was a5b04da, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 14, 2009 at 8:05:44 PM

2009-09-14 Joel Sherrill <joel.sherrill@…>

  • Makefile.am, configure.ac, sp65/init.c: Add new test to exercise very simple priority ceiling case that was previously only tested via the POSIX API.
  • sp66/.cvsignore, sp66/Makefile.am, sp66/init.c, sp66/sp66.doc, sp66/sp66.scn: New files.
  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2009.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#include <tmacros.h>
13
14#if defined(INHERIT_CEILING)
15  #define TEST_NAME                "66"
16  #define TASK_PRIORITY            2
17#else
18  #define TEST_NAME                "65"
19  #define TASK_PRIORITY            1
20#endif
21
22rtems_task Task_1(
23  rtems_task_argument arg
24);
25
26rtems_task Init(
27  rtems_task_argument ignored
28)
29{
30  int                  status, ceiling, old_ceiling;
31  rtems_id             Mutex_id, Task_id;
32 
33  puts( "\n\n*** TEST " TEST_NAME " ***" );
34
35  /*
36   *  Create binary semaphore (a.k.a. Mutex) with Priority Ceiling
37   *  attribute.
38   */
39   
40  puts( "Creating semaphore" );
41  status = rtems_semaphore_create(
42    rtems_build_name( 's','e','m','1' ),
43    1,
44    RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_PRIORITY_CEILING,
45    1,
46    &Mutex_id
47  );
48  directive_failed( status, "rtems_semaphore_create" );
49
50  puts( "Calling rtems_semaphore_obtain" );
51  status = rtems_semaphore_obtain( Mutex_id, RTEMS_DEFAULT_OPTIONS, 0 );
52  directive_failed( status, "rtems_semaphore_obtain" );
53 
54  puts( "Calling rtems_task_create" );
55  status = rtems_task_create( rtems_build_name( 'T', 'A', 'S', '1' ), 
56    TASK_PRIORITY,
57    RTEMS_MINIMUM_STACK_SIZE,
58    RTEMS_DEFAULT_MODES,
59    RTEMS_DEFAULT_ATTRIBUTES,
60    &Task_id
61  );
62  directive_failed( status, "rtems_task_create" );
63 
64  puts( "Calling rtems_task_start" );
65  status = rtems_task_start( Task_id, Task_1, (rtems_task_argument)&Mutex_id );
66  directive_failed( status, "rtems_task_start" );
67 
68  sleep(1);
69 
70  puts( "Calling semaphore release" );
71  status = rtems_semaphore_release( Mutex_id );
72  directive_failed( status, "rtems_semaphore_release" );
73 
74
75  puts( "*** END OF TEST 65 ***" );
76
77  rtems_test_exit(0);
78}
79
80rtems_task Task_1(
81  rtems_task_argument arg
82)
83{
84  int status_in_task;
85  rtems_id *Mutex_id = (rtems_id *)arg;
86
87  puts( "Init Task_1: Obtaining semaphore" );
88  status_in_task = rtems_semaphore_obtain( *Mutex_id, RTEMS_DEFAULT_OPTIONS, 0 );
89  directive_failed( status_in_task, "Task_1 rtems_semaphore_obtain" );
90  return;
91}
92
93/* configuration information */
94
95#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
96#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
97
98#define CONFIGURE_MAXIMUM_TASKS         2
99#define CONFIGURE_MAXIMUM_SEMAPHORES    1
100#define CONFIGURE_INIT_TASK_PRIORITY    TASK_PRIORITY
101#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
102
103#define CONFIGURE_INIT
104#include <rtems/confdefs.h>
105
106/* global variables */
Note: See TracBrowser for help on using the repository browser.