Issue
I read that linux kernel threads don't have their own address space, their mm field is set to NULL. I know that all kernel threads share address space, but still, they have their own stack right? They need to somehow describe that field, and without mm, how to they do that? and other lists like open files, where do they keep it? also, what's the point of setting active_mm field to previous user task's mm? thanks in advance.
Solution
As their name suggest, kernel threads work in kernel mode, so its stack is referenced by a CPU register (i.e: ss
, ebp
).
Open files references (as any other process) are kept in the process descriptor field struct files_struct *files
. They have nothing to do with memory descriptors.
For regular process, the fields mm
and active_mm
are normally the same. Kernel threads don't own any memory descriptor, so they use the one that was active (active_mm
) of the previously running process, hence, kernel threads mm
is always null and they use active_mm
.
Hope this helps!
Answered By - Paulo Bu