From the course: Linux Device Drivers: Reading, Writing, and Debugging

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Understand the user and kernel address spaces

Understand the user and kernel address spaces - Linux Tutorial

From the course: Linux Device Drivers: Reading, Writing, and Debugging

Understand the user and kernel address spaces

- [Instructor] Let's talk about address spaces. When you're writing a driver, you need to be aware of address spaces. Your driver code's going to run in the kernel address space. A process, opening up your device file, say, is running in user space. We can also say code running in the kernel is running in kernel mode. And so we have two different address spaces. That means virtual addresses have to be translated differently. Some implementations of Linux and some systems, they overlap pointers. So given literal pointer value could map at different places, maybe the kernel, maybe user space. Most instances of Linux, the kernel virtual addresses are distinct and they're much bigger values from user space. So by looking at a pointer literal value, you could tell if it's kernel or user space. But in user space, all the processes reuse the virtual addresses. So at virtual address and user space, we have to know which process to be able to translate it. And the kernel, of course, knows how…

Contents