In microprocessor, there are a number of modes like user mode,supervisor mode and so on depending on the architecture of the computer. Why they have created so many modes(why they have assigned so many privileges)
migrated from electronics.stackexchange.com Aug 21 '13 at 12:22
This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.
It is often useful for an operating system to be able to run code from a potentially-untrusted source without having to give the code unlimited power to damage the system. If a processor didn't have any concept of "user mode" and "supervisor mode", the only way an operating system could limit the actions of the untrusted code would be to inspect every single instruction to ensure that it wasn't doing anything that might cause damage. Not exactly speedy. To improve the situation, processors that are designed to facilitate the use of potentially-untrusted code can invoke a "restricted" mode. In this mode, most of the instructions work as they normally would, but are only allowed to access particular areas of memory. To switch back to "unrestricted" mode, it's necessary to execute an instruction which will simultaneously switch the processor to unrestricted mode and transfer program execution to one of a number of special addresses that would be unavailable in restricted mode. Each address is associated with some kind or request for the operating system to do something (typically the exact operation will be specified by the combinations of values in different registers); the operating system code will examine each request and make sure it represents something the calling code is allowed to do; if it does, the operating system will perform the indicated operation and then execute an instruction which will simultaneously put the machine back into restricted mode and transfer program execution to the instruction after the last "request operating-system action" instruction.
Because switching modes is somewhat expensive, some processors have included facilities to allow some programs' actions to be tightly restricted while others are allowed to do a few more things. In practice, however, it's often simpler to just have two modes: restricted and unrestricted (often called "user" and "supervisor").