Changeset 13964ef in mainline


Ignore:
Timestamp:
2008-11-22T17:10:12Z (16 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0aa1665
Parents:
2eb893b
Message:

Fix race that allowed Udebug to report THREAD_B events for threads already reported with THREAD_READ.

Location:
kernel/generic
Files:
3 edited

Legend:

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

    r2eb893b r13964ef  
    195195    bool end_variant);
    196196
    197 void udebug_thread_b_event(struct thread *t);
     197void udebug_thread_b_event_attach(struct thread *t, struct task *ta);
    198198void udebug_thread_e_event(void);
    199199
  • kernel/generic/src/proc/thread.c

    r2eb893b r13964ef  
    764764                         }
    765765                }
     766#ifdef CONFIG_UDEBUG
     767                /*
     768                 * Generate udebug THREAD_B event and attach the thread.
     769                 * This must be done atomically (with the debug locks held),
     770                 * otherwise we would either miss some thread or receive
     771                 * THREAD_B events for threads that already existed
     772                 * and could be detected with THREAD_READ before.
     773                 */
     774                udebug_thread_b_event_attach(t, TASK);
     775#else
    766776                thread_attach(t, TASK);
     777#endif
    767778                thread_ready(t);
    768 
    769 #ifdef CONFIG_UDEBUG
    770                 /* Generate udebug THREAD_B event */
    771                 udebug_thread_b_event(t);
    772 #endif
    773779
    774780                return 0;
  • kernel/generic/src/udebug/udebug.c

    r2eb893b r13964ef  
    306306}
    307307
    308 /** Thread-creation event hook.
     308/** Thread-creation event hook combined with attaching the thread.
    309309 *
    310310 * Must be called when a new userspace thread is created in the debugged
    311  * task. Generates a THREAD_B event.
     311 * task. Generates a THREAD_B event. Also attaches the thread @a t
     312 * to the task @a ta.
     313 *
     314 * This is necessary to avoid a race condition where the BEGIN and THREAD_READ
     315 * requests would be handled inbetween attaching the thread and checking it
     316 * for being in a debugging session to send the THREAD_B event. We could then
     317 * either miss threads or get some threads both in the thread list
     318 * and get a THREAD_B event for them.
    312319 *
    313320 * @param t     Structure of the thread being created. Not locked, as the
    314321 *              thread is not executing yet.
    315  */
    316 void udebug_thread_b_event(struct thread *t)
     322 * @param ta    Task to which the thread should be attached.
     323 */
     324void udebug_thread_b_event_attach(struct thread *t, struct task *ta)
    317325{
    318326        call_t *call;
     
    320328        mutex_lock(&TASK->udebug.lock);
    321329        mutex_lock(&THREAD->udebug.lock);
     330
     331        thread_attach(t, ta);
    322332
    323333        LOG("udebug_thread_b_event\n");
Note: See TracChangeset for help on using the changeset viewer.