threadgroup_lock — lock threadgroup
void fsfuncthreadgroup_lock ( | struct task_struct * tsk) ; |
Lock the threadgroup tsk
belongs to. No new task is allowed to enter
and member tasks aren't allowed to exit (as indicated by PF_EXITING) or
perform exec. This is useful for cases where the threadgroup needs to
stay stable across blockable operations.
fork and exit paths explicitly call threadgroup_change_{begin|end}() for synchronization. While held, no new task will be added to threadgroup and no existing live task will have its PF_EXITING set.
During exec, a task goes and puts its thread group through unusual changes. After de-threading, exclusive access is assumed to resources which are usually shared by tasks in the same group - e.g. sighand may be replaced with a new one. Also, the exec'ing task takes over group leader role including its pid. Exclude these changes while locked by grabbing cred_guard_mutex which is used to synchronize exec path.