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.org/license/LICENSE. |
---|
8 | */ |
---|
9 | |
---|
10 | #ifdef HAVE_CONFIG_H |
---|
11 | #include "config.h" |
---|
12 | #endif |
---|
13 | |
---|
14 | #include <rtems.h> |
---|
15 | |
---|
16 | /* forward declarations to avoid warnings */ |
---|
17 | rtems_device_driver consume_semaphores_initialize( |
---|
18 | rtems_device_major_number major RTEMS_UNUSED, |
---|
19 | rtems_device_minor_number minor RTEMS_UNUSED, |
---|
20 | void *pargp RTEMS_UNUSED |
---|
21 | ); |
---|
22 | |
---|
23 | #define MAXIMUM 20 |
---|
24 | rtems_id Semaphores[MAXIMUM]; |
---|
25 | |
---|
26 | rtems_device_driver consume_semaphores_initialize( |
---|
27 | rtems_device_major_number major RTEMS_UNUSED, |
---|
28 | rtems_device_minor_number minor RTEMS_UNUSED, |
---|
29 | void *pargp RTEMS_UNUSED |
---|
30 | ) |
---|
31 | { |
---|
32 | int sems; |
---|
33 | rtems_status_code status; |
---|
34 | |
---|
35 | for ( sems=0 ; sems<MAXIMUM ; sems++ ) { |
---|
36 | status = rtems_semaphore_create( |
---|
37 | rtems_build_name( 'S', 'M', '1', ' ' ), |
---|
38 | 1, |
---|
39 | RTEMS_DEFAULT_MODES, |
---|
40 | RTEMS_NO_PRIORITY, |
---|
41 | &Semaphores[sems] |
---|
42 | ); |
---|
43 | if ( status == RTEMS_TOO_MANY ) |
---|
44 | break; |
---|
45 | } |
---|
46 | |
---|
47 | #if 0 |
---|
48 | printk( "Consumed %d\n", sems ); |
---|
49 | printk( "Freeing %d\n", SEMAPHORES_REMAINING ); |
---|
50 | #endif |
---|
51 | |
---|
52 | #if defined(SEMAPHORES_REMAINING) |
---|
53 | { |
---|
54 | int i; |
---|
55 | |
---|
56 | for ( i=0 ; i<SEMAPHORES_REMAINING ; i++ ) { |
---|
57 | (void) rtems_semaphore_delete( Semaphores[i] ); |
---|
58 | } |
---|
59 | } |
---|
60 | #endif |
---|
61 | return RTEMS_SUCCESSFUL; |
---|
62 | } |
---|
63 | |
---|