0% found this document useful (0 votes)
69 views

L1 - Introduction

The document provides an overview of operating systems concepts. It discusses what an operating system is, providing a simple definition as a program that acts as an intermediary between the computer user and hardware. It then briefly outlines the history of operating systems, how they evolved with hardware from early computers that had no OS to modern batch processing, time-sharing, and personal computer OSs like Windows and Linux. Key motivations for having an operating system are to provide abstraction from hardware variations, allocate resources efficiently for multiple programs, and act as a control program to prevent misuse of the computer.

Uploaded by

jiatsd
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)
69 views

L1 - Introduction

The document provides an overview of operating systems concepts. It discusses what an operating system is, providing a simple definition as a program that acts as an intermediary between the computer user and hardware. It then briefly outlines the history of operating systems, how they evolved with hardware from early computers that had no OS to modern batch processing, time-sharing, and personal computer OSs like Windows and Linux. Key motivations for having an operating system are to provide abstraction from hardware variations, allocate resources efficiently for multiple programs, and act as a control program to prevent misuse of the computer.

Uploaded by

jiatsd
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
You are on page 1/ 56

CS2106

Introduction to OS

Lecture 1

1
Overview
 Operating Systems basic concepts:
 What is OS?
 Brief History
 Motivation for OS
 Overview of Modern OSes

 Operating System Structures


 OS components
 Types of kernel

 Virtual Machines
[ CS2106 L1 - AY2021 S1 ]
2
What is OS?
 Incorrect/Incomplete definition:
 It is the desktop when you boot up your PC
 The "thing" that stores your games
 Windows! (or Mac! ) (or Linux!)

 One simple definition:


 A program that acts as an intermediary between a computer user
and the computer hardware
 Wikipedia: An operating system (OS) is system software that
manages computer hardware, software resources, and provides
common services for computer programs.
[ CS2106 L1 - AY2021 S1 ]
3
Illustration: What is an OS?
User

Operating System

Hardware

 A simplified view:
 Will be refined as we move along

 The most general version:


 Hardware ( not only computer! )
 User ( can be application programs or actual person! )

[ CS2106 L1 - AY2021 S1 ]
4
Example of Common OS
 On Computer:
 Windows 10/9/8/XP
 Mac OS X
 Linux distros: Ubuntu, Redhat, CentOS, Debian
 Solaris

 On Smartphone:
 iOS, Android, Windows Mobile

 Other hardware with OS:


 Game console: PS4, Xbox, Wii U, PSP vista, …
 Home appliance: Blueray/DVD Player, Mio TV console, …

[ CS2106 L1 - AY2021 S1 ]
5
To invent the future, you must understand the past

BRIEF HISTORY OF OS

[ CS2106 L1 - AY2021 S1 ]
6
Brief History of OS
 Essentially, OS evolves with:
 Computer hardware
 User application and usage pattern

 The "first" computers:


 Electronic Numerical Integrator And Computer (ENIAC)
 1945
 Program controlled by cables and switches

 Harvard Mark I:
 1944

 Program controlled by punched paper tape

[ CS2106 L1 - AY2021 S1 ]
7
OS for the first computers
 OS Type: User Program
 NO OS
Hardware

 Programs directly interact with hardware


 Reprogram by changing physical configuration of hardware

 Advantage:
 Minimal overhead

 Disadvantage:
 Not portable

 Inefficient use of computer!

[ CS2106 L1 - AY2021 S1 ]
8
Mainframes: The "Big Iron"
 Commonly used by large corporations in 60s, 70s

 Common features:
 No interactive interface
 Accept programs in the form of:
 Paper tape, magnetic tape, punch card
 Support batch processing only
 Very costly
 Usually "rented" instead of owned
 Example:
 IBM 360
 Cost 5 billion US dollars in 1964

[ CS2106 L1 - AY2021 S1 ]
9
OS for Mainframes
 OS Type:
 Batch OS User Program

OS

Hardware
 Batch OS:
 Execute user program (a.k.a job) one at a time
 Load job from media, execute, collect result
 User Job:
 Still interact with hardware directly
 With additional information for the OS
 Resource required
 Job specification
[ CS2106 L1 - AY2021 S1 ]
10
OS for Mainframes: Improvements
 Simple batch processing is inefficient:
 CPU idle when perform I/O

 One possible Improvements:


 Multiprogramming:
 loads multiple jobs and runs other jobs when I/O needs to be done
 Overlaps computation with I/O

 Another development of OS during this period (70s):


 Time-Sharing OS

[ CS2106 L1 - AY2021 S1 ]
11
Time-Sharing OS
 Features:
 Allow multiple users to interact with machine using terminals (teletypes)
 User job scheduling
 Illusion of Concurrency
 Memory management
 Famous Examples:
 CTSS developed at MIT 1960s
 Multics (1970s)
 Considered as the parent of Unix
 Pushed the state of art in virtual memory, security
 Not so different from using Unix servers today but more primitive

[ CS2106 L1 - AY2021 S1 ]
12
Time-sharing OS: Illustration
☺ ☺ ☺ Multiple Users

Programs
UP UP …. UP initiated by user

OS

Hardware

 OS manages the sharing of:


 CPU time, memory and storage

 Virtualization of hardware:
 Each program executes as if it has all the resources to itself

[ CS2106 L1 - AY2021 S1 ]
13
Minicomputer and Unix
 Minicomputer follows the mainframe:
 A "mini" version of mainframe:
 Smaller and cheaper
 Example:
 Digital Equipment Corp (DEC) PDP-11
 Famous OS:
 Unix
 Developed by AT&T employees, including Ken Thompson, Dennis Ritchie,
Douglas McIlroy, and Joe Ossanna
 Ken Thompson and Dennis Ritchie
 Invented the C programming language as well!!

[ CS2106 L1 - AY2021 S1 ]
14
Personal Computer
 Apple II PC:
 First successfully produced mass home computer
 Designed by Steve Wozniak (alone!)

 IBM PC:
 The first generic PC
 PC becoming truly a collection of commodity hardware components
 Leads to dominance of Microsoft OS in PCs: MSDOS then Windows

[ CS2106 L1 - AY2021 S1 ]
15
OS on Personal Computer
 Machine (can be) dedicated to user, not timeshared between
multiple users
 Give rise to personal OS

 Several Models:
 Windows model:
 Single user at a time but possibly more than 1 user can access
 Dedicated machine
 Unix model:
 One user at the workstation but other users can access remotely
 General time sharing model

[ CS2106 L1 - AY2021 S1 ]
16
Why do we need OS?

MOTIVATIONS OF OS

[ CS2106 L1 - AY2021 S1 ]
17
Motivation for OS: Abstraction
 Large variation in hardware configurations

 Example (Hard disk):


 Different capacity (500mb, 320gb, 1.5tb etc)
 Different capabilities:
 Rotation per minutes (RPM)
 Access (read/write) speed
 Etc

 However, hardware in the same category has well defined


and common functionality
 Example (Hard disk): Store and retrieve information
[ CS2106 L1 - AY2021 S1 ]
18
Motivation for OS: Abstraction
 Operating System serves as an abstraction:
 Hide the different low level details
 Present the common high level functionality to user

 The user can then perform essential tasks through operating


system
 no need to concern with low level details

 Provides:
 Efficiency and portability

[ CS2106 L1 - AY2021 S1 ]
19
Motivation for OS: Resource Allocator
 Program execution requires multiple resources:
 CPU, memory, I/O devices etc

 For better utilization of resources, multiple programs should


be allowed to execute simultaneously

 OS is a resource allocator
 Manages all resources
 CPU, Memory, Input/Output devices
 Arbitrate potentially conflicting requests
 for efficient and fair resource use
[ CS2106 L1 - AY2021 S1 ]
20
Motivation for OS: Control Program
 Program can misuse the computer:
 Accidentally: due to coding bugs
 Maliciously: virus, malware etc

 Multiple users can share the computer:


 Tricky to ensure separate user space

 OS is a control program
 Controls execution of programs
 Prevent errors and improper use of the computer
 Provides security and protection
