source: rtems/cpukit/posix/src/prwlockwrlock.c @ 8866e62

5
Last change on this file since 8866e62 was 8866e62, checked in by Sebastian Huber <sebastian.huber@…>, on 05/23/16 at 04:26:58

score: Move thread queue object support

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/**
2 * @file
3 *
4 * @brief Obtain a Write Lock on a RWlock Instance
5 * @ingroup POSIXAPI
6 */
7
8/*
9 *  POSIX RWLock Manager -- Obtain a Write Lock on a RWLock Instance
10 *
11 *  COPYRIGHT (c) 1989-2007.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#if HAVE_CONFIG_H
20#include "config.h"
21#endif
22
23#include <pthread.h>
24#include <errno.h>
25
26#include <rtems/posix/rwlockimpl.h>
27
28THREAD_QUEUE_OBJECT_ASSERT( POSIX_RWLock_Control, RWLock.Wait_queue );
29
30int pthread_rwlock_wrlock(
31  pthread_rwlock_t  *rwlock
32)
33{
34  POSIX_RWLock_Control *the_rwlock;
35  ISR_lock_Context      lock_context;
36  Thread_Control       *executing;
37
38  the_rwlock = _POSIX_RWLock_Get( rwlock, &lock_context );
39
40  if ( the_rwlock == NULL ) {
41    return EINVAL;
42  }
43
44  executing = _Thread_Executing;
45  _CORE_RWLock_Seize_for_writing(
46    &the_rwlock->RWLock,
47    executing,
48    true,          /* do not timeout -- wait forever */
49    0,
50    &lock_context
51  );
52  return _POSIX_RWLock_Translate_core_RWLock_return_code(
53    (CORE_RWLock_Status) executing->Wait.return_code
54  );
55}
Note: See TracBrowser for help on using the repository browser.