5
Last change
on this file since 4025a60f was
4025a60f,
checked in by Sebastian Huber <sebastian.huber@…>, on 04/19/16 at 15:02:54
|
score: Avoid Giant lock for CORE mtx/sem
Avoid Giant lock for CORE mutex and semaphore flush and delete
operations.
Update #2555.
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Close a Named Semaphore |
---|
5 | * @ingroup POSIX_SEMAPHORE |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2014. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <semaphore.h> |
---|
22 | |
---|
23 | #include <rtems/posix/semaphoreimpl.h> |
---|
24 | |
---|
25 | int sem_close( |
---|
26 | sem_t *sem |
---|
27 | ) |
---|
28 | { |
---|
29 | POSIX_Semaphore_Control *the_semaphore; |
---|
30 | Objects_Locations location; |
---|
31 | ISR_lock_Context lock_context; |
---|
32 | |
---|
33 | _Objects_Allocator_lock(); |
---|
34 | the_semaphore = _POSIX_Semaphore_Get_interrupt_disable( |
---|
35 | sem, |
---|
36 | &location, |
---|
37 | &lock_context |
---|
38 | ); |
---|
39 | switch ( location ) { |
---|
40 | |
---|
41 | case OBJECTS_LOCAL: |
---|
42 | _CORE_semaphore_Acquire_critical( |
---|
43 | &the_semaphore->Semaphore, |
---|
44 | &lock_context |
---|
45 | ); |
---|
46 | the_semaphore->open_count -= 1; |
---|
47 | _POSIX_Semaphore_Delete( the_semaphore, &lock_context ); |
---|
48 | _Objects_Allocator_unlock(); |
---|
49 | return 0; |
---|
50 | |
---|
51 | #if defined(RTEMS_MULTIPROCESSING) |
---|
52 | case OBJECTS_REMOTE: |
---|
53 | #endif |
---|
54 | case OBJECTS_ERROR: |
---|
55 | break; |
---|
56 | } |
---|
57 | |
---|
58 | _Objects_Allocator_unlock(); |
---|
59 | |
---|
60 | rtems_set_errno_and_return_minus_one( EINVAL ); |
---|
61 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.