4.115
Last change
on this file since 2d2352b was
2d2352b,
checked in by Sebastian Huber <sebastian.huber@…>, on 06/05/13 at 09:48:57
|
score: Add and use _Objects_Put()
Add and use _Objects_Put_without_thread_dispatch(). These two functions
pair with the _Objects_Get() function. This helps to introduce object
specific SMP locks to avoid lock contention.
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Obtain a Read Lock on a RWLock Instance |
---|
5 | * @ingroup POSIXAPI |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2007. |
---|
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.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <pthread.h> |
---|
22 | #include <errno.h> |
---|
23 | |
---|
24 | #include <rtems/system.h> |
---|
25 | #include <rtems/posix/rwlock.h> |
---|
26 | |
---|
27 | /** |
---|
28 | * This directive attempts to obtain a read only lock on an rwlock instance. |
---|
29 | * |
---|
30 | * @param[in] rwlock is the pointer to rwlock id |
---|
31 | * |
---|
32 | * @retval 0 if successful |
---|
33 | * @retval error_code if unsuccessful |
---|
34 | */ |
---|
35 | |
---|
36 | int pthread_rwlock_rdlock( |
---|
37 | pthread_rwlock_t *rwlock |
---|
38 | ) |
---|
39 | { |
---|
40 | POSIX_RWLock_Control *the_rwlock; |
---|
41 | Objects_Locations location; |
---|
42 | |
---|
43 | if ( !rwlock ) |
---|
44 | return EINVAL; |
---|
45 | |
---|
46 | the_rwlock = _POSIX_RWLock_Get( rwlock, &location ); |
---|
47 | switch ( location ) { |
---|
48 | |
---|
49 | case OBJECTS_LOCAL: |
---|
50 | |
---|
51 | _CORE_RWLock_Obtain_for_reading( |
---|
52 | &the_rwlock->RWLock, |
---|
53 | *rwlock, |
---|
54 | true, /* we are willing to wait forever */ |
---|
55 | 0, |
---|
56 | NULL |
---|
57 | ); |
---|
58 | |
---|
59 | _Objects_Put( &the_rwlock->Object ); |
---|
60 | return _POSIX_RWLock_Translate_core_RWLock_return_code( |
---|
61 | (CORE_RWLock_Status) _Thread_Executing->Wait.return_code |
---|
62 | ); |
---|
63 | |
---|
64 | #if defined(RTEMS_MULTIPROCESSING) |
---|
65 | case OBJECTS_REMOTE: |
---|
66 | #endif |
---|
67 | case OBJECTS_ERROR: |
---|
68 | break; |
---|
69 | } |
---|
70 | |
---|
71 | return EINVAL; |
---|
72 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.