CSE 325-Operating System Lec1-3
CSE 325-Operating System Lec1-3
Lecture: 1-3
1.1
Course Description
■ This course introduces the principles and techniques for the design
and implementation of operating systems:
• interrupts,
• computer resource management
memory management,
processor management,
I/O management,
file management,
process management and
security management,
• inter process communication.
■ Additionally topics are:Multithreaded OS,and Concurrent
computations.
■ This course includes a project implementation.
2
Course Outcomes
Successful completion of this course, you will be able to:
1.5
Operating System Concepts – 8th Edition
Lecture 1: Introduction
Objective
USER
- Performs specific function
-Directly from user Database progs, Image editing
/application prog Paint, Web browser etc
Coordinates
Operates,
Controls operations Printer, Mouse, Hard Disk etc
GOALS:
» Convenient to use
» Execute user programs & make solving user problems easier
» Use H/W in an efficient manner
Operating System Definition
■ OS is a resource allocator
• Manages all resources
• Decides between conflicting requests for efficient and fair resource use.
■ OS is a control program
• Controls execution of programs to prevent errors and improper use
of the computer. e.g. Memory Protection.
An example comparing life with/without OS
13
1.1
3
How does a program execute?
■ C Program ■ Assembly ■ Executable
int A[2]; int C[2]; int B[2]; Load $t0, [A] 0001…………………..00
P=A[0]; Load $t1, [B] 0000…………………..01
Q=B[0]; ADD $t3, $t0, $t1 00011…………………11
C[0]=P+Q; STORE $t3, [C] 100…………………….11
First.c
First.asm le
m b
First.o Asse
■ Memory
PC=0 0 0001…………………..00
IR= 0001…………………..00 4 0000…………………..01
8 00011…………………11
12
1.12
100…………………….11
Galvin, OS Concepts, Chapter 13.2.3
■ DMA
Transfer
Computer System
I/O Mapped: Special I/O
instruction in/out
instruction
Example from the Intel architecture: out 0x21,AL
000-00F DMA Controller
Galvin, OS Concepts, Chapter 13.2
32 bits (Data) IE R
32 bits Data
Polling VS
Interrupt
Both are methods to notify processor that I/O device needs attention
Polling
simple, but slow
processor check status of I/O device regularly to see if it needs attention
similar to checking a telephone without bells!
Interrupt
fast, but more complicated
Interrupt is better if processor has other work to do
processor is notified by I/O device (interrupted) when device needs attention
similar to a telephone with bells
CPU Device
Status bits Interrupts
IE=1/ or we
can say a
flag
Enable
IE =1
IC
CPU sets CPU IE =1, Device can send interrupt (Not Masked)
Different Interrupts
■ DMA Transfer
Galvin, OS Concepts, Chapter 13.2.3
Device
Driver
2/3
DMA X
Controller bytes
-Status
-Source 4
-Destination
-Length
Block of data
How does user communicate with OS
User
GUI
KERNEL
KERNEL CLI OS
KERNEL
Monolithic Microkernel
CPU
1) Polling
2) Interrupt
Hardware
The Kernel and The Shell
An Operating system has two parts: kernel and shell
KERNEL (resides in main memory):
• is the heart and soul of an OS. Useful applications and utilities are
added over the kernel, then the complete package becomes an OS.
• directly controls the computer hardware by performing OS services
using specific system calls or requests or hardware interrupts.
• hides the hardware details from the user and application programs.
Example,
• User enters commands via shell in order to use the kernel service.
Type of shells
In order to keep process 2 within it's 2K box, we can do one of two things:
Option #1: Option #2:
Set BASE = 4K Set BASE =
4K more frequent scheme
Set LIMIT=2K LIMIT = 2K(6K-4K)
A memory access is legal, A memory access is legal,
if BASE <= X < BASE + LIMIT, if 0 <= X < LIMIT,
where X is the actual memory address where X is the offset
address = BASE + X
Kernel Types
Monolithic Kernel Micro Kernel
All the parts of a kernel Only the important parts are in kernel
- Scheduler, file system, - IPC, basic scheduler, basic memory
memory,
device drivers etc. are in one unit management, basic I/O primitives etc.
within the kernel.
-Others (including device drivers) are in user
space.
Signals & sockets to ensure IPC -Message Passing system to ensure IPC
Advantages Advantages
- Faster processing - Crash resistant
- Smaller size
- Portable
- No need recompiling(for a new feature)
Disadvantages Disadvantages
-Crash insecure -slower processing due to additional
-Porting Inflexibility message passing
-Add a new feature needs recompiling -2%-4% slower
whole
-Kernel size explosion
DOS, Unix, Linux Symbian, Mac OS X, MINIX, Windows NT
,
Lecture 2: OS Evaluation
Computers were in Universities / Large companies
Programmers wrote programs (FORTRAN/ Assembly)on
paper.
Input
Room Operator brings
Cards from input room
and read in computer
Read in
Operator tears off the output
And carry it over to the output room
FORTRAN Output
Compiler Room
From Cabinet
• Problems
Long turnaround time - up to 2 DAYS!!!
– Debugging…
Low CPU utilization
– I/O and CPU could not overlap;
From John Ousterhout slides
– slow mechanical devices.
38
Offline Processing
Operating System Concepts – 8 th
Edition Tanenbaum@Modern
Silberschatz, Galvin and Gagne OS
©2009
BATCH Processing (One by
one) Similar jobs
I= Input
OS
C=Computation
User Program O=Output
Buffering
• Online Spooling (simultaneous peripheral operations on-line)
A type of buffering, to disk (present)
– Random access device, unlike tape
Use disk as large storage for reading as many input files as possible and
storing output files until output devices are ready to accept them.
■ Requires:
• secure memory [will learn @ final]and I/O for each program.
• intervention, if program loops indefinitely.
• CPU scheduling to choose the next job to run.[will learn later]
I= Input
Multiprogrammed Processing C=Computation
O=Output
I1 C1 O1
Process 1
2 4 2
I2 C2 O2 8 units
Process 2
2 3 2 Time efficiency
I3 C3 O3
Process 3 …..
2 7 2
2 4 3 7 2 = 18
OS supports
-SPOOL
-Overlapping I/O and CPU [I/O of one job CPU of another job]
- Interleaving – mixed of CPU and I/O operations of several programs
and alternating between them
Timesharing
■ A variant of multiprogramming.
■ Supports multiple users at the same time
■ Programs queued for execution in FIFO order.
■ A technique to protect CPU.
I1 C1 C1 O1
Process 1 … ….
2 2 2 2
I2 C2 C2 O2
Process 2 … …
2 2 1 …2
I3 C3 C3 C3 C3 O2
… …
Process 3
2 2 2 2 1 2
22 2 2 2 3 2 1 2 =18