Kernel Thread Lock Question

View: New views
2 Messages — Rating Filter:   Alert me  

Kernel Thread Lock Question

by Tom Judge :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Do I need to hold the per thread lock here? (This is for 7.1)

PROC_LOCK(p);
//mtx_lock_spin(&sched_lock);
breakout = 0;
FOREACH_THREAD_IN_PROC(p, td) {
    thread_lock(td);
    if (!TD_ON_RUNQ(td) &&
            !TD_IS_RUNNING(td) &&
            !TD_IS_SLEEPING(td)) {
        breakout = 1;
        thread_unlock(td);
        break;
    }
    thread_unlock(td);
}
//mtx_unlock_spin(&sched_lock);
PROC_UNLOCK(p);


Thanks

Tom
_______________________________________________
freebsd-hackers@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@..."

Re: Kernel Thread Lock Question

by Julian Elischer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Tom Judge wrote:

> Do I need to hold the per thread lock here? (This is for 7.1)
>
> PROC_LOCK(p);
> //mtx_lock_spin(&sched_lock);
> breakout = 0;
> FOREACH_THREAD_IN_PROC(p, td) {
>    thread_lock(td);
>    if (!TD_ON_RUNQ(td) &&
>            !TD_IS_RUNNING(td) &&
>            !TD_IS_SLEEPING(td)) {
>        breakout = 1;
>        thread_unlock(td);
>        break;
>    }
>    thread_unlock(td);
> }
> //mtx_unlock_spin(&sched_lock);
> PROC_UNLOCK(p);
>

"probably not" because the value in the status word can change just
after you release it anyhow so your result does not have to be
consistent with anything, just with itself.

>
> Thanks
>
> Tom
> _______________________________________________
> freebsd-hackers@... mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@..."

_______________________________________________
freebsd-hackers@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@..."