在 Linux 2.6 内核之前,struct task_struct
存在于每个进程的内核堆栈的末尾。没有thread_info struct
概念。但在Linux 2.6内核中,而不是task_struct
thread_info struct
被放置在进程内核堆栈的末尾。被放置在最后。这个thread_info结构体包含一个指向task_struct
的指针。结构。
需要什么thread_info
结构要介绍什么?我们本可以访问task_struct
使用 stack pointer
的结构直接如果task_struct
被放置在进程的内核堆栈的末尾。
在 2.6 内核中,task_struct
使用slab_allocator
动态分配。在 2.6 内核之前,它是静态分配的吗?
最佳答案
FrankH,他正在寻找(我怀疑是出于纯粹的兴趣)进行此更改的原因。这是我用我的 l33t 谷歌技能发现的。链接后面有更多信息:
"task_struct is huge. it's around 1,7KB on a 32 bit machine. on the other hand, you can easily see that thread_info is much slimmer.
kernel stack is either 4 or 8KB, and either way a 1.7KB is pretty much, so storing a slimmer struct, that points to task_struct, immediately saves a lot of stack space and is a scalable solution."
关于process - Linux 2.6 内核中需要 thread_info 结构吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6134226/