+ All Categories
Home > Documents > This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous...

This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous...

Date post: 26-Aug-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
42
Course Introduction (contd.): Operating Systems Indranil Sengupta (odd section) and Mainack Mondal (even section) CS39002 Spring 2019-20
Transcript
Page 1: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

Course Introduction (contd.): Operating Systems

Indranil Sengupta (odd section)and Mainack Mondal (even section)CS39002

Spring 2019-20

Page 2: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

The website is up!

http://www.facweb.iitkgp.ac.in/~isg/OS/

Page 3: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

The story so far

• What is an OS

• What are the two goals of an OS

• Two key parts of OS

• Interrupt driven functionality of OS

Page 4: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

Today’s class

• A brief historical overview of OS• Batch processing systems• Multiprogramming• Multitasking• Some practice problems

• Today’s OS (multitasking, like Unix)• Dual mode of operation• Uses of timer

Page 5: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

A brief history of OS

Page 6: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

The beginningComputers == which performs computational tasks

Page 7: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

The beginningComputers == which performs computational tasks

Give a job: It will give you output

Page 8: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

The beginningComputers == which performs computational tasks

Give a job: It will give you output

What if you had to compute multiple jobs?

Page 9: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

First computers were similar

• Thus the operating system was simply designed• Batch processing operating system• One job executed at a time• only one job in memory at one time and executed (till

completion) before the next one starts

Page 10: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

First computers were similar

• Thus the operating system was simply designed• Batch processing operating system• One job executed at a time• only one job in memory at one time and executed (till

completion) before the next one starts

• https://youtu.be/YXE6HjN8heg?t=308

OS

User program

Jobs waiting

Page 11: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

Problem with batch processing

A job has to wait for another to finish

Led to very high wait times for the following jobs

CPU was not doing anything at that time

Page 12: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

Problem with batch processing

A job has to wait for another to finishLed to very high wait times for the following jobsCPU was not doing anything at that time

Insight: Input/Output from periphrals were very slowYour job has to wait forever when my job is simply reading the necessary data from peripheral devices

Page 13: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

SPOOLing

Simultaneous peripheral jobs online (SPOOL)Only start jobs when all required data is readOR, Send data output to a SPOOL buffer / virtual device

Page 14: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

SPOOLing under the hood

CPU

Page 15: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

SPOOLing under the hood

CPU

SPOOL buffer

Page 16: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

SPOOLing under the hood

I/O processor

CPU

SPOOL buffer

Page 17: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

SPOOLing under the hood

Input device I/O processor Output Device

CPU

SPOOL buffer

Page 18: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

SPOOLing bring in important concepts• Addition of I/O processors• Read/Write becomes faster

• Concept of virtual device• Batch of jobs• CPU-bound and I/O bound jobs

Page 19: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

SPOOLing bring in important concepts• Addition of I/O processors• Read/Write becomes faster

• Concept of virtual device• Batch of jobs• CPU-bound and I/O bound jobs

A special form of multiprogramming

Page 20: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

Multiprogramming

• Multiple jobs loaded into memory at the same time and job scheduler selected a job (say job A)• If a big I/O request come for job A, then A’s context is

stored away and job B is started• Once A’s I/O finished restrore A

Page 21: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

Multiprogramming

• Multiple jobs loaded into memory at the same time and job scheduler selected a job (say job A)• If a big I/O request come for job A, then A’s context is

stored away and job B is started• Once A’s I/O finished restrore A

• Storing context (current program state)• Need memory protection• Need privileged mode

Page 22: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

Multiprogramming: Issue

• Relies on the fact that job B can start when job A is doing I/O

• For multiprogramming to work: a good mix of CPU and I/O bound jobs

• What if its not the case?

Page 23: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

Today’s class

• A brief historical overview of OS• Batch processing systems• Multiprogramming• Multitasking• Some practice problems

• Today’s OS (multitasking, like Unix)• Dual mode of operation• Uses of timer

Page 24: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

Multitasking (timesharing)

• Logical extension of multiprogramming

• CPU switches jobs so fast that users can interact with each job while its running

• Creates interactive computing (e.g. cancel download)

• Characteristics

• Real time: meeting deadline for jobs

• Better share resources between jobs

Page 25: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

Multitasking: Need for new tech

• Concept of CPU scheduling• Need hardware timers• Concept of CPU burst and I/O burst (lots of CPU

operations OR lots of I/O operations in one go)• Have to worry about context switch overhead

Page 26: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

Today’s class

• A brief historical overview of OS• Batch processing systems• Multiprogramming• Multitasking• Some practice problems

• Today’s OS (multitasking, like Unix)• Dual mode of operation• Uses of timer

Page 27: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

Multitasking: The tools

• For multitasking, somebody needs to schedule the tasks as time goes

• kernel does it

• Dual mode of operation

• Use of timer

Page 28: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

Dual mode of operation

• Process can execute in two modes

• user mode and kernel mode

• User mode: run normal applications

• Kernel mode: directly talk to CPU/Peripherals to schedule tasks

Page 29: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

Dual mode of operation

• Process can execute in two modes

• user mode and kernel mode

• User mode: run normal applications

• Kernel mode: directly talk to CPU/Peripherals to schedule tasks

• Mode bit in in hardware

• Tells CPU if its running in user or kernel mode

Page 30: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

Kernel mode facilities

• Can run privileged instructions on CPU• Only in kernel mode• If you try to run them in user mode generates

exceptions• Example: low-level I/O operation, setting protection

registers like, running EI, DI instructions (Enable/Disable interrupt)

Page 31: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

How to switch between these two modes?• System call or interrupt changes mode to kernel

• Special “return” instruction changes mode to user

Page 32: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

How to switch between these two modes?• System call or interrupt changes mode to kernel

• Special “return” instruction changes mode to user

But when to change modes when applications are running?

Page 33: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

Today’s class

• A brief historical overview of OS• Batch processing systems• Multiprogramming• Multitasking• Some problems

• Today’s OS (multitasking, like Unix)• Dual mode of operation• Uses of timer

Page 34: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

How to use hardware timer?

• Recall that OS divide tasks into micro tasks and then schedule them in CPU • Uses a hardware timer to prevent infinite loop or

resource hogging

Page 35: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

How to use hardware timer?

• Recall that OS divide tasks into micro tasks and then schedule them in CPU • Uses a hardware timer to prevent infinite loop or

resource hogging

• Timer interrupts processor after prespecified time• OS initializes the count value (privileged mode)• Count value in timer is decremented by physical clock

Page 36: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

How to use hardware timer?

• Recall that OS divide tasks into micro tasks and then schedule them in CPU • Uses a hardware timer to prevent infinite loop or

resource hogging

• Timer interrupts processor after prespecified time• OS initializes the count value (privileged mode)• Count value in timer is decremented by physical clock• Generates an interrupt when count value is 0

Page 37: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

User mode(mode = 1)

Putting it all together: the multitasking basic in two modes

User process Syscall

Kernel mode(mode = 0)

Page 38: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

Putting it all together: the multitasking basic in two modes

User process Syscall

Syscallhandler

Mode = 0Kernel mode(mode = 0)

User mode(mode = 1)

Page 39: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

Putting it all together: the multitasking basic in two modes

User process Syscall

Syscallhandler

Mode = 0

User mode(mode = 1)

Kernel mode(mode = 0)

Return

Page 40: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

Putting it all together: the multitasking basic in two modes

User process Syscall

Syscallhandler

Mode = 0 Mode = 1

User mode(mode = 1)

Kernel mode(mode = 0)

Return

Page 41: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

Putting it all together: the multitasking basic in two modes

User process Syscall Resume operation

Syscallhandler

Mode = 0 Mode = 1

User mode(mode = 1)

Kernel mode(mode = 0)

Return

Page 42: This file has been cleaned of potential threats. If you ...isg/OS/SLIDES/02.pdf · Simultaneous peripheral jobs online (SPOOL) Only start jobs when all required data is read ... (current

Today’s class

• A brief historical overview of OS• Batch processing systems• Multiprogramming• Multitasking• Some problems

• Today’s OS (multitasking, like Unix)• Dual mode of operation• Uses of timer


Recommended