[lkml]   [2004]   [Feb]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: keventd_create_kthread
    In message <> you write:
    > wait_task_inactive() will return due to the preemption?
    > perhaps wait_task_inactive() should wait until the target task leaves state

    That's not enough: it can set that and then get preemted. It really
    want to return when the task is off the runqueue. The original
    wait_task_inactive() does an incredible complicated and AFAICT useless
    dance wrt not locking and disabling preempt explicitly. Ingo, how's
    this replacement? (And who wrote this code?)

    * wait_task_inactive - wait for a thread to unschedule.
    * The caller must ensure that the task *will* unschedule sometime soon,
    * else this function might spin for a *long* time. This function can't
    * be called with interrupts off, or it may introduce deadlock with
    * smp_call_function() if an IPI is sent by the same process we are
    * waiting to become inactive.
    void wait_task_inactive(task_t * p)
    unsigned long flags;
    runqueue_t *rq;

    rq = task_rq_lock(p, &flags);
    /* Must be off runqueue entirely, not preempted. */
    if (unlikely(p->array)) {
    task_rq_unlock(rq, &flags);
    /* If it's preempted: yield. It could be a while. */
    if (!task_running(p))
    goto repeat;
    task_rq_unlock(rq, &flags);

    Untested BTW.

    Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 14:01    [W:0.018 / U:0.368 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site