1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/*
* COPYRIGHT (c) 1989-2012.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <rtems.h>
/* forward declarations to avoid warnings */
rtems_device_driver consume_semaphores_initialize(
rtems_device_major_number major RTEMS_UNUSED,
rtems_device_minor_number minor RTEMS_UNUSED,
void *pargp RTEMS_UNUSED
);
#define MAXIMUM 20
rtems_id Semaphores[MAXIMUM];
rtems_device_driver consume_semaphores_initialize(
rtems_device_major_number major RTEMS_UNUSED,
rtems_device_minor_number minor RTEMS_UNUSED,
void *pargp RTEMS_UNUSED
)
{
int sems;
rtems_status_code status;
for ( sems=0 ; sems<MAXIMUM ; sems++ ) {
status = rtems_semaphore_create(
rtems_build_name( 'S', 'M', '1', ' ' ),
1,
RTEMS_DEFAULT_MODES,
RTEMS_NO_PRIORITY,
&Semaphores[sems]
);
if ( status == RTEMS_TOO_MANY )
break;
}
#if 0
printk( "Consumed %d\n", sems );
printk( "Freeing %d\n", SEMAPHORES_REMAINING );
#endif
#if defined(SEMAPHORES_REMAINING)
{
int i;
for ( i=0 ; i<SEMAPHORES_REMAINING ; i++ ) {
(void) rtems_semaphore_delete( Semaphores[i] );
}
}
#endif
return RTEMS_SUCCESSFUL;
}
|