Question

I'm studying for my operating systems final and was wondering if someone could tell me why the OS needs to switch into kernel mode for syscalls?

Was it helpful?

Solution

A syscall is used specifically to run an operating in the kernel mode since the usual user code is not allowed to do this for security reasons.

For example, if you wanted to allocate memory, the operating system is privileged to do it (since it knows the page tables and is allowed to access memory of other processes), but you as a user program should not be allowed to peek or ruin the memory of other processes. It's a way of sandboxing you. So you send a syscall requesting the operating system to allocate memory, and that happens at the kernel level.

Edit: I see now that the Wikipedia article is surprisingly useful on this

OTHER TIPS

Since this is tagged "homework", I won't just give the answer away but will provide a hint:

The kernel is responsible for accessing the hardware of the computer and ensuring that applications don't step on one another. What would happen if any application could access a hardware device (say, the hard drive) without the cooperation of the kernel?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top