source: rtems/cpukit/score/include/rtems/score/threadq.h @ f5d6c8b

4.11
Last change on this file since f5d6c8b was f5d6c8b, checked in by Sebastian Huber <sebastian.huber@…>, on Apr 27, 2015 at 2:25:52 PM

score: Delete Thread_queue_Control::timeout_status

Use a parameter for _Thread_queue_Enqueue() instead to reduce memory
usage.

  • Property mode set to 100644
File size: 5.2 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Constants and Structures Needed to Declare a Thread Queue
5 *
6 *  This include file contains all the constants and structures
7 *  needed to declare a thread queue.
8 */
9
10/*
11 *  COPYRIGHT (c) 1989-2014.
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_THREADQ_H
20#define _RTEMS_SCORE_THREADQ_H
21
22#include <rtems/score/chain.h>
23#include <rtems/score/isrlock.h>
24#include <rtems/score/percpu.h>
25#include <rtems/score/priority.h>
26#include <rtems/score/rbtree.h>
27#include <rtems/score/states.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33/**
34 *  @defgroup ScoreThreadQueue Thread Queue Handler
35 *
36 *  @ingroup Score
37 *
38 *  This handler provides the capability to have threads block in
39 *  ordered sets. The sets may be ordered using the FIFO or priority
40 *  discipline.
41 */
42/**@{*/
43
44typedef struct Thread_queue_Control Thread_queue_Control;
45
46/**
47 * @brief Thread queue priority change operation.
48 *
49 * @param[in] the_thread The thread.
50 * @param[in] new_priority The new priority value.
51 * @param[in] the_thread_queue The thread queue.
52 *
53 * @see Thread_queue_Operations.
54 */
55typedef void ( *Thread_queue_Priority_change_operation )(
56  Thread_Control       *the_thread,
57  Priority_Control      new_priority,
58  Thread_queue_Control *the_thread_queue
59);
60
61/**
62 * @brief Thread queue initialize operation.
63 *
64 * @param[in] the_thread_queue The thread queue.
65 *
66 * @see _Thread_Wait_set_operations().
67 */
68typedef void ( *Thread_queue_Initialize_operation )(
69  Thread_queue_Control *the_thread_queue
70);
71
72/**
73 * @brief Thread queue enqueue operation.
74 *
75 * @param[in] the_thread_queue The thread queue.
76 * @param[in] the_thread The thread to enqueue on the queue.
77 *
78 * @see _Thread_Wait_set_operations().
79 */
80typedef void ( *Thread_queue_Enqueue_operation )(
81  Thread_queue_Control *the_thread_queue,
82  Thread_Control       *the_thread
83);
84
85/**
86 * @brief Thread queue extract operation.
87 *
88 * @param[in] the_thread_queue The thread queue.
89 * @param[in] the_thread The thread to extract from the thread queue.
90 *
91 * @see _Thread_Wait_set_operations().
92 */
93typedef void ( *Thread_queue_Extract_operation )(
94  Thread_queue_Control *the_thread_queue,
95  Thread_Control       *the_thread
96);
97
98/**
99 * @brief Thread queue first operation.
100 *
101 * @param[in] the_thread_queue The thread queue.
102 *
103 * @retval NULL No thread is present on the thread queue.
104 * @retval first The first thread of the thread queue according to the insert
105 * order.  This thread remains on the thread queue.
106 *
107 * @see _Thread_Wait_set_operations().
108 */
109typedef Thread_Control *( *Thread_queue_First_operation )(
110  Thread_queue_Control *the_thread_queue
111);
112
113/**
114 * @brief Thread queue operations.
115 *
116 * @see _Thread_wait_Set_operations().
117 */
118typedef struct {
119  /**
120   * @brief Thread queue priority change operation.
121   *
122   * Called by _Thread_Change_priority() to notify a thread about a priority
123   * change.  In case this thread waits currently for a resource the handler
124   * may adjust its data structures according to the new priority value.  This
125   * handler must not be NULL, instead the default handler
126   * _Thread_Do_nothing_priority_change() should be used in case nothing needs
127   * to be done during a priority change.
128   */
129  Thread_queue_Priority_change_operation priority_change;
130
131  /**
132   * @brief Thread queue initialize operation.
133   *
134   * Called by object initialization routines.
135   */
136  Thread_queue_Initialize_operation initialize;
137
138  /**
139   * @brief Thread queue enqueue operation.
140   *
141   * Called by object routines to enqueue the thread.
142   */
143  Thread_queue_Enqueue_operation enqueue;
144
145  /**
146   * @brief Thread queue extract operation.
147   *
148   * Called by object routines to extract a thread from a thread queue.
149   */
150  Thread_queue_Extract_operation extract;
151
152  /**
153   * @brief Thread queue first operation.
154   */
155  Thread_queue_First_operation first;
156} Thread_queue_Operations;
157
158/**
159 *  The following enumerated type details all of the disciplines
160 *  supported by the Thread Queue Handler.
161 */
162typedef enum {
163  THREAD_QUEUE_DISCIPLINE_FIFO,     /* FIFO queue discipline */
164  THREAD_QUEUE_DISCIPLINE_PRIORITY  /* PRIORITY queue discipline */
165}   Thread_queue_Disciplines;
166
167/**
168 *  This is the structure used to manage sets of tasks which are blocked
169 *  waiting to acquire a resource.
170 */
171struct Thread_queue_Control {
172  /** This union contains the data structures used to manage the blocked
173   *  set of tasks which varies based upon the discipline.
174   */
175  union {
176    /** This is the FIFO discipline list. */
177    Chain_Control Fifo;
178    /** This is the set of threads for priority discipline waiting. */
179    RBTree_Control Priority;
180  } Queues;
181
182  /**
183   * @brief The operations for this thread queue.
184   */
185  const Thread_queue_Operations *operations;
186
187  /**
188   * @brief Lock to protect this thread queue.
189   *
190   * It may be used to protect additional state of the object embedding this
191   * thread queue.
192   *
193   * @see _Thread_queue_Acquire(), _Thread_queue_Acquire_critical() and
194   * _Thread_queue_Release().
195   */
196  ISR_LOCK_MEMBER( Lock )
197};
198
199/**@}*/
200
201#ifdef __cplusplus
202}
203#endif
204
205#endif
206/* end of include file */
Note: See TracBrowser for help on using the repository browser.