Introduction - Operating System

Basic


  • An OS is a piece of Software that manages all the Resources of a computer system.
  • Without OS
    • Bulky and Complex Apps => Every App has to write its own Code for Resource Management which also violates DRY principle
    • Resource exploitation by 1 App
    • No Memory protection
  • Functionality
    • Resource Management (Arbitration)
      • Memory Management
      • Storage Management (File System)
      • Process Management (CPU Scheduling)
    • Acts as Interface => Between Hardware & User
    • Hides complexity of the Hardware (Abstraction)
    • Security => Isolation and Protection
    • Access to the Computer hardware
  • Goals
    • Maximum CPU Utilization => Should not let CPU be idle
    • No Process Starvation
    • High Priority Execution
  • Key Interfaces => Instruction set architecture (ISA), Application binary interface (ABI), Application programming interface (API)

Types


  • Single Process
    • Only 1 process is executed at a time from the Ready Queue
    • None of the Goals is satisfied
    • Example => MS DOS 1981
  • Batch Processing
    • User prepares jobs using punch cards > A Operator sorts the Jobs into Batches of similar needs > Each Jobs of 1 batch is executed like Single process
    • None of the Goals is satisfied
    • Example => ATLAS, Manchester Univ 1960s
  • Multi-Programming
    • Several processes sharing the Main Memory in a Ready Queue
      • OS can execute any other if current process gets busy with I/O
    • Single CPU, Better CPU Utilization
    • Example => THE, Dijkstra 1960s
  • Multi-Tasking
    • Time Sharing => Each Process is executed of a fixed amount of time
    • Single CPU, Context Switching
    • All Goals are followed
    • Increases responsiveness
    • Example => CTSS, MIT 1960s
  • Multi-Threading
    • .txt > .cpp > compile > executable (.exe) > Program > Process (Under Execution in RAM)
    • Thread (Light weight Process) => Sub-Process in a Process, Independent task
    • Thread Scheduling => Threads are scheduled for execution based on their priority
    • Thread Context Switching => Fast switching, CPU’s cache state is preserved, OS saves current state of thread & switches to another thread of same process, Doesn’t includes switching of memory address space
    • Executes code Asynchronously, Needs to be Multi-Processing environment (Better to have no. of Threads equal to CPU)
    • No need for Isolation and Protection as they are part of same Process
    • Example => Multiple Tabs in Browser, Text-editor
  • Multi-Processing
    • More than 1 CPU
    • Increases reliability => If 1 CPU fails than other can work
    • Better Throughput => Number of task executed per unit time
    • Example => Windows NT
  • Distributed System
    • More than 1 CPU, Memory, GPU
    • Loosely connected autonomous => Geographically separated
    • Example => LOCUS, AIX
  • Real Time
    • Real time error free, Computations within tight-time boundaries
    • Example => ATC (Air Traffic Controller), ROBOTS

Components


  • User Space
    • No Hardware access
    • Interacts with Kernel
    • Types
      • GUI => Windows
      • CLI => Terminal, PowerShell
  • Kernel
    • Interacts with Hardware
    • Functions
      • Process Management => Process Creation & Termination, Process & Thread Schedule, Process Sync, Process Communication
      • Memory Management => Allocate, De-allocate, Free Space management
      • File Management => Create, Delete, Directory Management
      • I/O Management => Spooling, Buffering, Caching
    • Types
      • Monolithic
        • Fast communication between different components of Kernel
        • Bulky => Everything is stored in same place
        • Less Reliable
        • Example => Linux, Unix, MS Dos
      • Micro
        • Less important components are put in User mode
        • Less Bulky, More Reliable and Stable
        • Overhead => Software Interrupt is more, Lower performance
        • Example => L4 Linux, Symbian OS
      • Hybrid
        • File Management in User space rest all in Kernel
        • Example => MacOS, Windows NT
      • Nano/Exo
  • Theory
    • Software Interrupt => Switching between both Components
    • Inter-process Communication (IPC)
      • Shared Memory => Some memory is shared between both components
      • Message Passing => Message is passed using System calls
    • System Call Interface (SCI)
      • Glbc => Library to call it. Implemented in C
    • System Calls => Way to switch from User Mode to kernel Mode
      • Implemented in C
      • App > Glbc > SCI > Kernel > Hardware
      • Types
        • Process Control
        • File Management
        • Device Management
        • Information Maintenance
        • Communication Management
      • System Calls

System


  • How Operating System Boots up?
    • Power On
      • Power Supply
    • CPU loads BIOS or UEFI
      • Basic Input Output System (BIOS) => Non-volatile/ROM chip
      • Unified Extensible Form-ware Interface (UEFI) => Upgraded version of BIOS
      • CPU initialized > Goes to the chip
    • BIOS runs tests and Initialize Hardware
      • Loads some settings from a memory area (Backed by CMOS Battery)
      • Power On Self Test (POST) => Checks all essential Hardware
    • BIOS will handoff responsibility for booting your PC to your OS’s bootloader (Boot device)
      • Master Boot Record (MBR) => Used in old system, In disk 0th index
      • EFI => In partition of disk
    • Bootleader loads the full OS
      • Windows = bootmgr.exe
      • Mac = boot.efi
      • LINUX = GRUB
  • Advantages of 64-bit over the 32-bit OS
    • Addressable Memory => 32-bit CPU = 2^32 memory addresses, 64-bit CPU = 2^64 memory addresses
    • Resource usage => 32-bit OS only supports RAM up to 4 GB
    • Performance => Having larger registers allow you to perform larger calculations at the same time
    • Compatibility => 64-bit CPU can run both 32-bit and 64-bit OS
    • Better Graphics performance => 8-bytes graphics calculations make graphics-intensive apps run faster
  • Types of Storages/Memory
    • Primary => Access Speed & Cost decreases as we go lower
      • Register
      • Cache => Additional memory system that temporarily stores frequently used instructions and data for quicker processing by the CPU
      • Main Memory (RAM)
    • Secondary => Storage media on which computer can store data & programs
      • Electronic Disk
      • Magnetic Disk
      • Optical Disk
      • Magnetic Disk
Share: