Vikrant Singh
Vikrant Singh

Reputation: 689

Is there a vm_area_struct pointer for kernel processes?

One of my friend name Raj, told me that there is only one global page table for kernel processes and they don't use vm_area_struct for there memory. vm_area_struct is used only to keep track of memory of user processes not kernel processes.

So I want to know what is the real story? Can someone shed light on which memory does vm_area_struct points to user or kernel?

Upvotes: 1

Views: 173

Answers (1)

user4822941
user4822941

Reputation:

Grab a book on operating systems like "UNIX Internals: The new frontiers".

Are you sure you don't mean mm_struct, which is the thing actually describing the address space?

In short, all kernel threads see the same memory. Further, entire kernel memory and userspace memory for given process are mapped together in one giant address space. It's permissions set on mappings which prevent the userspace process from doing anything with kernel pages.

So, as the kernel switches between tasks, it also changes mm_struct in use. But there is a hack. Because all mappings include the entire kernel, there is no need to switch mm if the new scheduled thing is a kernel thread.

Upvotes: 1

Related Questions