简体   繁体   中英

Linux kernel thread address space

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.

As their name suggest, kernel threads work in kernel mode, so its stack is referenced by a CPU register (ie: 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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM