Reputation: 1185
I was reading cpu protection rings and system call working. But that leads me to a different question. What if I don't (i.e. a user program ) use kernel API calls (system calls), and if possible write everything in assembly and execute it. If the user program has some inconsistent code, the CPU must not execute them, or the system may crash. But at what point in time the CPU realizes that a particular instruction xyzw
must not be executed? How the protection level plays the key role here? Does the underlying ISA have a predefined privilege level for each instruction?
Thank You.
Upvotes: 0
Views: 106
Reputation:
If the user program has some inconsistent code, the CPU must not execute them, or the system may crash. But at what point in time the CPU realizes that a particular instruction xyzw must not be executed?
what does this mean?
if there is wrong stuff, say division by 0, the cpu will raise an exception while trying to execute it. this switches you to the kernel and the os decides what to do - typically kill the process. modulo cpu bugs this is what happens for all "inconsistent" instructions.
cpu raises exceptions and switches to the kernel all the time - page faults, first time fpu use and whatnot are the standard reasons.
Upvotes: 1