1

I'm trying to better understand the process of switching from user mode to kernel mode on linux systems.

When a process requires access to the low level HW/restricted memory spaces, does it issue a system call to the kernel and the kernel runs the code on its behalf and passes the information back to the process ? or does the kernel put the process in a privileged mode and now the process itself is running in kernel mode and has access to whatever resources it requested ?

Thanks !

migrated from serverfault.com Jan 29 at 14:17

This question came from our site for system and network administrators.

1

does it issue a system call to the kernel and the kernel runs the code on its behalf and passes the information back to the process ? or does the kernel put the process in a privileged mode and now the process itself is running in kernel mode and has access to whatever resources he requested ?

Yes. Any of the above, depending on the system call.

Sometimes a process transitions to kernel mode and does things. Sometimes kernel threads handle the work, especially I/O and file system related. For gettimeofday(), vDSO means it just reads the value without going to kernel space.

Read articles introducing the system call interface, such as LWN's Anatomy of a system call. Architecture specific, so the details of Linux on x86 are not portable other operating systems or CPU types. But probably have similar concepts.

Use profiling tools to see what the stacks look like for your workload. Get an idea of the % "system CPU" is typical for your workload.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.