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

4.104.115
Last change on this file since a5b04da was a5b04da, checked in by Joel Sherrill <joel.sherrill@…>, on 09/14/09 at 20:05:44

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.4 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
14rtems_task Task_1(
15  rtems_task_argument arg
16);
17
18rtems_task Init(
19  rtems_task_argument ignored
20)
21{
22  int                  status, ceiling, old_ceiling;
23  rtems_id             Mutex_id, Task_id;
24 
25  puts( "\n\n*** TEST 66 ***" );
26
27  /*
28   *  Create binary semaphore (a.k.a. Mutex) with Priority Ceiling
29   *  attribute.
30   */
31   
32  puts( "Creating semaphore" );
33  status = rtems_semaphore_create(
34    rtems_build_name( 's','e','m','1' ),
35    1,
36    RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_PRIORITY_CEILING,
37    1,
38    &Mutex_id
39  );
40  directive_failed( status, "rtems_semaphore_create" );
41
42  puts( "Calling rtems_semaphore_obtain" );
43  status = rtems_semaphore_obtain( Mutex_id, RTEMS_DEFAULT_OPTIONS, 0 );
44  directive_failed( status, "rtems_semaphore_obtain" );
45 
46  puts( "Calling rtems_task_create" );
47  status = rtems_task_create( rtems_build_name( 'T', 'A', 'S', '1' ),
48    2,
49    RTEMS_MINIMUM_STACK_SIZE,
50    RTEMS_DEFAULT_MODES,
51    RTEMS_DEFAULT_ATTRIBUTES,
52    &Task_id
53  );
54  directive_failed( status, "rtems_task_create" );
55 
56  puts( "Calling rtems_task_start" );
57  status = rtems_task_start( Task_id, Task_1, (rtems_task_argument)&Mutex_id );
58  directive_failed( status, "rtems_task_start" );
59 
60  sleep(1);
61 
62  puts( "Calling semaphore release" );
63  status = rtems_semaphore_release( Mutex_id );
64  directive_failed( status, "rtems_semaphore_release" );
65 
66  puts( "*** END OF TEST 66 ***" );
67
68  rtems_test_exit(0);
69}
70
71rtems_task Task_1(
72  rtems_task_argument arg
73)
74{
75  int status_in_task;
76  rtems_id *Mutex_id = (rtems_id *)arg;
77
78  puts( "Init Task_1: Obtaining semaphore" );
79  status_in_task = rtems_semaphore_obtain( *Mutex_id, RTEMS_DEFAULT_OPTIONS, 0 );
80  directive_failed( status_in_task, "Task_1 rtems_semaphore_obtain" );
81  return;
82}
83
84/* configuration information */
85
86#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
87#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
88
89#define CONFIGURE_MAXIMUM_TASKS         2
90#define CONFIGURE_MAXIMUM_SEMAPHORES    1
91#define CONFIGURE_INIT_TASK_PRIORITY    2
92#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
93
94#define CONFIGURE_INIT
95#include <rtems/confdefs.h>
96
97/* global variables */
Note: See TracBrowser for help on using the repository browser.