source: rtems/cpukit/posix/src/prwlocktimedwrlock.c

Last change on this file was c3105894, checked in by Sebastian Huber <sebastian.huber@…>, on Oct 19, 2017 at 11:47:57 AM

score: Move thread queue timeout handling

Update #3117.
Update #3182.

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/**
2 * @file
3 *
4 * @brief Function applies a Write lock to RWLock referenced by rwlock
5 * @ingroup POSIXAPI
6 */
7
8/*
9 *  POSIX RWLock Manager -- Attempt to Obtain a Write Lock on a RWLock Instance
10 *
11 *  COPYRIGHT (c) 1989-2008.
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 <rtems/posix/rwlockimpl.h>
24#include <rtems/posix/posixapi.h>
25
26int pthread_rwlock_timedwrlock(
27  pthread_rwlock_t      *rwlock,
28  const struct timespec *abstime
29)
30{
31  POSIX_RWLock_Control *the_rwlock;
32  Thread_queue_Context  queue_context;
33  Status_Control        status;
34
35  the_rwlock = _POSIX_RWLock_Get( rwlock );
36  POSIX_RWLOCK_VALIDATE_OBJECT( the_rwlock );
37
38  _Thread_queue_Context_initialize( &queue_context );
39  _Thread_queue_Context_set_enqueue_timeout_realtime_timespec(
40    &queue_context,
41    abstime
42  );
43  status = _CORE_RWLock_Seize_for_writing(
44    &the_rwlock->RWLock,
45    true,
46    &queue_context
47  );
48  return _POSIX_Get_error( status );
49}
Note: See TracBrowser for help on using the repository browser.