| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 1 | /* -*- mode: C; c-basic-offset: 3; -*- */ | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 2 | /* | 
| bart | 86562bd | 2009-02-16 19:43:56 +0000 | [diff] [blame] | 3 | This file is part of drd, a thread error detector. | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 4 |  | 
| bart | 86562bd | 2009-02-16 19:43:56 +0000 | [diff] [blame] | 5 | Copyright (C) 2006-2009 Bart Van Assche <bart.vanassche@gmail.com>. | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 6 |  | 
|  | 7 | This program is free software; you can redistribute it and/or | 
|  | 8 | modify it under the terms of the GNU General Public License as | 
|  | 9 | published by the Free Software Foundation; either version 2 of the | 
|  | 10 | License, or (at your option) any later version. | 
|  | 11 |  | 
|  | 12 | This program is distributed in the hope that it will be useful, but | 
|  | 13 | WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
|  | 15 | General Public License for more details. | 
|  | 16 |  | 
|  | 17 | You should have received a copy of the GNU General Public License | 
|  | 18 | along with this program; if not, write to the Free Software | 
|  | 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | 
|  | 20 | 02111-1307, USA. | 
|  | 21 |  | 
|  | 22 | The GNU General Public License is contained in the file COPYING. | 
|  | 23 | */ | 
|  | 24 |  | 
|  | 25 |  | 
| bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 26 | #include "drd_clientobj.h" | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 27 | #include "drd_cond.h" | 
|  | 28 | #include "drd_error.h" | 
|  | 29 | #include "drd_mutex.h" | 
|  | 30 | #include "drd_suppression.h" | 
| bart | 46b5fce | 2008-06-28 13:01:30 +0000 | [diff] [blame] | 31 | #include "pub_tool_errormgr.h"    /* VG_(maybe_record_error)() */ | 
|  | 32 | #include "pub_tool_libcassert.h"  /* tl_assert()               */ | 
|  | 33 | #include "pub_tool_libcprint.h"   /* VG_(printf)()             */ | 
|  | 34 | #include "pub_tool_machine.h"     /* VG_(get_IP)()             */ | 
|  | 35 | #include "pub_tool_options.h"     /* VG_(clo_backtrace_size)   */ | 
|  | 36 | #include "pub_tool_threadstate.h" /* VG_(get_running_tid)()    */ | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 37 |  | 
|  | 38 |  | 
| bart | 46b5fce | 2008-06-28 13:01:30 +0000 | [diff] [blame] | 39 | /* Local functions. */ | 
| bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 40 |  | 
| bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 41 | static void DRD_(cond_cleanup)(struct cond_info* p); | 
| bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 42 |  | 
|  | 43 |  | 
| bart | 46b5fce | 2008-06-28 13:01:30 +0000 | [diff] [blame] | 44 | /* Local variables. */ | 
| bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 45 |  | 
| bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 46 | static Bool DRD_(s_report_signal_unlocked) = True; | 
|  | 47 | static Bool DRD_(s_trace_cond); | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 48 |  | 
|  | 49 |  | 
| bart | 46b5fce | 2008-06-28 13:01:30 +0000 | [diff] [blame] | 50 | /* Function definitions. */ | 
| bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 51 |  | 
| bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 52 | void DRD_(cond_set_report_signal_unlocked)(const Bool r) | 
| bart | 764dea2 | 2009-02-15 13:16:52 +0000 | [diff] [blame] | 53 | { | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 54 | DRD_(s_report_signal_unlocked) = r; | 
| bart | 764dea2 | 2009-02-15 13:16:52 +0000 | [diff] [blame] | 55 | } | 
|  | 56 |  | 
| bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 57 | void DRD_(cond_set_trace)(const Bool trace_cond) | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 58 | { | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 59 | DRD_(s_trace_cond) = trace_cond; | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 60 | } | 
|  | 61 |  | 
|  | 62 | static | 
| bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 63 | void DRD_(cond_initialize)(struct cond_info* const p, const Addr cond) | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 64 | { | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 65 | tl_assert(cond != 0); | 
|  | 66 | tl_assert(p->a1         == cond); | 
|  | 67 | tl_assert(p->type       == ClientCondvar); | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 68 |  | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 69 | p->cleanup       = (void(*)(DrdClientobj*))(DRD_(cond_cleanup)); | 
|  | 70 | p->delete_thread = 0; | 
|  | 71 | p->waiter_count  = 0; | 
|  | 72 | p->mutex         = 0; | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 73 | } | 
|  | 74 |  | 
| bart | 195e41f | 2009-02-15 11:34:57 +0000 | [diff] [blame] | 75 | /** | 
|  | 76 | * Free the memory that was allocated by cond_initialize(). Called by | 
|  | 77 | * DRD_(clientobj_remove)(). | 
| bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 78 | */ | 
| bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 79 | static void DRD_(cond_cleanup)(struct cond_info* p) | 
| bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 80 | { | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 81 | tl_assert(p); | 
|  | 82 | if (p->mutex) | 
|  | 83 | { | 
|  | 84 | struct mutex_info* q; | 
|  | 85 | q = &(DRD_(clientobj_get)(p->mutex, ClientMutex)->mutex); | 
|  | 86 | tl_assert(q); | 
|  | 87 | { | 
|  | 88 | CondDestrErrInfo cde = { p->a1, q->a1, q->owner }; | 
|  | 89 | VG_(maybe_record_error)(VG_(get_running_tid)(), | 
|  | 90 | CondDestrErr, | 
|  | 91 | VG_(get_IP)(VG_(get_running_tid)()), | 
|  | 92 | "Destroying condition variable that is being" | 
|  | 93 | " waited upon", | 
|  | 94 | &cde); | 
|  | 95 | } | 
|  | 96 | } | 
| bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 97 | } | 
|  | 98 |  | 
| bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 99 | static struct cond_info* DRD_(cond_get_or_allocate)(const Addr cond) | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 100 | { | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 101 | struct cond_info *p; | 
| bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 102 |  | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 103 | tl_assert(offsetof(DrdClientobj, cond) == 0); | 
|  | 104 | p = &(DRD_(clientobj_get)(cond, ClientCondvar)->cond); | 
|  | 105 | if (p == 0) | 
|  | 106 | { | 
|  | 107 | p = &(DRD_(clientobj_add)(cond, ClientCondvar)->cond); | 
|  | 108 | DRD_(cond_initialize)(p, cond); | 
|  | 109 | } | 
|  | 110 | return p; | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 111 | } | 
|  | 112 |  | 
| bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 113 | static struct cond_info* DRD_(cond_get)(const Addr cond) | 
| bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 114 | { | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 115 | tl_assert(offsetof(DrdClientobj, cond) == 0); | 
|  | 116 | return &(DRD_(clientobj_get)(cond, ClientCondvar)->cond); | 
| bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 117 | } | 
|  | 118 |  | 
|  | 119 | /** Called before pthread_cond_init(). */ | 
| bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 120 | void DRD_(cond_pre_init)(const Addr cond) | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 121 | { | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 122 | struct cond_info* p; | 
| bart | 72b751c | 2008-03-01 13:44:24 +0000 | [diff] [blame] | 123 |  | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 124 | if (DRD_(s_trace_cond)) | 
|  | 125 | { | 
|  | 126 | VG_(message)(Vg_UserMsg, | 
|  | 127 | "[%d/%d] cond_init       cond 0x%lx", | 
|  | 128 | VG_(get_running_tid)(), | 
|  | 129 | DRD_(thread_get_running_tid)(), | 
|  | 130 | cond); | 
|  | 131 | } | 
| bart | 72b751c | 2008-03-01 13:44:24 +0000 | [diff] [blame] | 132 |  | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 133 | p = DRD_(cond_get)(cond); | 
| bart | 72b751c | 2008-03-01 13:44:24 +0000 | [diff] [blame] | 134 |  | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 135 | if (p) | 
|  | 136 | { | 
|  | 137 | CondErrInfo cei = { .cond = cond }; | 
|  | 138 | VG_(maybe_record_error)(VG_(get_running_tid)(), | 
|  | 139 | CondErr, | 
|  | 140 | VG_(get_IP)(VG_(get_running_tid)()), | 
|  | 141 | "initialized twice", | 
|  | 142 | &cei); | 
|  | 143 | } | 
| bart | 72b751c | 2008-03-01 13:44:24 +0000 | [diff] [blame] | 144 |  | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 145 | p = DRD_(cond_get_or_allocate)(cond); | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 146 | } | 
|  | 147 |  | 
| bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 148 | /** Called after pthread_cond_destroy(). */ | 
| bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 149 | void DRD_(cond_post_destroy)(const Addr cond) | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 150 | { | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 151 | struct cond_info* p; | 
| bart | 72b751c | 2008-03-01 13:44:24 +0000 | [diff] [blame] | 152 |  | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 153 | if (DRD_(s_trace_cond)) | 
|  | 154 | { | 
|  | 155 | VG_(message)(Vg_UserMsg, | 
|  | 156 | "[%d/%d] cond_destroy    cond 0x%lx", | 
|  | 157 | VG_(get_running_tid)(), | 
|  | 158 | DRD_(thread_get_running_tid)(), | 
|  | 159 | cond); | 
|  | 160 | } | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 161 |  | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 162 | p = DRD_(cond_get)(cond); | 
|  | 163 | if (p == 0) | 
|  | 164 | { | 
|  | 165 | CondErrInfo cei = { .cond = cond }; | 
|  | 166 | VG_(maybe_record_error)(VG_(get_running_tid)(), | 
|  | 167 | CondErr, | 
|  | 168 | VG_(get_IP)(VG_(get_running_tid)()), | 
|  | 169 | "not a condition variable", | 
|  | 170 | &cei); | 
|  | 171 | return; | 
|  | 172 | } | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 173 |  | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 174 | if (p->waiter_count != 0) | 
|  | 175 | { | 
|  | 176 | CondErrInfo cei = { .cond = cond }; | 
|  | 177 | VG_(maybe_record_error)(VG_(get_running_tid)(), | 
|  | 178 | CondErr, | 
|  | 179 | VG_(get_IP)(VG_(get_running_tid)()), | 
|  | 180 | "destruction of condition variable being waited" | 
|  | 181 | " upon", | 
|  | 182 | &cei); | 
|  | 183 | } | 
| bart | 72b751c | 2008-03-01 13:44:24 +0000 | [diff] [blame] | 184 |  | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 185 | DRD_(clientobj_remove)(p->a1, ClientCondvar); | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 186 | } | 
|  | 187 |  | 
| bart | 08e6d6a | 2008-06-28 16:28:49 +0000 | [diff] [blame] | 188 | /** Called before pthread_cond_wait(). Note: before this function is called, | 
|  | 189 | *  mutex_unlock() has already been called from drd_clientreq.c. | 
|  | 190 | */ | 
| bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 191 | int DRD_(cond_pre_wait)(const Addr cond, const Addr mutex) | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 192 | { | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 193 | struct cond_info* p; | 
|  | 194 | struct mutex_info* q; | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 195 |  | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 196 | if (DRD_(s_trace_cond)) | 
|  | 197 | { | 
|  | 198 | VG_(message)(Vg_UserMsg, | 
|  | 199 | "[%d/%d] cond_pre_wait   cond 0x%lx", | 
|  | 200 | VG_(get_running_tid)(), | 
|  | 201 | DRD_(thread_get_running_tid)(), | 
|  | 202 | cond); | 
|  | 203 | } | 
| bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 204 |  | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 205 | p = DRD_(cond_get_or_allocate)(cond); | 
|  | 206 | tl_assert(p); | 
| bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 207 |  | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 208 | if (p->waiter_count == 0) | 
|  | 209 | { | 
|  | 210 | p->mutex = mutex; | 
|  | 211 | } | 
|  | 212 | else if (p->mutex != mutex) | 
|  | 213 | { | 
|  | 214 | CondWaitErrInfo cwei | 
|  | 215 | = { .cond = cond, .mutex1 = p->mutex, .mutex2 = mutex }; | 
|  | 216 | VG_(maybe_record_error)(VG_(get_running_tid)(), | 
|  | 217 | CondWaitErr, | 
|  | 218 | VG_(get_IP)(VG_(get_running_tid)()), | 
|  | 219 | "Inconsistent association of condition variable" | 
|  | 220 | " and mutex", | 
|  | 221 | &cwei); | 
|  | 222 | } | 
|  | 223 | tl_assert(p->mutex); | 
|  | 224 | q = DRD_(mutex_get)(p->mutex); | 
|  | 225 | if (q | 
|  | 226 | && q->owner == DRD_(thread_get_running_tid)() && q->recursion_count > 0) | 
|  | 227 | { | 
|  | 228 | const ThreadId vg_tid = VG_(get_running_tid)(); | 
|  | 229 | MutexErrInfo MEI = { q->a1, q->recursion_count, q->owner }; | 
|  | 230 | VG_(maybe_record_error)(vg_tid, | 
|  | 231 | MutexErr, | 
|  | 232 | VG_(get_IP)(vg_tid), | 
|  | 233 | "Mutex locked recursively", | 
|  | 234 | &MEI); | 
|  | 235 | } | 
|  | 236 | else if (q == 0) | 
|  | 237 | { | 
|  | 238 | DRD_(not_a_mutex)(p->mutex); | 
|  | 239 | } | 
| bart | 08e6d6a | 2008-06-28 16:28:49 +0000 | [diff] [blame] | 240 |  | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 241 | return ++p->waiter_count; | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 242 | } | 
|  | 243 |  | 
| bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 244 | /** Called after pthread_cond_wait(). */ | 
| bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 245 | int DRD_(cond_post_wait)(const Addr cond) | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 246 | { | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 247 | struct cond_info* p; | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 248 |  | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 249 | if (DRD_(s_trace_cond)) | 
|  | 250 | { | 
|  | 251 | VG_(message)(Vg_UserMsg, | 
|  | 252 | "[%d/%d] cond_post_wait  cond 0x%lx", | 
|  | 253 | VG_(get_running_tid)(), | 
|  | 254 | DRD_(thread_get_running_tid)(), | 
|  | 255 | cond); | 
|  | 256 | } | 
| bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 257 |  | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 258 | p = DRD_(cond_get)(cond); | 
|  | 259 | if (p) | 
|  | 260 | { | 
|  | 261 | if (p->waiter_count > 0) | 
| bart | a9c5508 | 2008-06-28 16:55:35 +0000 | [diff] [blame] | 262 | { | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 263 | --p->waiter_count; | 
|  | 264 | if (p->waiter_count == 0) | 
|  | 265 | { | 
|  | 266 | p->mutex = 0; | 
|  | 267 | } | 
| bart | a9c5508 | 2008-06-28 16:55:35 +0000 | [diff] [blame] | 268 | } | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 269 | return p->waiter_count; | 
|  | 270 | } | 
|  | 271 | return 0; | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 272 | } | 
|  | 273 |  | 
| bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 274 | static void DRD_(cond_signal)(Addr const cond) | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 275 | { | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 276 | const ThreadId vg_tid = VG_(get_running_tid)(); | 
|  | 277 | const DrdThreadId drd_tid = DRD_(VgThreadIdToDrdThreadId)(vg_tid); | 
|  | 278 | struct cond_info* const cond_p = DRD_(cond_get)(cond); | 
| bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 279 |  | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 280 | if (cond_p && cond_p->waiter_count > 0) | 
|  | 281 | { | 
|  | 282 | if (DRD_(s_report_signal_unlocked) | 
|  | 283 | && ! DRD_(mutex_is_locked_by)(cond_p->mutex, drd_tid)) | 
|  | 284 | { | 
|  | 285 | /* A signal is sent while the associated mutex has not been locked. */ | 
|  | 286 | /* This can indicate but is not necessarily a race condition.       */ | 
|  | 287 | CondRaceErrInfo cei; | 
|  | 288 | cei.cond  = cond; | 
|  | 289 | cei.mutex = cond_p->mutex; | 
|  | 290 | VG_(maybe_record_error)(vg_tid, | 
|  | 291 | CondRaceErr, | 
|  | 292 | VG_(get_IP)(vg_tid), | 
|  | 293 | "CondErr", | 
|  | 294 | &cei); | 
|  | 295 | } | 
|  | 296 | } | 
|  | 297 | else | 
|  | 298 | { | 
|  | 299 | /* No other thread is waiting for the signal, hence the signal will be */ | 
|  | 300 | /* lost. This is normal in a POSIX threads application.                */ | 
|  | 301 | } | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 302 | } | 
|  | 303 |  | 
| bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 304 | /** Called before pthread_cond_signal(). */ | 
| bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 305 | void DRD_(cond_pre_signal)(Addr const cond) | 
| bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 306 | { | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 307 | if (DRD_(s_trace_cond)) | 
|  | 308 | { | 
|  | 309 | VG_(message)(Vg_UserMsg, | 
|  | 310 | "[%d/%d] cond_signal     cond 0x%lx", | 
|  | 311 | VG_(get_running_tid)(), | 
|  | 312 | DRD_(thread_get_running_tid)(), | 
|  | 313 | cond); | 
|  | 314 | } | 
| bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 315 |  | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 316 | DRD_(cond_signal)(cond); | 
| bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 317 | } | 
|  | 318 |  | 
| bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 319 | /** Called before pthread_cond_broadcast(). */ | 
| bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 320 | void DRD_(cond_pre_broadcast)(Addr const cond) | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 321 | { | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 322 | if (DRD_(s_trace_cond)) | 
|  | 323 | { | 
|  | 324 | VG_(message)(Vg_UserMsg, | 
|  | 325 | "[%d/%d] cond_broadcast  cond 0x%lx", | 
|  | 326 | VG_(get_running_tid)(), | 
|  | 327 | DRD_(thread_get_running_tid)(), | 
|  | 328 | cond); | 
|  | 329 | } | 
| bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 330 |  | 
| bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 331 | DRD_(cond_signal)(cond); | 
| sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 332 | } |