[ CS2106 L1 - AY2021 S1 ]
21
Motivation for OS: Summary
 Manage resources and coordination
 process synchronization, resource sharing
 Simplify programming
 abstraction of hardware, convenient services
 Enforce usage policies
 Security and protection
 User Program Portability:
 Across different hardware
 Efficiency
 Sophisticated implementations
 Optimized for particular usage and hardware
[ CS2106 L1 - AY2021 S1 ]
22
The families of modern OS

OVERVIEW OF MODERN OS

[ CS2106 L1 - AY2021 S1 ]
23
Modern OS: Overview
PC

Mobile Real-Time Embedded

[ CS2106 L1 - AY2021 S1 ]
24
Common Architecture for OS

OS STRUCTURE

[ CS2106 L1 - AY2021 S1 ]
25
Operating System Structures
 We have identified the major capabilities of an OS
 i.e. the specification of the OS

 Let us now consider:


 The best way to provides these capabilities
 i.e. the implementations of the OS

 Operating system structure:


 Organization of the various components
 Important factors:
 Flexibility
 Robustness
 Maintainability
 Performance

[ CS2106 L1 - AY2021 S1 ]
26
Illustration: High level view of OS
PowerPoint Chrome DOTA
User
Mode
User Interface Software

Kernel
Mode Operating System

Hardware Hardware

 Operating System is essentially a software


 Runs in kernel mode: Have complete access to all hardware resources
 Other software executes in user mode
 With limited (or controlled) access to hardware resources
[ CS2106 L1 - AY2021 S1 ]
27
Illustration: Generic OS Components
E
System
User Programs
D
Processes
Library
C C

OS
A B B
Hardware

 A: OS executing machine instructions


 B: normal machine instructions executed (program/library code)
 C: calling OS using system call interface
 D: user program calls library code
 E: system processes
 Provide high level services, usually part of OS

[ CS2106 L1 - AY2021 S1 ]
28
OS as a Program
 OS is also known as the kernel
 Just another program with some special features
 Deals with hardware issues
 Provides system call interface
 Special code for interrupt handlers, device drivers

 Kernel code has to be different than normal programs:


 no use of system call in kernel code
 can’t use normal libraries
 no normal I/O

 Consider this:
 Normal programs use OS: what does OS use? 

[ CS2106 L1 - AY2021 S1 ]
29
Implementing Operating System
 Programming Language:  Common code organization:
 Historically in assembly/machine 1. Machine independent HLL
code 2. Machine dependent HLL
 Now in HLLs: 3. Machine dependent assembly
 Especially C/C++ code
 Heavily hardware architecture  Challenges:
dependent
 “No one else” to rely on for nice
services
 Debugging is hard
 Complexity
 Enormous Codebase

[ CS2106 L1 - AY2021 S1 ]
30
OS Structures
 Several ways to structure an OS:
 Monolithic
 Microkernel
 Layered
 Client-Server
 Exokernel
 etc

 We will cover the first two in details:


 They represent the whole range of possibilities
 Most other approaches are variant or improvement

[ CS2106 L1 - AY2021 S1 ]
31
Monolithic OS
 Kernel is:
 One BIG special program
 Various services and components are integral part
 Good SE principles is still possible with:
 modularization
 separation of interfaces and implementation
 This is the traditional approach taken by:
 Most Unix variants, Windows NT/XP

 Advantages:
 Well understood
 Good performance
 Disadvantages:
 Highly coupled components
 Usually devolved into very complicated internal structure

[ CS2106 L1 - AY2021 S1 ]
32
Monolithic Kernel Illustration
User
User Programs Mode

System Call Interface

Process Memory Kernel


OS Management Management
File System Mode

Device Driver

Hardware

Generic Architecture of Monolithic OS Components


[ CS2106 L1 - AY2021 S1 ]
33
Microkernel OS
 Kernel is:
 Very small and clean
 Only provides basic and essential facilities:
 Inter-Process Communication (IPC)
 Address space management
 Thread management
 etc
 Higher level services:
 Built on top of the basic facilities
 Run as server process outside of the OS
 Use IPC to communicate

 Advantages:
 Kernel is generally more robust and more extendible
 Better isolation and protection between kernel and high level services

 Disadvantages:
 Lower Performance

