Turnstile_purpose_ts_free

Bulat Bulat bltsrc at mail.ru
Sun Jun 5 08:08:54 UTC 2016


 Hi, guys.

Have little question about implementation of turnstiles in the kernel.
That is, what is the purpose of ts_free list in turnstile structure? 
Related file: kern/subr_turnstile.c

I understand that turnstile is used for tracking non-sleepable locks, tracking
blocked threads on that lock, that
when thread blocks on lock it adds its own turnstile to lock's turnstile's ts_free
list and regrabs any available turnstile from that lock's turnstile's ts_free list when
it is waking up.

Could you please explain, why algorithm does so, why goes through  hassle of
putting turnstile into ts_free only to regrab it from ts_free later, as it stores pointer to own turnstile
and could keep it there, using only when it is the first thread to be blocked on a lock.

There is definitely logic in using ts_free member, but it is a bit unclear for me.
Would be glad to see your explanation, thanks.

bnm



More information about the freebsd-hackers mailing list