0% found this document useful (0 votes)
4 views11 pages

Operating System Concepts Overview

Lecture 2 covers key operating system concepts including storage structure, operating system operations, and architecture. It explains the differences between main memory and secondary storage, the instruction execution cycle, and the dual-mode operation of user and kernel modes. Additionally, it discusses multiprocessor and clustered systems, their advantages, and the importance of caching and device drivers in managing system resources.

Uploaded by

Malik Awan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views11 pages

Operating System Concepts Overview

Lecture 2 covers key operating system concepts including storage structure, operating system operations, and architecture. It explains the differences between main memory and secondary storage, the instruction execution cycle, and the dual-mode operation of user and kernel modes. Additionally, it discusses multiprocessor and clustered systems, their advantages, and the importance of caching and device drivers in managing system resources.

Uploaded by

Malik Awan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Lecture 2 – Operating System Concepts

(Pages 1–11)
1. Recap of Lecture 1

 What is an Operating System (OS)


 What Operating Systems Do
 Computer-System Organization
 Computer-System Architecture
 Operating-System Structure

2. Objectives of This Lecture

 Storage Structure
 Operating System Operations
 Operating System Architecture

3. Storage Definitions and Notation


1. Bit → Smallest storage unit (0 or 1).
2. Byte → 8 bits (basic unit of storage in most computers).
3. Word → Native unit of data in computer architecture (e.g., 64-bit word).
4. Storage Sizes
o 1 KB = 1024 Bytes
o 1 MB = 1024² Bytes
o 1 GB = 1024³ Bytes
o 1 TB = 1024⁴ Bytes
o 1 PB = 1024⁵ Bytes
(Manufacturers often simplify: 1 MB ≈ 1 million bytes, 1 GB ≈ 1
billion bytes).
5. Networking → Data measured in bits (not bytes).
 Instruction Execution Cycle
 Memory Addressing (limitations of RAM)
 Secondary Storage
 Main Memory
 Secondary Storage
 Hard Disks
 Solid-State Disks

4. Storage Structure – CPU & Memory


 Programs run from Main Memory (RAM).
 Interaction with RAM is through load and store instructions.
1. Load instruction → Moves data from RAM → CPU register.
2. Store instruction → Moves data from register → RAM.
 Instruction Execution Cycle:
1. Fetch instruction → store in instruction register.
2. Decode instruction → may fetch operands from memory.
3. Execute → store result back in memory.

5. Memory Addressing

 Memory only sees addresses, not how they are generated.


 Ideally, all programs should be in RAM, but not possible in reality because:
1. RAM is too small.
2. RAM is volatile (data lost when power off).

6. Secondary Storage

 Acts as an extension of RAM.


 Stores large quantities of data.
 Magnetic disks (HDDs) → most common.
 Other devices also exist with differences in speed, cost, size, and volatility.

7. Storage Structure Types


1. Main Memory (RAM)
o Only large storage that CPU can access directly.
o Random access
o Volatile

2. Secondary Storage
o Extension of RAM.
o Non-volatile, large capacity

3. Hard Disks (HDD)


Made of rigid platters with magnetic coating.
Structure:
o Platters → divided into tracks.
o Tracks → subdivided into sectors.
Disk controller manages logical interaction between computer & disk.

4. Solid State Drives (SSD)


o Faster, non-volatile
o Increasing popularity
o Based on different technologies (e.g., flash memory).

 Caching
 Device Driver

8. Storage Hierarchy
 Organized by: Speed, Cost, Volatility.
 Caching → Copy data to faster storage (e.g., RAM as cache for HDD).
 Device Drivers → Manage I/O, act as interface between hardware & OS
kernel.

(Diagram in slides: shows levels → Registers → Cache → RAM → SSD/HDD →


Tape, etc.)
 Cache Principle
 Cache Management (size & replacement policy)

10. Caching
 Used in hardware, OS, and software.
 Principle: Copy data from slower storage → faster storage temporarily.
 Steps:
1. Check cache first.
2. If data present → use (fast).
3. If not → fetch from slower storage, put in cache, then use.
 Challenges: Cache is smaller → needs good management & replacement
policy.

 Dual-mode Operation
1. User Mode
2. Kernel Mode
 Mode Bit
 Transition from User to Kernel Mode

11. Operating-System Operations


 Dual Mode (User & Kernel) protects system.

a. User Mode

 Runs applications (e.g., text editor).


 Switch to kernel mode if: system call, interrupt, or request occurs.

b. Kernel Mode

 Boots system, runs OS functions.


 Executes privileged instructions (e.g., interrupts, I/O).
 Illegal if tried in user mode → generates trap.
 Mode Bit (hardware feature):
o Kernel mode = 0
o User mode = 1
 When interrupt/fault occurs → hardware switches system into kernel
mode.
 Purpose:
o Distinguish user code vs kernel code.
o Some instructions are only executable in kernel mode.
 System Call: switches user mode → kernel mode.
 Return from system call: switches kernel mode → user mode.

2. Transition from User to Kernel Mode

 Happens during:
o System calls (program requests OS service).
o Interrupts (external events, like I/O completion).
o Faults/Traps (illegal instructions, divide by zero).

 Multiprocessor Systems
 Advantages
 Types of Multiprocessing
o Asymmetric Multiprocessing (AMP)
o Symmetric Multiprocessing (SMP)
 Dual-Core Design
 Types of Multiprocessors (Comparison Table)
 Symmetric Multiprocessing Architecture

3. Computer-System Architecture
 Most systems → single general-purpose processor.
 But also have special-purpose processors (e.g., I/O processors, GPUs).
 Multiprocessor Systems (Increasingly common.)
 Also called Parallel Systems or Tightly Coupled Systems.

