You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure whether it's safe to traverse this list without any lock. I examined all usages and most of them are protected by rcu_read_lock() or read_lock(&tasklist_lock).
Hi @iwoeruhsdfwoi , thanks for your comment.
You're right reg the need for protection.
Do understand though, that this is a book where the reader makes progress as (s)he covers each chapter.
The locking / synchronization details are left to the last two chapters...
In fact, this statement in the book in Ch 6 (pg 311 of the e-book) hints at this:
...
We print the name of the thread as well (by looking up the comm member of
the task structure). You might question why we don't use the get_task_comm() routine to obtain the task's name here; the short
reason: it causes a deadlock! We shall explore this (and how to avoid it) in detail in the later chapters on kernel synchronization. For now, again, we just do it the simple way.
...
This is again mentioned in Ch 12 pg 668, mentioning the fact that as tasklist_lock isn't exported, it isn't available to modules.
The RCU read lock can be used; I shall add it.
As you've written reg this, I'll update the code (and relevant info in a comment in these examples). Thanks.
I'm not sure whether it's safe to traverse this list without any lock. I examined all usages and most of them are protected by
rcu_read_lock()
orread_lock(&tasklist_lock)
.Linux-Kernel-Programming/ch6/foreach/prcs_showall/prcs_showall.c
Line 51 in 7c72a6e
The text was updated successfully, but these errors were encountered: