Lecture 01 Intro To OS
Lecture 01 Intro To OS
Lecture 01 Intro To OS
Operating Systems
Lecture 01
Introduction to Operating Systems
Fall 2018
Arif Butt (PUCIT)
Note:
Some slides and/or pictures are adapted from course text book and Lecture slides of
• Dr Syed Mansoor Sarwar
• Dr Kubiatowicz
• Dr P. Bhat
• Dr Hank Levy
• Dr Indranil Gupta
• Course Outline
– Computing environments
2
Course Information
• Required Textbook: Operating System Concepts,
10th Edition Silbershatz, Galvin, Gagne
• Grades Website: http://online.pucit.edu.pk
• Resources Website: http://arifbutt.me
• Prerequisites : Nill
• Corequisites : CMP223, CMP210
• Office: New Faculty Building # G7
• Students Counseling hours:
– Mentioned on http://arifbutt.me
• Teaching Assistant info:
– Mentioned on http://arifbutt.me
• 24 hour turnaround for email: [email protected]
3
Course Information
Visit Course Web Site for following information:
http://www.arifbutt.me
– Lecture Slides
– Video Lectures (OS with Linux)
– Quizzes + Assignments + Labs
– Announcements
– Teaching Assistants
– SOPs and Course related Policies
– Misc Resources
4
Lecture Format
• Please come to class (in time)
• I will mark the attendance in the first five minutes. Students
with more than eight absents will not be allowed to sit in the
class and their names will be struck off the register. (Be
watch full)
• To Help you understand important and hard OS concepts
please read the relevant textbook sections before lecture
• Exam, quiz, PA and HW questions could be from anywhere in
the lecture slides, textbook sections covered, reading
material provided. Your best strategy is to play it safe –
read all material referred to in lecture
• Make sure you also
– Periodically check lecture notes on course web page
– Utilize the student counseling hours
5
Lab Format
• Please come to Labs (in time)
• There are one or two video lectures associated
with each lab, uploaded on course web site. Please
listen to those lectures twice before coming to lab
• To Help you understand important and hard OS
concepts please read the relevant Chapters of
UNIX The Textbook by Dr Mansoor Sarwar
• Quizzes might be taken in class or in Lab, so don’t
miss
• Contents covered in the Lab will come in the
Quizzes as well as in the Mid and Final exams
6
Who cares to get an A?
• Final exam: 40%
• Mid-exam: 35%
• Sessionals: 25%
– Surprise Quizzes: 10%
– Assignments (PA/LW/HW): 5%
– Lab : 10%
7
Surprise Quizzes
• There will be surprise quizzes, given at the start
of a lecture, during any lecture. The total
number of quizzes could be anywhere between 4
and 40.
• NO LATE or MAKEUP SURPRISE QUIZZES,
under any circumstances whatsoever
• Surprise quizzes are completely individual
efforts.
• Your best strategy is to play it safe – attend
every lecture and do the reading/programming
assignments
8
Cheating Policy
• Academic integrity
11
Programming Assignments
&
Linux Shell Commands
12
No Pains No Gains
13
Outline
14
Operating System
Overview
15
Operating System–An Abstraction
16
Operating System–An Abstraction
19
Operating System–An Abstraction
20
Computer System Organization
21
Computer System Organization
• One or more CPUs, device controllers connect
through common bus providing access to shared
memory
• Concurrent execution of CPUs and devices
competing for memory cycles
22
Computer System Operation
• I/O devices and the CPU can execute concurrently
• Each device controller is in charge of a particular
device type
• Each device controller has a local buffer
• Each device controller type has an operating
system device driver to manage it
• CPU moves data from/to main memory to/from
local buffers
• I/O is from the device to local buffer of
controller
• Device controller informs CPU that it has finished
its operation by causing an interrupt
23
What Is an OS?
“Code” that:
• Sits between programs & hardware
• Sits between different programs
• Sits betweens different users
But what does it do?
Provides an orderly and controlled allocation of the
processor(s), memory(ies) and I/O devices among the
various programs competing for them
Loose analogy:
– Government: creates and enforces laws that govern
resources (money, land, houses, vehicles, oil, etc.)
but allows citizens to have freedom with using the
resources (as long as the citizen obeys laws)
24
What Is an OS? (…)
Resources Services
• Allocation • Abstraction
• Protection • Simplification
• Reclamation • Convenience
• Virtualization • Standardization
25
What is an OS? (…)
Objective of an OS is to Tame the h/w so that people can program and can get something useful out of it.
27
Interrupt
• Virtually all computers provide a
mechanism by which other modules (I/O,
memory) may interrupt the normal
sequencing of the processor.
Answer
• Provided to improve processor utilization
The
Phone
• Most I/O devices are slower than the .
.
Resume
28
Sub Routine Call vs Interrupt
Sub routine Call Interrupt
• Occur due to an internal event
• Occur due to execution of
(setting of flag) or an
an instruction
external event (key press)
• Address of subroutine is • Address of ISR is determined
determined by the address by h/w (vectored / non
part of an instruction vectored interrupt)
• Other than contents of PC,
• Stores only the contents of
store the state of processor
PC (return address)
as well (all processor
registers)
29
Interrupts, Traps and Signals
• Interrupt. An event generated by an I/O
device to get the attention of CPU and control
goes to the OS. State of the CPU is saved, ISR
is executed and then state of CPU is restored.
• Trap. An event generated by CPU and control
goes to the OS. Normally when an instruction is
executed that may cause a division by zero or Answer
The
protection error. State of CPU is not saved and
Phone
.
TSR is executed.
.
• Signal. A notification given to a process by the .
.
OS because the process did something, the .
user did something, one process wants to tell .
34
How to protect Processes from one another?
Need three important things:
• Protection of I/O devices
• Every process should not have access to every device
• Protection of memory
• A process should not access another process address
space
• Preemptive switching from task to task
• Use of timer
• Must not be able to disable timer from user code
35
I/O PROTECTION
• All I/O instructions are privileged instruction, no user
process can execute an I/O instruction directly. If he/she
is permitted he/she can always overwrite/delete some
ones else data
• I/O is done using system call. A way that an OS allows a
user process to invoke an operation such as an I/O
operation e.g. opening and reading a file
• Following lines of Assy code displays xter ‘A’ on monitor screen
MOV DL, ‘A’ ;Place xter to be displayed in DL
MOV AH, 02 ;Place appropriate svc no / system call no in AH
INT 21h ;Call the interrupt
• Following lines of Assy code input a xter and place it in AL register
MOV AH, 01
INT 21h
36
Memory Protection
• Process Address Space. Region in the main
memory that a process can legally access is known
as its address space. A process must not be
allowed to go outside its address space
• Implementation. CPU uses two registers to
determine the range of logical addresses a
program may access
• Base Register holds the smallest/starting
address of the Address Space assigned to a
process
• Limit Register contains the size of the address
space allocated to the process
37
Memory Protection (cont…)
38
Memory Protection (cont…)
39
CPU Protection
• In multiprogramming or time sharing OS, multiple
processes are running at a time and we want to make sure
that the CPU must not stay with a process for an infinite
amount of time
• Implementation.
• Timer interrupts computer after a specified period to ensure OS
maintains control
• Timer (counter register) is loaded with a predetermined value and
decremented every clock tick
• When the timer reaches the value 0, an interrupt occurs and an
ISR is executed to switch CPU to another process
• How Timer is loaded? This is also a privileged instr, because no
one other than the admin should be allowed to assign a time slice
to various processes
40
Operating System Services
Some important tasks a kernel performs are:
• Process management and IPC
• Signal handling
• Synchronization and Deadlock management
• Memory management
• Mass storage management and File management
• Information management
• User management and security
• Networking services (wired + wireless)
Two methods by which a program can make requests for
services from the Kernel:
• By making a system call
• By calling a library routine that makes use of this system
call
41
Types of
Operating Systems
42
Network Operating Systems
• In NOS, the users are aware of the existence of multiple
computers and can log in to remote machines and copy files
from one machine to another
• Each machine runs its own local OS and has its own local
user(s)
• A NOS is a collection of s/w and associated protocols that
allow a set of autonomous computers which are inter-
connected by a computer NW to be used together in a
convenient and cost effective manner
• Remote Login. Each user normally works on his/her own system; using a
different system requires some kind of remote login, instead of having
the OS dynamically allocate processes to CPU
telnet pucit.edu.pk
• Remote File Transfer. Users are aware of where their files are kept
and must move file from one system to another with explicit file
transfer commands instead of having file placement managed by OS
ftp pucit.edu.pk
43
Distributed OS
• A Distributed System is a collection of independent
computers that appears to its users as a single
coherent system
47
Computing Environment (…)
■ Client-Server Computing
50
Computing Environment (…)
Multiprocessor Systems
• Also called parallel systems or tightly coupled
systems
• Multiple CPUs in a single entity, comm using system
bus
• Advantages
• Increased throughput
• Increased reliability (Graceful degradation, fault
tolerance)
• Saves money by not duplicating power supplies,
housings, and peripherals
• Disadvantage
• More complex in both hardware and software
than uni-processor systems
51
Computing Environment (…)
Types of Multiprocessor Systems
55
We’re done for now, but Todo’s for
you after this lecture…
• Go through the slides and Book Sections: 1.1-1.12
• Go through Unix The Text Book Chapters 0 - 3
• Get a Secure Shell account in the Lab. Log in using your SSH
account in lab and try executing some basic shell commands.
• Copy following resources from course web site
• Video Lectures Series on Linux by Arif Butt
• UNIX The Text Book
• ITC Lecture Slides (Basic Linux Commands)
• Basic Linux Tutorial
• If you are using MS Windows at your home PC, please dual boot
it with some Linux distribution or install Linux in virtual
environment using Virtual Box