An OS can be divided into two layers
Program is an executable file.
Process is an instance of the program in execution.
Shell is a command interpreter. It is a user program.
Kernel is responsible for executing instructions of a program/process on the CPU. Processes run on CPU in time-share manner.
Kernel ensures that each process
Kernel is responsible for ensuring fairness while scheduling process execution order.
Each process is given an "address (memory) space" for execution. It can be divided into shared memory & private memory.
Process by default is assigned private memory. Shared memory can be done with external mechanism.
Kernel is responsible for allocating and protecting memory space of each process. It is also responsible for handling low memory situation by writing process memory to secondary memory ie., swap device.
Kernel can swap memory in two ways:
Kernel is responsible for managing File System ie.,
Kernel provides restricted/controlled access to hardware devices like terminal, hard disk etc.
User processes are of two types/levels
There can be other levels but UNIX makes use of only two.
OS keeps track of the various processes and their state [:see ~4] including which mode it runs in (User vs. Kernel).
If a process executes a system call, the execution switches from user to kernel mode. However, if the user process does not have access to privileged resources, then the system returns an error.
Kernel or CPU execution can be interrupted asynchronously by I/O or system clock interrupts.
On receiving an interrupt the kernel will:
Interrupts & exception handling can be handled by a single mechanism.
There can be critical activity/code execution during which interrupts should be ignored or put aside
Kernel permanently resides in main memory.
Currently executing process also resides in memory (or parts of it)
Compiler creates a program with fixed addresses to refer while executing the program. Virtual Machine (VM) creates the abstraction that a process is running on an isolated machine with fixed memory addresses even though it is running on a system along with other processes.
Kernel does the translation of "VM specific addresses" to "System wide addresses".
OS can be split across three levels/layers:
Note: Hardware is addition [:see ~5]
Kernel Level is responsible for
System Calls provide access to File System & Process control _(diagram on pg. 20).
Chapter 5 is dedicated to System Calls [:see ~ch5]
Assembly language programs (AsmProgs) can make system calls without system call library.
User programs make use of high level libraries (like STDIO) which provide better abstraction or sophisticated use of system calls.
File subsystem accesses file data via Buffering Mechanism.
Buffering Mechanism reads & writes data to Block I/O Devices.
File subsystem can directly read & write data to Character Devices/Raw Devices.
Memory management module (part of Process management subsystem) handles allocating memory for running processes.
In case of insufficient main memory to execute a process, it takes care of moving memory to secondary memory etc. [:see ~ch9]