0% found this document useful (0 votes)
28 views39 pages

CSE 325-Operating System Lec1-3

This document provides an overview of the major components of an operating system. It discusses topics like system architecture, interrupts, I/O management, memory management, and resource allocation. The goal of the document is to introduce the key principles and techniques for designing and implementing operating systems.

Uploaded by

thrafi.reserve
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)
28 views39 pages

CSE 325-Operating System Lec1-3

This document provides an overview of the major components of an operating system. It discusses topics like system architecture, interrupts, I/O management, memory management, and resource allocation. The goal of the document is to introduce the key principles and techniques for designing and implementing operating systems.

Uploaded by

thrafi.reserve
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/ 39

CSE 325-Operating System

Lecture: 1-3

Computer Science and Engineering

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:

• Identify different components of Operating System.

• Describe different methods of resource management.

• Apply resource management techniques for resource


constrained problems.

• Expose memory organization and I/O management


techniques.
Text book

1.5
Operating System Concepts – 8th Edition
Lecture 1: Introduction
Objective

Overview of the major OS components.


Components of a Computer System

services to the user


(e.g. Web Browser. MS
Office)

services to the hardware


(Disk Driver, assembler,
Linker, loader)
Microarchitecture- Computer Organization
■ The way a given instruction set
architecture (ISA) is implemented
on a processor

The ISA includes :


- the execution model,
- processor registers,
- address and data formats.

The microarchitecture includes:


- the parts of the processor and
- how these interconnect and
- interoperate to implement ISA.

Silberschatz, Galvin and Gagne ©2009


0
What is an Operating System?
■ A program that acts as an intermediary betn a user & H/W

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

The Computer System


(H/W & S/W)

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.

One goal of the operating system is to increase the


utilization of resources.

Utilization =useful time/total time


For example, the OS should avoid wasting CPU time because the
disk is rotating or wasting switching among tasks. Waiting for I/O.

■ 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

Life with an OS Life without an OS


file = open
(“test.txt”, • Blocks, platter, track,
O_WRONLY); and sector
write (file, “test”,
4); close (file); • Where is this file on disk?
Which platter, track, and
sectors?

• Code needs to change on a


different system

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

020-021 Interrupt Controller


040-043 Timer
3D0-3DF Graphics Controller
Memory mapped I/O: No Special Instruction
load/store instructions
Controller registers/memorymaps in physical address
space. I/O accomplished with load and store instructions

Example: load 0xFFFF0000, AL


1-Ready
(Control) load 0xFFFF0004, BX 0-not

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

In brief: Interrupt is asynchronous, and polling is synchronous


Interrupts Work
requester
Service provider
Interrupts Device
CPU
Status bits
IE=0 / or we
can say a flag
Not
enable Masked Interrupts
Short periods of time

CPU Device
Status bits Interrupts
IE=1/ or we
can say a
flag
Enable

Sends acknowledgement, disable interrupts IE=0, and calls


Interrupt Service routine
Alternative: Interrupt Vector

IE =1

Mouse click IRQ

IC

-crtl+Alt+Del, restart, power off


IRQ
IE =1

CPU sets CPU IE =1, Device can send interrupt (Not Masked)
Different Interrupts

An operating system is interrupt driven

Non-Maskable • It does not check IE flag or priority.


(hardware)
Maskable • It checks IE flag or priority. If IE=1, the processor
(hardware) acknowledges the interrupt..

Normal • a programmer initiated and expected transfer of control to


interrupt a special handler routine.
• user program can ask for an operating system service
(Software
• unconditional –control always transfer to pre-defined
Interrupt) procedure.
Exception • automatically generated unexpected events occur in
(Software Interrupt) response to some exceptional condition.
Operating System Concepts – 8th Edition • illegal program
1.23 actions that generate an interrupt.
Silberschatz, Galvin and Gagne ©2009
DMA – Direct Memory Access

- High Speed, I/O device

■ 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

System call SHELL

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,

• Linux is a kernel as it does not include applications-


file-system utilities, windowing systems and graphical
desktops, system administrator commands, text
editors, compilers etc.
• So, various companies add these kind of applications
over Linux kernel and provide their operating system
like ubuntu, centOS, redHat etc.
An Operating system has two parts: kernel and shell
shell (command interpreter): Part of OS

• Serves as the interface between user and kernel.

• User enters commands via shell in order to use the kernel service.

Type of shells

Graphical User Interface (GUI) Command line interface (CLI)


Windows/Mac OS– 8th Edition
Operating System Concepts Dos/Linux Silberschatz, Galvin and Gagne
©2009
OS Protections
Transition from User to Kernel Mode
Dual-mode operation allows OS to protect itself and other
system components.
• User mode
• Kernel/Supervisor/Monitor/System Mode.

Mode bit @ Process Status Word (PSW)-Register


• Provides ability to distinguish when system is running user code or
kernel code.
• Some instructions designated as privileged, only executable in kernel
mode. Example: load/save from protected memory, initiate I/O etc.
• System call changes mode to kernel, return from call resets it to user.

1.30 Silberschatz, Galvin and Ga


g System Concepts – 8th Edition
need more hardware support.
Simple Model for Memory Protection

To obtain true protection,


• The goal is to make sure that, for example, process 2 can't go outside
of the 4K-6K region.
• This requires hardware support -- we can't do it in software alone.
• The simplest model is to add two registers: BASE & LIMIT (assigned by OS)
• This is the simplest model, most computers are more complex.

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.

Punched the program into CARDS

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

Wasting time while operators were walking around


the machine room
Supervisor/Operator Control
CR ----> MT MT ----> CPU CPU ----> LP IBM 7094

• 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

Process 1 Process 2 Process 3


I1 I2 I3
C1 C2 C3
O1 O2 O3
2 4 2 2 3 2 2 7 2 26

I= Input
OS
C=Computation
User Program O=Output

OS resides in memory and the task was simple


- transfer control from one job to another

Problem: Low CPU utilization;


- During I/O CPU is idle. WHY?
Batch Systems - Issues
• Solutions to speed up I/O:

• Offline Processing (Previous)


load jobs into memory from tapes,
card reading and line printing are done offline.

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.

Allows overlap - I/O of one job with computation of another.


Introduces : job pool (Queues-job queue, ready queue)
– allows OS to choose next job to run so as to increase CPU utilization
Multiprogramming
■ Use interrupts to run multiple programs simultaneously
• When a program performs I/O,
instead of polling, execute another program till interrupt is received.
• Efficiency

■ 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.

■ Like multiprogramming, but timer device interrupts after a quantum


(timeslice).
Interrupted program is returned to end of FIFO
Next program is taken from head of FIFO
Time Shared Processing

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

Concept of Virtual Processors


Time Slice =2
Virtual Machines
VMware
Reading Materials

■ Galvin : 1.1, 1.2, 2.1, 2.2, 2.5, 3.3, 3.5.3,3.6


■ Galvin: 13, 13.2.1,13.2.2
End of Lecture 1-3

You might also like