[ CS2106 L1 - AY2021 S1 ]
34
Microkernel Components

User Programs

Device Process Memory File


Driver Management Management System User
Mode

OS IPC Scheduling Interrupt Handler …

Kernel
Hardware Mode

Generic Architecture of Microkernel OS Components

[ CS2106 L1 - AY2021 S1 ]
35
Other Operating System Structure
 Layered Systems:
 Generalization of monolithic system
 Organize the components into hierarchy of layers
 Upper layers make use of the lower layers
 Lowest layer is the hardware
 Highest layer is the user interface
 Client-Server Model
 Variation of microkernel
 Two classes of processes:
 Client process request service from server process
 Server Process built on top of the microkernel
 Client and Server process can be on separate machine!

[ CS2106 L1 - AY2021 S1 ]
36
Ways of running OSes

VIRTUAL MACHINES

[ CS2106 L1 - AY2021 S1 ]
37
Motivation: Why Virtual Machines
 Operating system assumes total control of the hardware:
 What if we want to run several OSes on the same hardware at the
same time?

 Operating system is hard to debug / monitor:


 How do we observe the working of the OS?
 How do we test a potentially destructive implementation?

[ CS2106 L1 - AY2021 S1 ]
38
Definition: Virtual Machine
 Virtual Machine:
 A software emulation of hardware
 Virtualization of underlying hardware
 Illusion of complete hardware to level above: memory, CPU, hard disk etc…
 Normal (primitive) operating system can then run on top of the virtual
machine

 Also known as Hypervisor


 Two classes of implementations shown next

[ CS2106 L1 - AY2021 S1 ]
39
Type 1 Hypervisor
UP UP UP UP

OS1 OS2 OS3

Type 1 Hypervisor

Hardware

 Type 1 hypervisor:
 Provides individual virtual machines to guest OSes
 eg. IBM VM/370

[ CS2106 L1 - AY2021 S1 ]
40
Type 2 Hypervisor
UP UP UP

Guest OS

Type 2 Hypervisor

Host Operating System

Hardware
 Type 2 hypervisor OS
 Runs in host OS
 Guest OS runs inside Virtual Machine
 e.g. VMware
[ CS2106 L1 - AY2021 S1 ]
41
Summary
 Definition of Operating System

 Roles of Operating System

 Common Operating System families

 Operating System structure

[ CS2106 L1 - AY2021 S1 ]
42
Reference
 Modern Operating System (4th Edition)
 By Andrew S.Tanenbaum
 Published by Pearson

 Operating System Concepts (8th Edition)


 By Abraham Silberschatz, Peter Baer Galvin & Greg Gagne
 Published by McGraw Hill

[ CS2106 L1 - AY2021 S1 ]
43
FYI: MODERN OS FAMILY
(AS OF 2016)

[ CS2106 L1 - AY2021 S1 ]
44
Modern OS: An Overview
 Several dominant desktop OSes:
 Microsoft Windows family
 Unix and its variants
 Mac OS family

 Specialized OSes:
 Real-time OS
 Embedded System OS
 Mobile OS
 Distributed OS

[ CS2106 L1 - AY2021 S1 ]
45
Microsoft OS Family
 16-bit:
 MS-DOS (various versions, v1.0 in 1985)
 Windows 1.X – 3.X, Windows 9X, Windows ME (2000)

 32-bit:
 Windows NT (32-bit, v3.1 in 1994)
 Windows 2000, XP, 2003, Vista, 7, 8, 10 (2015)

 64-bit:
 Windows XP (2005), Vista, 7, 8, 10 (2015)

 Mostly on PC (Intel Processors) platforms


 Proprietary
 some sources available under conditions
 Complex architecture, internals info not widely available
[ CS2106 L1 - AY2021 S1 ]
46
Microsoft OS: Complexity
 Win NT 3.1: (shipped 1993)
 Dev Team Size: 200
 6 Millions LOC (Line of Code)
 Complete build time is 5 hours on ~486/50

 Win 2000: (shipped 1999)


 Dev Team Size: 1400
 29 Millions LOC (about 50Gb of disk space)
 Complete build time: 8 hours on 4-way PIII Xeon 550 with 50Gb disk and 512k
