(OS'25) Lecture 1
(OS'25) Lecture 1
Dr Hanan Hindy
[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
… … … …
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.
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
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
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)
readyexit nullnew
runningblocked
blockedready
runningready
readyrunning
runningexit
newready
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
• Berkeley CS162
– L13: Address Translation & Paging
– L14: Paging (cont.) & Segmentation
– L03: Abstraction1 - Processes & Threads