Discussion:
Relevant mailing list
(too old to reply)
Bulat Bulat via freebsd-questions
2016-06-04 19:27:54 UTC
Permalink
Thanks, Matthew and Patrick.

I am currently reading about locking in kernel, mostly man pages and headers
related to topic. That is various kinds of mutexes, rwlocks, shared locks, and the like.
Also I read boot - design and implementation of freebsd.

Then I started reading .c files and stuck on kern/subr_turnstile.
What the structure is and the purpose of it for me is understandable, how it is being
added when thread blocks and how it is being removed after wakeup().

However, the meaning of ts_free member in turnstile structure for me is unclear.
My understanding: when thread discovers than lock's turnstile is already present
at turnstile chain it adds its own turnstile to lock's turnstile's ts_free
and after it wokes up it regrabs turnstile from the same
ts_free list of lock's turnstile. But why does it so, if it already has its own turnstile, what the
meaning of putting of turnstile to free list only for regrabbing it later.

Thanks.
bnm
Matthew Seaman
2016-06-04 21:38:13 UTC
Permalink
Post by Bulat Bulat via freebsd-questions
However, the meaning of ts_free member in turnstile structure for me is unclear.
My understanding: when thread discovers than lock's turnstile is already present
at turnstile chain it adds its own turnstile to lock's turnstile's ts_free
and after it wokes up it regrabs turnstile from the same
ts_free list of lock's turnstile. But why does it so, if it already has its own turnstile, what the
meaning of putting of turnstile to free list only for regrabbing it later.
This is definitely a question for freebsd-***@...

Cheers,

Matthew
Mehmet Erol Sanliturk
2016-06-04 22:59:29 UTC
Permalink
Post by Bulat Bulat via freebsd-questions
Post by Bulat Bulat via freebsd-questions
However, the meaning of ts_free member in turnstile structure for me is
unclear.
Post by Bulat Bulat via freebsd-questions
My understanding: when thread discovers than lock's turnstile is already
present
Post by Bulat Bulat via freebsd-questions
at turnstile chain it adds its own turnstile to lock's turnstile's
ts_free
Post by Bulat Bulat via freebsd-questions
and after it wokes up it regrabs turnstile from the same
ts_free list of lock's turnstile. But why does it so, if it already has
its own turnstile, what the
Post by Bulat Bulat via freebsd-questions
meaning of putting of turnstile to free list only for regrabbing it
later.
Cheers,
Matthew
This is

put to free list - take it from free list .


A possible another method is to use

dispose - allocate

pair .


When dispose - allocate was taking long time ( in old times ) , the "put to
free - take from free" method was in use .


I am not saying that the reason of the use in your case is that , but there
was such a method in older times .


Mehmet Erol Sanliturk

Loading...