Changeset 32e6c9c in mainline


Ignore:
Timestamp:
2008-11-21T22:31:43Z (15 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ef687799
Parents:
741fd16
Message:

Get rid of int_lock from udebug_thread_t, as is flawed.

Location:
kernel/generic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/udebug/udebug.h

    r741fd16 r32e6c9c  
    170170 */
    171171typedef struct {
    172         /**
    173          * Prevent deadlock with udebug_before_thread_runs() in interrupt
    174          * handler, without actually disabling interrupts.
    175          * ==0 means "unlocked", >0 means "locked"
    176          */
    177         atomic_t int_lock;
    178 
    179172        /** Synchronize debug ops on this thread / access to this structure. */
    180173        mutex_t lock;
  • kernel/generic/src/udebug/udebug.c

    r741fd16 r32e6c9c  
    3636 *
    3737 * Udebug is an interface that makes userspace debuggers possible.
    38  *
    39  * Functions in this file are executed directly in each thread, which
    40  * 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 avoid
    42  * deadlock, functions in this file are protected from the interrupt
    43  * by locking the recursive lock THREAD->udebug.int_lock (just an atomic
    44  * variable). This prevents udebug_stoppable_begin/end() from being
    45  * 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-initiated
    49  * code.
    5038 */
    5139 
     
    5644#include <arch.h>
    5745
    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 }
    6746
    6847/** Initialize udebug part of task structure.
     
    8968        mutex_initialize(&ut->lock, MUTEX_PASSIVE);
    9069        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);
    9670
    9771        ut->go_call = NULL;
     
    162136        ASSERT(TASK);
    163137
    164         udebug_int_lock();
    165 
    166138        /* Early check for undebugged tasks */
    167139        if (!udebug_thread_precheck()) {
    168                 udebug_int_unlock();
    169140                return;
    170141        }
     
    232203        /* Early check for undebugged tasks */
    233204        if (!udebug_thread_precheck()) {
    234                 udebug_int_unlock();
    235205                return;
    236206        }
     
    258228                mutex_unlock(&TASK->udebug.lock);
    259229        }
    260 
    261         udebug_int_unlock();
    262230}
    263231
     
    274242
    275243        return;
    276         ASSERT(!PREEMPTION_DISABLED);
    277 
    278         /*
    279          * Prevent agains re-entering, such as when preempted inside this
    280          * function.
    281          */
    282         if (atomic_get(&THREAD->udebug.int_lock) != 0)
    283                 return;
    284 
    285         udebug_int_lock();
    286244
    287245        ipl = interrupts_enable();
     
    294252
    295253        interrupts_restore(ipl);
    296 
    297         udebug_int_unlock();
    298254}
    299255
     
    312268        etype = end_variant ? UDEBUG_EVENT_SYSCALL_E : UDEBUG_EVENT_SYSCALL_B;
    313269
    314         udebug_int_lock();
    315 
    316270        /* Early check for undebugged tasks */
    317271        if (!udebug_thread_precheck()) {
    318                 udebug_int_unlock();
    319272                return;
    320273        }
     
    363316
    364317        udebug_wait_for_go(&THREAD->udebug.go_wq);
    365 
    366         udebug_int_unlock();
    367318}
    368319
     
    378329{
    379330        call_t *call;
    380 
    381         udebug_int_lock();
    382331
    383332        mutex_lock(&TASK->udebug.lock);
     
    420369        LOG("- sleep\n");
    421370        udebug_wait_for_go(&THREAD->udebug.go_wq);
    422 
    423         udebug_int_unlock();
    424371}
    425372
     
    432379{
    433380        call_t *call;
    434 
    435         udebug_int_lock();
    436381
    437382        mutex_lock(&TASK->udebug.lock);
     
    468413        mutex_unlock(&TASK->udebug.lock);
    469414
    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         */
    472419}
    473420
     
    491438        LOG("udebug_task_cleanup()\n");
    492439        LOG("task %" PRIu64 "\n", ta->taskid);
    493 
    494         udebug_int_lock();
    495440
    496441        if (ta->udebug.dt_state != UDEBUG_TS_BEGINNING &&
     
    555500        ta->udebug.debugger = NULL;
    556501
    557         udebug_int_unlock();
    558 
    559502        return 0;
    560503}
Note: See TracChangeset for help on using the changeset viewer.