No address space for Linux Kernel threads

后端 未结 2 756
既然无缘
既然无缘 2021-02-04 19:48

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?

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-04 20:04

    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.

提交回复
热议问题