Qualcomm Interview Question
Software Engineer / DevelopersCountry: United States
Interview Type: Phone Interview
Also, kernel memory has a hard stack size limit. So if some computation can be done in an isolated memory space that needs a lot of memory, it can be done in userspace memory.
Oh, and a crash in userspace memory can't take down the entire system so easily.
All answers above doesn't address why ? : Kernel doesn't map entire physical ram into its address space , so when it wants to use virtual address which is not mapped inside kernel address space it will temparory map those address into special region call pkmap, this time it needs to use user virtual address.
There are two types of virtual addresses: user mode and kernel mode. All user applications/drivers runs in user virtual address space while the kernel mode drivers and OS runs in kernel mode virtual address space. Kernel mode drivers can access user virtual address but vice versa is not true. However kernel mode drivers accessing user virtual addresses can lead to problem. Whenever user mode app/driver wants to run, a process will be created which will provide user virtual address space. So even if app crashes, it will not affect the while system address space but of kernel mode driver crashes , it can lead to system crash.
Obviously, when we are running a program in userspace, we don't have access to the kernel virtual memory addresses. In that situation, the question is moot.
- Prite April 30, 2013When we are running code in kernel mode, say, as a kernel module or driver, we normally access kernel virtual memory. But if the situation comes where our kernel mode code has to interact with some userspace component, we must be extremely careful that we translate "kernel virtual addresses" to "user virtual addresses" before passing them off, and vice-versa.