0% found this document useful (0 votes)
31 views64 pages

(OS'25) Lecture 1

Uploaded by

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

(OS'25) Lecture 1

Uploaded by

ziadsameh071
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 64

Operating Systems

Dr Hanan Hindy
[email protected]

*Lecture slides are modified by Dr. Ahmed Salah * 1


2
Course Team
Instructor : Dr. Hanan Hindy
– Email: [email protected]

• TAs: Razan Bayoumi, Mohamed Raafat


– Emails:
[email protected]
[email protected]

3
Main Textbook
Text Book: Operating Systems Internals
& Design Principles 9th Ed, William
Stallings.

4
Grades Distribution
• Total Grade: 100
– Final Exam: 50
– Year Work: 50

• Year Work:
– Midterm Exam: 15
– Practical Exam: 20
– HandsOn: 10
– Quiz: 5
5
General Rules and Guidelines
• Please be on time.
• Missing deadlines is not allowed.
• Plagiarism is NOT acceptable and NOT tolerable.
• Any misconduct or misbehavior is NOT acceptable and
NOT tolerable.
• Never hesitate to ask.
• Don’t forget to enjoy learning.

6
General Rules and Guidelines
Weekly office hours
• Ask any question….
• Issues…
• Feedback…

7
Course Goals
• Introduce you to operating system concepts:
• It is hard to use a computer without interacting with OS.
• Understanding the OS makes you a more effective programmer
• Cover important systems concepts in general
• Caching, concurrency, memory management, I/O, protection, ..
• Teach you to deal with larger software systems.
Warning: Many people will consider course hard.
Key: Take your own experience  It is FUN!
Follow lectures & tutorials WEEKLY
What’s OS?
• Chose one:
o Windows
o Hardware
o User application
o Software program
What’s OS?
A master control software that
• runs other programs.
• Acts as an interface between (H/W) and the user applications
(S/W) Applications Hardware
Operating System

Hard
Word K e r n eMemory
E-mail l Disk

Manages Manages
Game Browser
Applications Monitor
Hardware Printer

… … … …

Its main part, the "kernel," which resides in memory at


all times.
What’s OS?

Applications Operating System Hardware


Hard
Word E-mail Kernel Memory
… Disk

Inter-Process
Manages Manages Communication
Game Browser Applications Hardware Monitor Printer
I/O Management

File Management
… … … …
Memory
Management

CPU Scheduling
OS kernel runs in privileged mode

Creates/
Provides
deletes
access to
processes
hardware
What about applications?
• Most software runs as user-level processes.

• Applications can invoke kernel through system calls


– Special instruction transfers control to kernel
System Call Example
What makes
Operating Systems
Exciting and
Challenging?
Why Studying OS?

USE COMPUTER MORE LEARN SYSTEM DESIGN ISSUES,


EFFICIENTLY CAN BE APPLIED ELSEWHERE
Goal & Syllabus
KNOW HOW the Operating System do its Main Jobs?

Solve competition on… LA


Bs
P art I :P
art
ABs: II
L
Shared
Memory CPU
Resource

Physical Virtual Single Critical


Multi CPU Deadlocks
Mem Mem CPU Sections
(CH.10) (CH.6)
(CH.7) (CH.8) (CH.9) (CH.5)
Learn More…
1. [Berkeley] CS162: Videos

2. [UMass] CS377: Videos

3. [Stanford] CS140: Lecture Notes /


https://www.scs.stanford.edu/24wi-cs212/notes/
GENERAL NOTE
Hidden Slides are Extra Knowledge
Not Included in Exams
Computer System Overview

Dave Bremer
Otago Polytechnic, N.Z.
©2008, Prentice Hall
A Computer’s Basic Elements
• Processor
• Main Memory
• I/O Modules
• System Bus
Instruction Execution
• A program consists of a set of instructions stored in
memory
• Two steps
– Processor reads (fetches) instructions from memory
– Processor executes each instruction
Basic Instruction Cycle
Instruction Fetch
and Execute
• The processor fetches the instruction from memory
• Program Counter (PC) holds address of the instruction to
be fetched next
– PC is incremented after each fetch
Interrupts
• Interrupt the normal sequencing of the processor
• Provided to improve processor utilization
– Most I/O devices are slower than the processor
– Processor must pause to wait for device
Common Classes
of Interrupts
Instruction Cycle
with Interrupts
Operating System Overview

Dave Bremer
Otago Polytechnic, N.Z.
©2008, Prentice Hall
Operating System

• A program that controls the execution of application prog’s


• An interface between applications and H/W
• Main objectives of an OS:
1. Make a computer more convenient to use
2. Use resources in an efficient manner
3. Ability to evolve
1) OS as User/Comp. Interface
• Program development
– Editors and debuggers.
• Program execution
– OS handles scheduling of numerous tasks required to execute
a program
• Access I/O devices
– Each device will have unique interface
– OS presents standard interface to users
1) OS as User/Comp. Interface
• Controlled access to files
– Accessing different media but presenting a common interface
to users
– Provides protection in multi-access systems
• System access
– Controls access to the system and its resources
1) OS as User/Comp. Interface
• Error detection and response
– Internal and external hardware errors
– Software errors
– Operating system cannot grant request of application
• Accounting
– Collect usage statistics
– Monitor performance
The Role of an OS
• A computer is a set of resources for the movement,
storage, and processing of data.
• The OS is responsible for managing these
resources.
2) OS as Resource Manager
• The OS functions in the same way as an ordinary
computer software
– It is a program that is executed by the CPU
• Operating system relinquishes control of the processor
2) OS as Resource Manager

