Block Diagram of Unix System

Draw the block diagram of Unix system and explain User Mode and Kernal mode .

A Unix operating system consist of three layer

  • Hardware
  • Kernel mode
  • User mode 

The major component of unix system are

1. Kernel

2. Shell & GUI

3. File system

Kernel Mode

In Kernel mode, the executing code has complete and unrestricted access to the underlying hardware. It can execute any CPU instruction and reference any memory address. Kernel mode is generally reserved for the lowest-level, most trusted functions of the operating system. Crashes in kernel mode are catastrophic; they will halt the entire PC.

User Mode

In User mode, the executing code has no ability to directly access hardware or reference memory. Code running in user mode must delegate to system APIs to access hardware or memory. Due to the protection afforded by this sort of isolation, crashes in user mode are always recoverable. Most of the code running on your computer will execute in user mode.

Kernel mode and user mode are a hardware feature, specifically a feature of the processor. Processors designed for mid-to-high-end systems (PC, feature phone, smartphone, all but the simplest network appliances, …) include this feature. Kernel mode can go by different names: supervisor mode, privileged mode, etc. On x86 (the processor type in PCs), it is called “ring 0”, and user mode is called “ring 3”.

The processor has a bit of storage in a register that indicates whether it is in kernel mode or user mode. (This can be more than one bit on processors that have more than two such modes.) Some operations can only be carried out while in kernel mode, in particular changing the virtual memory configuration by modifying the registers that control the MMU ( Memory Management Unit ). Furthermore, there are only very few ways to switch from user mode to kernel mode, and they all require jumping to addresses controlled by the kernel code. This allows the code running in kernel mode to control the memory that code running in user mode can access.

Unix-like operating systems (and most other operating systems with process isolation) are divided in two parts:

  • The kernel runs in kernel mode. The kernel can do everything.
  • Processes run in user mode. Processes can't access hardware and can't access the memory of other processes (except as explicitly shared).

The operating system thus leverages the hardware features (privileged mode, MMU) to enforce isolation between processes.

Microkernel  - based operating systems have a finer-grained architecture, with less code running in kernel mode.

Microkernal** a microkernel  is the near-minimum amount of software that can provide the mechanisms needed to implement an operating system (OS). These mechanisms include low-level address space management, thread management, and inter-process communication (IPC).  

When user mode code needs to perform actions that it can't do directly (such as access a file, access a peripheral, communicate with another process, …), it makes a system call: a jump into a predefined place in kernel code.

When a hardware peripheral needs to request attention from the CPU, it switches the CPU to kernel mode and jumps to a predefined place in kernel code. This is called an interrupt.

Leave Comment

Important Topics

Features of Unix
Block Diagram of Unix System
Architecture of Unix Operating System
Linux Operating System
Linux Vs Unix
Unix vs Windows
Shell and types of Shell
Advantages and disadvantages of Unix
Unix File System
Types of File
Daemon Process
Process Life Cycle
Fork System Call
Piping in Unix
Users and types of Users
User Management Systems
SUDO Users
Basic Shell Commands in Linux