Advantages:

1. Increased Throughput – More processors = more tasks done in parallel.


2. Economy of Scale – Cheaper than multiple single systems.
3. Increased Reliability – System can continue even if one processor fails
(fault tolerance).

Types:

1. Asymmetric Multiprocessing (AMP)


2. Symmetric Multiprocessing (SMP)

4. Dual-Core and Multicore Systems

 Dual-Core → two processing cores in one chip.


 Multicore → Multiple cores inside a single chip.
 Multi-chip systems → several separate processors in one chassis.
 Benefit: Better performance with less power consumption.

5. Types of Multiprocessors
 Asymmetric Multiprocessing (AMP):
o Master assigns tasks, slaves perform them.
o Can have different architectures.
o If master fails → system may fail unless backup master is available.
 Symmetric Multiprocessing (SMP):
o All processors perform all tasks.
o Same architecture.
o Shared memory communication & resources.
o If one processor fails → system performance reduces, but continues.
6. Table – Comparison of SMP vs AMP

Feature SMP (Symmetric) AMP (Asymmetric)

OS Tasks All processors run OS Only master runs OS

Process Common ready queue or private


Master assigns to slaves
Handling queues

Architecture Same for all processors May be same or different

Communication Shared memory Controlled by master

If master fails → another must


Failure Handling If one fails → system slows but works
replace

7. Symmetric Multiprocessing Architecture

 All processors connected to shared main memory.


 Each CPU has access to same memory space.
 OS manages scheduling across processors.

 Clustered Systems (Overview)


 Asymmetric Clustering
 Symmetric Clustering

8. Clustered Systems
 Similar to multiprocessor systems but:
o Use multiple independent computers working together.
o Share resources via Storage-Area Network (SAN).
 Use cases: High-performance computing (HPC), high availability.
 Applications must support parallelization to use cluster power.
9. Clustered System Types
a. Asymmetric Clustering

 One node = hot standby (backup).


 Other nodes run applications.
 If active node fails → standby takes over.

(Details)

 Has master node controlling slave nodes.


 Uses distributed cache → improves performance.
 Resources (memory, devices) divided at boot time.
 Failover: if master fails → standby node takes over.

b. Symmetric Clustering

 All nodes run applications and monitor each other.


 More efficient because no idle standby.

(Details)

 Two or more nodes run applications and monitor each other.


 Better resource usage than asymmetric (no node wasted as standby).
 More reliable because multiple nodes share the load.

Questions & Exercises


Kernel vs User Mode
Privileged Instructions
Symmetric vs Asymmetric Multiprocessing
Clustered vs Multiprocessor Systems
Interrupts vs Traps
Caches (usefulness, problems, limitations)
Q1. Kernel Mode vs User Mode
 How does the OS distinguish between kernel mode and user mode?
o OS uses a mode bit (provided by hardware).
o Kernel Mode (0):
 Executes privileged instructions.
 Can directly control I/O, memory, and hardware.
o User Mode (1):
 Executes user programs.
 Cannot execute privileged instructions.

Q2. Privileged Instructions


Which instructions should be privileged?

 a. Set value of timer → Privileged (prevents user from disabling system


control).
 b. Read the clock → Not privileged (safe for users).
 c. Clear memory → Privileged (user must not erase system memory).
 d. Issue a trap instruction → Not privileged (this is how users request OS
service).
 e. Turn off interrupts → Privileged (critical for system control).
 f. Modify entries in device-status table → Privileged (controls I/O devices).
 g. Switch from user to kernel mode → Privileged (cannot be done directly
by user).
 h. Access I/O device → Privileged (protects hardware from misuse).

Q3. Symmetric vs Asymmetric Multiprocessing


 Symmetric Multiprocessing (SMP):
o All processors share work equally.
o Same architecture.
o Use shared memory.
 Asymmetric Multiprocessing (AMP):
o One master processor controls others (slaves).
o May have different architectures.
o Master assigns tasks, slaves execute.

Advantages of Multiprocessor Systems:

1. Increased throughput (parallel execution).


2. Economy of scale (cheaper than multiple systems).
3. Increased reliability (fault tolerance, graceful degradation).

Disadvantage:

 Complexity in design and scheduling.

Q4. Clustered Systems vs Multiprocessor Systems


 Multiprocessor systems:
o Multiple CPUs in one system (shared memory).
 Clustered systems:
o Multiple independent computers connected together (via SAN or
network).
o Share resources, appear as one system.
o Require:
 Shared storage (SAN).
 Cluster software to coordinate nodes.
 High-availability mechanisms (failover, monitoring).

Q5. Interrupts vs Traps


 Interrupt:
o Caused by external events (I/O completion, hardware signals).
o Purpose: CPU can respond to urgent events.
 Trap:
o Caused by software or internal events (errors or requests).
o Example: divide by zero, invalid memory access.
 Difference:
o Interrupt = external → asynchronous.
o Trap = internal → synchronous.

Can traps be intentional?

 Yes ✅
 Example: System calls (user program requests OS service through a trap).

Q6. Caches
 Why caches are useful?
o Provide faster data access compared to slower storage.
o Reduce CPU waiting time.
 Problems solved:
o Reduce speed gap between CPU and memory.
o Improve performance.
 Problems caused:
o Cache coherence issue (data mismatch between cache and main
memory).
o Replacement policy (deciding which data to evict).
 Why not make cache as large as storage?
o Too expensive.
o Cache memory (SRAM) is much costlier than DRAM or disk.
o Power and space consumption increase.

You might also like