23 Feb 2017

Unix 1.5 Assumptions About Hardware


ASSUMPTIONS ABOUT HARDWARE




The execution of user processes on UNIX systems is divided into two levels: user and kernel. 

When a process executes a system call, the execution mode of the process changes from user mode to kernel mode: the operating system executes and attempts to service the user request, returning an error code if it fails.



The differences between the two modes are :- 
• Processes in user mode can access their own instructions and data but not kernel instructions and data. Processes in kernel mode, however, can access kernel and user addresses.
• Some machine instructions are privileged and result in an error when executed in user mode.

Interrupts and Exceptions
The UNIX system allows devices such as I/O peripherals or the system clock to, interrupt the CPU asynchronously. On interruption, the kernel saves it as current context, determines the cause of the interrupt, and services the interrupt. After the kernel services the interrupt, it restores its interrupted context and proceeds as if nothing has happened. When the kernel services an interrupt, it blocks out lower priority interrupts but services higher priority interrupts.
An exception condition refers to unexpected events caused by a process, such as addressing illegal memory, executing privileged instructions, dividing by zero, etc. They are distinct from interrupts, which are caused by events that are external to a process. Exceptions happen "in the middle" of the execution of an instruction, and the system attempts to restart the instruction after handling the exception. The UNIX system uses one mechanism to handle interrupts and exception conditions.

Processor Execution Levels



Computers typically have a set of privileged instructions that set the processor execution level in the processor status word. Setting the processor execution level to certain values masks off interrupts from that level and lower levels, allowing only higher-level interrupts. If the kernel masks out disk interrupts, all interrupts except for clock interrupts and machine error interrupts are prevented. If it masks out software interrupts, all other interrupts may occur.

Memory Management
The kernel permanently resides in main memory as does the currently executing process. When compiling a program, the compiler generates a set of addresses in the program that represent addresses of variables and data structures or the addresses of instructions such as functions. The compiler generates the addresses for a virtual machine as if no other program will execute simultaneously on the physical machine. When the program is to run on the machine, the kernel allocates space in main memory for it, but the virtual addresses generated by the compiler need not identical to the physical addresses that they occupy in the machine. The kernel coordinates with the machine hardware to set up a virtual to physical address translation that maps the compiler generated addresses to the physical machine addresses. The mapping depends on the capabilities of the machine hardware.

Friends, if you find this post useful please comment below. If you want quick notes for any topic please mail us at hardikpanchal551@gmail.com, we will try to provide notes if possible. Thanks for reading.

2 comments: