Course Introduction (contd.): Operating Systems Indranil Sengupta - - PowerPoint PPT Presentation

course introduction contd operating systems
SMART_READER_LITE
LIVE PREVIEW

Course Introduction (contd.): Operating Systems Indranil Sengupta - - PowerPoint PPT Presentation

Course Introduction (contd.): Operating Systems Indranil Sengupta (odd section) and Mainack Mondal (even section) CS39002 Spring 2019-20 The website is up! http://www.facweb.iitkgp.ac.in/~isg/OS/ The story so far What is an OS What


slide-1
SLIDE 1

Course Introduction (contd.): Operating Systems

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

CS39002 Spring 2019-20

slide-2
SLIDE 2

The website is up!

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

slide-3
SLIDE 3

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
slide-4
SLIDE 4

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
slide-5
SLIDE 5

A brief history of OS

slide-6
SLIDE 6

The beginning

Computers == which performs computational tasks

slide-7
SLIDE 7

The beginning

Computers == which performs computational tasks Give a job: It will give you output

slide-8
SLIDE 8

The beginning

Computers == which performs computational tasks Give a job: It will give you output What if you had to compute multiple jobs?

slide-9
SLIDE 9

First computers were similar

  • Thus the operating system was simply designed
  • Ba

Batch h processing ng operating ng system

  • One job executed at a time
  • only one job in memory at one time and executed (till

completion) before the next one starts

slide-10
SLIDE 10

First computers were similar

  • Thus the operating system was simply designed
  • Ba

Batch h processing ng operating ng 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

slide-11
SLIDE 11

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

slide-12
SLIDE 12

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 Insight: Input/Output from periphrals were very slow Your job has to wait forever when my job is simply reading the necessary data from peripheral devices

slide-13
SLIDE 13

SPOOLing

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

slide-14
SLIDE 14

SPOOLing under the hood

CPU

slide-15
SLIDE 15

SPOOLing under the hood

CPU SPOOL buffer

slide-16
SLIDE 16

SPOOLing under the hood

I/O processor CPU SPOOL buffer

slide-17
SLIDE 17

SPOOLing under the hood

Input device I/O processor Output Device CPU SPOOL buffer

slide-18
SLIDE 18

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
slide-19
SLIDE 19

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

slide-20
SLIDE 20

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
slide-21
SLIDE 21

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
slide-22
SLIDE 22

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?
slide-23
SLIDE 23

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
slide-24
SLIDE 24

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
slide-25
SLIDE 25

Multitasking: Need for new tech

  • Concept of CPU scheduling
  • Need hardware timers
  • Concept of CPU burst and I/O burst (lots of CPU
  • perations OR lots of I/O operations in one go)
  • Have to worry about context switch overhead
slide-26
SLIDE 26

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
slide-27
SLIDE 27

Multitasking: The tools

  • For multitasking, somebody needs to schedule

the tasks as time goes

  • kernel does it
  • Dual mode of operation
  • Use of timer
slide-28
SLIDE 28

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

slide-29
SLIDE 29

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
slide-30
SLIDE 30

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)

slide-31
SLIDE 31

How to switch between these two modes?

  • System call or interrupt changes mode to kernel
  • Special “return” instruction changes mode to

user

slide-32
SLIDE 32

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?

slide-33
SLIDE 33

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
slide-34
SLIDE 34

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

slide-35
SLIDE 35

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
slide-36
SLIDE 36

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
slide-37
SLIDE 37

User mode (mode = 1)

Putting it all together: the multitasking basic in two modes

User process Syscall Kernel mode (mode = 0)

slide-38
SLIDE 38

Putting it all together: the multitasking basic in two modes

User process Syscall Syscall handler Mode = 0 Kernel mode (mode = 0) User mode (mode = 1)

slide-39
SLIDE 39

Putting it all together: the multitasking basic in two modes

User process Syscall Syscall handler Mode = 0 User mode (mode = 1) Kernel mode (mode = 0) Return

slide-40
SLIDE 40

Putting it all together: the multitasking basic in two modes

User process Syscall Syscall handler Mode = 0 Mode = 1 User mode (mode = 1) Kernel mode (mode = 0) Return

slide-41
SLIDE 41

Putting it all together: the multitasking basic in two modes

User process Syscall Resume

  • peration

Syscall handler Mode = 0 Mode = 1 User mode (mode = 1) Kernel mode (mode = 0) Return

slide-42
SLIDE 42

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