Changeset 32e6c9c in mainline
- Timestamp:
- 2008-11-21T22:31:43Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ef687799
- Parents:
- 741fd16
- Location:
- kernel/generic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/udebug/udebug.h
r741fd16 r32e6c9c 170 170 */ 171 171 typedef struct { 172 /**173 * Prevent deadlock with udebug_before_thread_runs() in interrupt174 * handler, without actually disabling interrupts.175 * ==0 means "unlocked", >0 means "locked"176 */177 atomic_t int_lock;178 179 172 /** Synchronize debug ops on this thread / access to this structure. */ 180 173 mutex_t lock; -
kernel/generic/src/udebug/udebug.c
r741fd16 r32e6c9c 36 36 * 37 37 * Udebug is an interface that makes userspace debuggers possible. 38 *39 * Functions in this file are executed directly in each thread, which40 * may or may not be the subject of debugging. The udebug_stoppable_begin/end()41 * functions are also executed in the clock interrupt handler. To avoid42 * deadlock, functions in this file are protected from the interrupt43 * by locking the recursive lock THREAD->udebug.int_lock (just an atomic44 * variable). This prevents udebug_stoppable_begin/end() from being45 * executed in the interrupt handler (they are skipped).46 *47 * Functions in udebug_ops.c and udebug_ipc.c execute in different threads,48 * so they needn't be protected from the (preemptible) interrupt-initiated49 * code.50 38 */ 51 39 … … 56 44 #include <arch.h> 57 45 58 static inline void udebug_int_lock(void)59 {60 atomic_inc(&THREAD->udebug.int_lock);61 }62 63 static inline void udebug_int_unlock(void)64 {65 atomic_dec(&THREAD->udebug.int_lock);66 }67 46 68 47 /** Initialize udebug part of task structure. … … 89 68 mutex_initialize(&ut->lock, MUTEX_PASSIVE); 90 69 waitq_initialize(&ut->go_wq); 91 92 /*93 * At the beginning the thread is stoppable, so int_lock be set, too.94 */95 atomic_set(&ut->int_lock, 1);96 70 97 71 ut->go_call = NULL; … … 162 136 ASSERT(TASK); 163 137 164 udebug_int_lock();165 166 138 /* Early check for undebugged tasks */ 167 139 if (!udebug_thread_precheck()) { 168 udebug_int_unlock();169 140 return; 170 141 } … … 232 203 /* Early check for undebugged tasks */ 233 204 if (!udebug_thread_precheck()) { 234 udebug_int_unlock();235 205 return; 236 206 } … … 258 228 mutex_unlock(&TASK->udebug.lock); 259 229 } 260 261 udebug_int_unlock();262 230 } 263 231 … … 274 242 275 243 return; 276 ASSERT(!PREEMPTION_DISABLED);277 278 /*279 * Prevent agains re-entering, such as when preempted inside this280 * function.281 */282 if (atomic_get(&THREAD->udebug.int_lock) != 0)283 return;284 285 udebug_int_lock();286 244 287 245 ipl = interrupts_enable(); … … 294 252 295 253 interrupts_restore(ipl); 296 297 udebug_int_unlock();298 254 } 299 255 … … 312 268 etype = end_variant ? UDEBUG_EVENT_SYSCALL_E : UDEBUG_EVENT_SYSCALL_B; 313 269 314 udebug_int_lock();315 316 270 /* Early check for undebugged tasks */ 317 271 if (!udebug_thread_precheck()) { 318 udebug_int_unlock();319 272 return; 320 273 } … … 363 316 364 317 udebug_wait_for_go(&THREAD->udebug.go_wq); 365 366 udebug_int_unlock();367 318 } 368 319 … … 378 329 { 379 330 call_t *call; 380 381 udebug_int_lock();382 331 383 332 mutex_lock(&TASK->udebug.lock); … … 420 369 LOG("- sleep\n"); 421 370 udebug_wait_for_go(&THREAD->udebug.go_wq); 422 423 udebug_int_unlock();424 371 } 425 372 … … 432 379 { 433 380 call_t *call; 434 435 udebug_int_lock();436 381 437 382 mutex_lock(&TASK->udebug.lock); … … 468 413 mutex_unlock(&TASK->udebug.lock); 469 414 470 /* Leave int_lock enabled. */ 471 /* This event does not sleep - debugging has finished in this thread. */ 415 /* 416 * This event does not sleep - debugging has finished 417 * in this thread. 418 */ 472 419 } 473 420 … … 491 438 LOG("udebug_task_cleanup()\n"); 492 439 LOG("task %" PRIu64 "\n", ta->taskid); 493 494 udebug_int_lock();495 440 496 441 if (ta->udebug.dt_state != UDEBUG_TS_BEGINNING && … … 555 500 ta->udebug.debugger = NULL; 556 501 557 udebug_int_unlock();558 559 502 return 0; 560 503 }
Note:
See TracChangeset
for help on using the changeset viewer.