source: rtems/cpukit/score/include/rtems/score/corerwlockimpl.h @ 114e408

5
Last change on this file since 114e408 was 114e408, checked in by Sebastian Huber <sebastian.huber@…>, on 08/22/16 at 11:17:05

score: Simplify thread queue acquire/release

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/**
2 * @file
3 *
4 * @brief Inlined Routines Associated with the SuperCore RWLock
5 *
6 * This include file contains all of the inlined routines associated
7 * with the SuperCore RWLock.
8 */
9
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#ifndef _RTEMS_SCORE_CORERWLOCKIMPL_H
20#define _RTEMS_SCORE_CORERWLOCKIMPL_H
21
22#include <rtems/score/corerwlock.h>
23#include <rtems/score/thread.h>
24#include <rtems/score/threadqimpl.h>
25#include <rtems/score/status.h>
26#include <rtems/score/watchdog.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32/**
33 * @addtogroup ScoreRWLock
34 */
35/**@{**/
36
37#define CORE_RWLOCK_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
38
39/**
40 *  This is used to denote that a thread is blocking waiting for
41 *  read-only access to the RWLock.
42 */
43#define CORE_RWLOCK_THREAD_WAITING_FOR_READ  0
44
45/**
46 *  This is used to denote that a thread is blocking waiting for
47 *  write-exclusive access to the RWLock.
48 */
49#define CORE_RWLOCK_THREAD_WAITING_FOR_WRITE 1
50
51/**
52 *  @brief Initialize a RWlock.
53 *
54 *  This routine initializes the RWLock based on the parameters passed.
55 *
56 *  @param[in] the_rwlock is the RWLock to initialize
57 */
58void _CORE_RWLock_Initialize(
59  CORE_RWLock_Control *the_rwlock
60);
61
62RTEMS_INLINE_ROUTINE void _CORE_RWLock_Destroy(
63  CORE_RWLock_Control *the_rwlock
64)
65{
66  _Thread_queue_Destroy( &the_rwlock->Wait_queue );
67}
68
69RTEMS_INLINE_ROUTINE void _CORE_RWLock_Acquire_critical(
70  CORE_RWLock_Control  *the_rwlock,
71  Thread_queue_Context *queue_context
72)
73{
74  _Thread_queue_Acquire_critical( &the_rwlock->Wait_queue, queue_context );
75}
76
77RTEMS_INLINE_ROUTINE void _CORE_RWLock_Release(
78  CORE_RWLock_Control  *the_rwlock,
79  Thread_queue_Context *queue_context
80)
81{
82  _Thread_queue_Release( &the_rwlock->Wait_queue, queue_context );
83}
84
85/**
86 *  @brief Obtain RWLock for reading.
87 *
88 *  This routine attempts to obtain the RWLock for read access.
89 *
90 *  @param[in] the_rwlock is the RWLock to wait for
91 *  @param[in] wait is true if the calling thread is willing to wait
92 */
93
94Status_Control _CORE_RWLock_Seize_for_reading(
95  CORE_RWLock_Control  *the_rwlock,
96  Thread_Control       *executing,
97  bool                  wait,
98  Thread_queue_Context *queue_context
99);
100
101/**
102 *  @brief Obtain RWLock for writing.
103 *
104 *  This routine attempts to obtain the RWLock for write exclusive access.
105 *
106 *  @param[in] the_rwlock is the RWLock to wait for
107 *  @param[in] wait is true if the calling thread is willing to wait
108 */
109Status_Control _CORE_RWLock_Seize_for_writing(
110  CORE_RWLock_Control  *the_rwlock,
111  Thread_Control       *executing,
112  bool                  wait,
113  Thread_queue_Context *queue_context
114);
115
116/**
117 *  @brief Release the RWLock.
118 *
119 *  This routine manually releases @a the_rwlock.  All of the threads waiting
120 *  for the RWLock will be readied.
121 *
122 *  @param[in] the_rwlock is the RWLock to surrender
123 *
124 *  @retval Status is returned to indicate successful or failure.
125 */
126Status_Control _CORE_RWLock_Surrender(
127  CORE_RWLock_Control  *the_rwlock,
128  Thread_queue_Context *queue_context
129);
130
131/** @} */
132
133#ifdef __cplusplus
134}
135#endif
136
137#endif
138/* end of include file */
Note: See TracBrowser for help on using the repository browser.