Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No address space for Linux Kernel threads

Why the Linux kernel threads do not have an address space. For any task to execute, it should have a memory region right? Where do the text and data of kernel threads go?

like image 554
nitin_cherian Avatar asked Jun 04 '11 09:06

nitin_cherian


2 Answers

Kernel threads do have an address space. It's just that they all share the same one. This does not prevent them from each having a different stack.

Text and data are laid out in the kernel address space (the one that is shared by all the threads), depending on how and when it was allocated, and what it's used for.

The Linux MM site has a lot of documentation about this aspect of Linux. Head over there.

like image 50
Mat Avatar answered Oct 20 '22 16:10

Mat


I don't know the precise answer, because I'm not a Linux architect.

But in general, so-called kernel threads do have an address space: it is the address space which contains the kernel. It might not need to be explicitly represented for each kernel thread, since it is shared among many threads.

I'd expect any real thread implementation to have a machine context block containing register values (and stack pointer, etc.), and a pointer to a the address space in which the thread is supposed to run. Then a scheduler, starting a ready thread, can easily determine whether the memory management unit is set up to enable access to the address space (and if not, set it up) to enable the thread to run in its desired space.

like image 34
Ira Baxter Avatar answered Oct 20 '22 14:10

Ira Baxter