what is the difference between user mode and kernel mode in terms of total number of machine instructions available?
I read this paragraph from " Modern Operating Systems , Tanenbaum " Most computers have two modes of operation: kernel mode and user mode. The operating system is the most fundamental piece of software and runs in kernel mode (also called supervisor mode). In this mode it has complete access to all the hardware and can execute any instruction the machine is capable of executing. The rest of the software runs in user mode, in which only a subset of the machine instructions is available. I am unable to get how they are describing difference in these two modes on basis of machine instructions available , at user end any software has the capability to make any changes at the hardware level ,like we have software which can affect the functioning of CPU , can play with registry details , so how can we say that at user mode , we have only subset of machine instructions available ?
The instructions that are available only in kernel mode are tend to be very few. These instructions are those that are only needed to manage the system. For example, most processors have a HALT instruction that stops the CPU that is used for system shutdowns. Obviously you would not want any user to be able to execute HALT and stop the computer for everyone. Such instructions are then made only accessible in kernel mode. Processors use a table of handlers for interrupt and exceptions. The Operating system creates such a table listing the handlers for these events. Then it loads register(s) giving the location(and size) of the table. The instructions for loading this register(s) are kernel mode only. Otherwise, any application could create total havoc on the system. Instructions of these nature will trigger an exception if executing in user mode. Such instructions tend to be few in number.
Well, in user-mode, there is definitely a subset of instructions available. This is the reason we have System Calls. Example: A user wants to create a new process in C. He cannot do that without entering kernel-mode, because certain set of instructions are only available to kernel-mode, So he uses the system call fork, that executes instructions for creating a new process (not available in user-mode). So System call is a mechanism of requesting a service from kernel of the OS to do something for the user, which he/she cannot write code for. Following excerpt from above link sums it up in the best way: A program is usually limited to its own address space so that it cannot access or modify other running programs or the operating system itself, and is usually prevented from directly manipulating hardware devices (e.g. the frame buffer or network devices). However, many normal applications obviously need access to these components, so system calls are made available by the operating system to provide well defined, safe implementations for such operations. The operating system executes at the highest level of privilege, and allows applications to request services via system calls, which are often initiated via interrupts. An interrupt automatically puts the CPU into some elevated privilege level, and then passes control to the kernel, which determines whether the calling program should be granted the requested service. If the service is granted, the kernel executes a specific set of instructions over which the calling program has no direct control, returns the privilege level to that of the calling program, and then returns control to the calling program.
Semaphore under uCOS-III
Logical addressing calculation
How thread is preserved in os fork?
Could someone help me to figure an example of MRU and CLOCK?
Composition Of An OS [closed]
Can Electron affect other OS apps?
How page faults are handled with Page Size Extension?
How to Install Metasploitable on External Device
Computer requirements for an RTOS
How to write data directly into video memory?
How page table entry invalidations communicated between processes?
How does keyboard or other I/O devices work before operaing system boots?
Working with QEMU on Pintos : make check returns FAIL because QEMU hangs after execution
How can two threads share memory declared as variables in an object?
OS routine on an interrupt
Minimum size of each page table entry