On Wed, 2003-04-23 at 16:41, Bryan K. wrote: > Reading the kernel source I have noticed that a kernel thread must always > have a valid mm_struct pointer at task_struct->active_mm. This prevents the > mm_struct to be deallocated if a kernel thread uses it. I was wandering why > a kernel thread need a mm_struct if it is not supposed to access addresses > below TASK_SIZE? It does not need (or have) an mm_struct. task->mm is NULL in a kernel thread (task->mm == NULL is what a kernel thread is, by definition, in fact). task->active_mm is just the current address space that is mapped in. It is an optimization, so we can have something like: task A is running and has an mm_struct of foo, thus A->mm == A->active_mm == foo task A is preempted by a kernel thread, B. Thus, B->mm == NULL and A->active_mm == foo, since the mm_struct was never replaced. Now, if task A is rescheduled the mm need not be reloaded. Make sense? Robert Love -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/