source: rtems/testsuites/sptests/sp65/init.c @ 3c8eda7

4.115
Last change on this file since 3c8eda7 was 3c8eda7, checked in by Joel Sherrill <joel.sherrill@…>, on 05/12/12 at 16:01:26

sptests - Eliminate missing prototype warnings

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2012.
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
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <tmacros.h>
15#include <unistd.h>
16
17/* forward declarations to avoid warnings */
18rtems_task Init(rtems_task_argument argument);
19rtems_task Task_1(rtems_task_argument arg);
20
21#if defined(INHERIT_CEILING)
22  #define TEST_NAME                "66"
23  #define TASK_PRIORITY            2
24#else
25  #define TEST_NAME                "65"
26  #define TASK_PRIORITY            1
27#endif
28
29rtems_task Init(
30  rtems_task_argument ignored
31)
32{
33  int                  status;
34  rtems_id             Mutex_id, Task_id;
35
36  puts( "\n\n*** TEST " TEST_NAME " ***" );
37
38  /*
39   *  Create binary semaphore (a.k.a. Mutex) with Priority Ceiling
40   *  attribute.
41   */
42
43  puts( "Creating semaphore" );
44  status = rtems_semaphore_create(
45    rtems_build_name( 's','e','m','1' ),
46    1,
47    RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_PRIORITY_CEILING,
48    1,
49    &Mutex_id
50  );
51  directive_failed( status, "rtems_semaphore_create" );
52
53  puts( "Calling rtems_semaphore_obtain" );
54  status = rtems_semaphore_obtain( Mutex_id, RTEMS_DEFAULT_OPTIONS, 0 );
55  directive_failed( status, "rtems_semaphore_obtain" );
56
57  puts( "Calling rtems_task_create" );
58  status = rtems_task_create( rtems_build_name( 'T', 'A', 'S', '1' ),
59    TASK_PRIORITY,
60    RTEMS_MINIMUM_STACK_SIZE,
61    RTEMS_DEFAULT_MODES,
62    RTEMS_DEFAULT_ATTRIBUTES,
63    &Task_id
64  );
65  directive_failed( status, "rtems_task_create" );
66
67  puts( "Calling rtems_task_start" );
68  status = rtems_task_start( Task_id, Task_1, (rtems_task_argument)&Mutex_id );
69  directive_failed( status, "rtems_task_start" );
70
71  sleep(1);
72
73  puts( "Calling semaphore release" );
74  status = rtems_semaphore_release( Mutex_id );
75  directive_failed( status, "rtems_semaphore_release" );
76
77  puts( "*** END OF TEST 65 ***" );
78
79  rtems_test_exit(0);
80}
81
82rtems_task Task_1(
83  rtems_task_argument arg
84)
85{
86  int status_in_task;
87  rtems_id *Mutex_id = (rtems_id *)arg;
88
89  puts( "Init Task_1: Obtaining semaphore" );
90  status_in_task = rtems_semaphore_obtain(
91    *Mutex_id,
92    RTEMS_DEFAULT_OPTIONS,
93    0
94  );
95  directive_failed( status_in_task, "Task_1 rtems_semaphore_obtain" );
96  return;
97}
98
99/* configuration information */
100
101#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
102#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
103
104#define CONFIGURE_MAXIMUM_TASKS         2
105#define CONFIGURE_MAXIMUM_SEMAPHORES    1
106#define CONFIGURE_INIT_TASK_PRIORITY    TASK_PRIORITY
107#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
108
109#define CONFIGURE_INIT
110#include <rtems/confdefs.h>
111
112/* global variables */
Note: See TracBrowser for help on using the repository browser.