RAM Devices

CPU(s)

Manage them
EFFICIENTLY
3) Evolution of Operating
Systems
• Operating systems will evolve over time
– Hardware upgrades plus new types of hardware
– New services
– Fixes
Uniprogramming/Multiprogramming/
Multiprocessing
Uniprogramming
• ~ Single App. System
• Processor must wait for I/O instruction to complete before
proceeding

• Inefficient use of resources


Multiprogramming
• When one job needs to wait for I/O, the processor can
switch to the other job
Multiprogramming
Multiprogramming vs. Multiprocessing
Multiprogramming:
only one process can execute at a
time;
• meanwhile all other processes
are waiting for the processor.

Multiprocessing:
more than one process can be
running simultaneously, each on a
different processor.
Major Achievements
1. Processes
2. Memory management
3. Information protection and security
4. Scheduling and resource management
5. System structure
1) Process
• Fundamental to the structure of OS’s
• A process is:
– A program in execution
– An instance of a running program
– The entity that can be assigned to and executed on a processor
– A single sequential thread of execution, a current state, and an
associated set of system resources.
Process Description and Control

Dave Bremer
Otago Polytechnic, N.Z.
©2008, Prentice Hall
Requirements of OS
• Fundamental Task: Process Management
• The Operating System must
1. Interleave the execution of multiple processes
2. Allocate resources to processes
3. Protect the resources of each process
4. Enable sharing among processes
5. Enable synchronization among processes.
What is a “process”?
• A program in execution
• An instance of a program running on a computer
Process Elements
• A process is comprised of:
1. Program code (possibly shared)
2. A set of data
3. User stack (for function calls)
4. User heap (for dynamic allocations)
5. Process Control Block
• Attributes describing the state of the process
Process Elements
• Process Control Block include WHAT?
– Identifier
– State
– Priority
– Program counter
– CPU Registers
– Memory pointers
– I/O status information
– Accounting information

Trace of the Process
• The behavior of an individual process is shown by listing
the sequence of instructions that are executed
• This list is called a Trace
• Dispatcher is a small program which switches the
processor from one process to another
Process Execution
• Consider three
processes being
executed
• All are in memory
(plus the dispatcher)
• Lets ignore virtual
memory for this.
Two-State Process Model
• Process may be in one of two states
– Running
– Not-running
Queuing Diagram

Etc … processes moved by the dispatcher of the OS to the CPU then back
to the queue until the task is competed
Problem of 2-State Model!
• “Not-Run” state includes:
1. Blocked on I/O
2. Time-out (Ready to execute again)

• WHAT’s the problem of this?


– dispatcher need to scan the list looking for a ready process.
Five-State Process Model

readyexit nullnew
runningblocked
blockedready
runningready
readyrunning
runningexit
newready
Terminated by its parent Wait Process
Reached
Waiting
Moved
on
Terminated
loaded
ato
eventinisallowed
request
max
CPU iscreated
memory
to
by
occurred
(e.g.
execute
OS OS,
time
Or parent is terminated Notcompleted
Either
Preempted
Number loadedby in
resource,
of them OS memory
I/O)
or
istousually
Aborted
allow
higher-priority
limited by process
OS
WHY?
Voluntarily release control
to OS (e.g. background proc)
Using Two Queues

What’s the Problem here?


each event takes O(N) searching for the
waiting process
Multiple Blocked Queues
Problem of 5-State Model!
• CPU is faster than I/O 
– All processes could be waiting for I/O
– Bad utilization of CPU
• SOLUTION
– Swap these processes to disk to free up more memory and use
CPU on more processes
– Called suspend state when swapped to disk
– Two new states
• Blocked/Suspend
• Ready/Suspend
Suspended Processes
• Processor is faster than I/O so all processes could be
waiting for I/O
– Swap these processes to disk to free up more memory and use
processor on more processes
• Blocked state becomes suspend state when swapped to
disk
• Two new states
– Blocked/Suspend
– Ready/Suspend
Two Suspend States
References
• Chapter 2
– Section 2.1 (OS Objectives & Functions)
– Section 2.2 (OS Evolution)
– Section 2.3 (Major Achievements)
– Section 3.1 (What’s a Process?)
– Section 3.2 (Process States)
– Section 3.3 (Process Description)

• Berkeley CS162
– L13: Address Translation & Paging
– L14: Paging (cont.) & Segmentation
– L03: Abstraction1 - Processes & Threads

You might also like