RAM

 Windows 7: (shipped 2009)


 Dev Team Size: ~2500 (split into 25 teams of ~100)
 ~40 Millions LOC

[ CS2106 L1 - AY2021 S1 ]
47
Unix and its Variants
 Many Unix Variants:
 Unix System V versions

 Berkeley System Distribution (BSD)

 Sun Solaris

 SGI IRIX, IBM AIX, Digital Unix, HP-UX, ...

 Linux

 MacOS X (BSD + Mach + Apple)

 Programming Interface (API) mostly the same, fundamentals are


same but small differences exist
 Simple architecture, internals well understood, good documentation, research papers
 Linux + BSD open source
 Non-proprietary, POSIX standards
 Implementations on many processors architectures:
 x86, powerpc, m68k, mips, arm, sparc, alpha, ...

[ CS2106 L1 - AY2021 S1 ]
48
Unix Variants: Rough timeline

"Unix history-simple" by Eraserhead1, Infinity0, Sav_vas - Levenez Unix History


[ CS2106 L1 - AY2021 S1 ] Diagram, Information on the history of IBM's AIX on ibm.com
49
Linux Distributions (Distros)
 Most popular form of linux OS
 E.g. Ubuntu, Fedora, SuSe, BSD, Debian, CentOS, etc

 Essentially a software collection with:


 Linux kernel
 Common software:
 Desktop management, browser, media player etc
 Development tools/libraries
 gnu libraries, compilers etc
 Device drivers
 Package manager
[ CS2106 L1 - AY2021 S1 ]
50
Mackintosh OS Timeline

[ CS2106 L1 - AY2021 S1 ]
51
Characteristics of Modern PC OS
 Multitasking:
 Concurrent execution of programs
 On multiple cores

 Multi/single user:
 Unix usually multi-user
 Windows usually single-user at a time

 Wide range of computer hardware:


 Single PC/notebook
 Shared memory systems with 10-100s of processors
 Machine clusters with 100-1000s of processors
 Distributed computing on Internet with >10K machines
[ CS2106 L1 - AY2021 S1 ]
52
Real Time OS
 OS for computer systems with time constraints:
 periodicity, deadlines

 Examples:
 Critical Systems: aircraft flight system, nuclear power plant, radar system
 Consumer appliances: mobile phones, mp3, video players

 Hard real time:


 Timing requirements must be respected, eg. control system
 Soft real time:
 Some timing constraints can be missed

 May need formally verified systems


[ CS2106 L1 - AY2021 S1 ]
53
Embedded OS
 OS for specialized devices and appliances

 Examples:
 (Older)Smartphones, microwave oven, car, smart cards, game consoles,
etc

 Special consideration required for:


 power usage, real-time requirement and memory limitations

 Usually:
 Not general purpose: cannot run any application
 Cannot be modified: Mostly stored in Read-Only Memory (ROM

[ CS2106 L1 - AY2021 S1 ]
54
Mobile OS
 OS for smartphones, tablets, PDAs, or other mobile devices

 Examples:
 Android, iOS, Windows Phone, etc

 Characteristics:
 Essentially a customised version of PC OS
 Common features: Touchscreen, Cellular, (Video) Camera, etc…

[ CS2106 L1 - AY2021 S1 ]
55
Distributed OS
 OS for computers/processors connected using network
 Loosely or Tightly coupled

 Loosely coupled:
 Autonomous nodes, network may be wide area
 Communication is asynchronous
 Reliability issues:
 communication may not be reliable, nodes may fail
 Resources are distributed
 eg. distributed filesystem, P2P storage

 Tightly coupled:
 Specialized node (e.g. Computing nodes) that shares other resources (e.g. Memory / Harddisk
etc), nodes in close proximity
 Examples:
 Tembusu2 cluster compute nodes:
 ~100 Intel Xeon nodes running CentOS

[ CS2106 L1 - AY2021 S1 ]
56

You might also like