Docsity

Operating System Services - Lecture Slides | CMSC 321, Study notes of Operating Systems

Partial preview of the text

Download Operating System Services - Lecture Slides | CMSC 321 and more Study notes Operating Systems in PDF only on Docsity!

CMSC 321:CMSC 321:

Operating Systems

Lecture 3ProcessesProcesses

Operating System ServicesOperating System Services • What services must an OS provide?

at se

ces

ust a

OS p o

de

  • program development– program execution– access to I/O– controlled access to files– system access (shared)

system access (shared)

  • error detection & response– accounting (stats)

Hardware support for OS Features

pp

The Interrupt Mechanism •^

Interrupts occur due to hardware events

-^

Interrupts occur due to hardware events (completion of disk I/O, etc.) or softwareevents (expiration of a timer, reception of amessage, etc.).

  • Instruction cycle is modifed to include a check

for pending interrupts after each instructionfor pending interrupts after each instructionexecution.

Hardware support for OS Features

pp

The Interrupt Mechanism •^

Interrupt vector

an area of system memory

•^

Interrupt vector

an area of system memory

containing a pointer to the interrupt handlerfor each type of interrupt.

  • Interrupt handler first preserves processor

state for the suspended process, thenperforms actions necessary to service theperforms actions necessary to service theinterrupt.

  • Different type of interrupts may have different

priorities: interupt handlers may themselvesbe interruptable!

Hardware support for OS Features

pp

Peripheral Handling: Direct Memory Access •^

All the work to complete the transfer occurs

-^

All the work to complete the transfer occurs between the device and the memorycontroller.

  • Cycle stealing - since the memory controller

can handle only one request at a time

some

can handle only one request at a time, somememory requests from the CPU may bedelayed by requests from the deviceperforming DMA.

Hardware support for OS Features

pp

  • Dual mode operation
    • Monitor mode for execution of OS (also called

Monitor mode for execution of OS (also calledSupervisor mode or Kernel mode)

  • User mode for execution of user programs
    • Time slicing - prevents a "runaway" process

from dominating CPU usage. Hardware timerfrom dominating CPU usage. Hardware timerneeded to implement this feature.

ProcessProcess

•^

Most fundamental concept in OS

-^

Most fundamental concept in OS

  • Process: a program in execution
    • one or more threads (units of work)– associated system resources
      • Program vs. process
        • program: a passive entity– process: an active entity

process: an active entity

  • For a

program

to execute, a

process

is created

for that programfor that program

Process ManagementProcess Management

•^

Fundamental task of any OS

-^

Fundamental task of any OS

  • For processes, OS must:
    • allocate resources– facilitate

multiprogramming

  • allow sharing and exchange of info

g^

g

  • protect resources from other processes– enable synchronization
    • How?
      • data structure for each process (coming soon…)– describes state and resource ownership– describes state and resource ownership

The Two-State Model

Two States: Not EnoughTwo States: Not Enough

  • Running process makes I/O syscall

Running process makes I/O syscall– moved to “not running” state– can’t be selected until I/O is complete!

  • “not running” should be two states: -^

blocked

: waiting for something, can’t be selected

d^

j^

t it hi

f^

CPU ti

-^

ready

: just itching for CPU time…

  • Five states total -^

running

,^

blocked

,^

ready

-^

new

: OS might not yet admit (e.g., performance)

-^

exiting

: halted or aborted

  • perhaps other programs want to examine tables & DS

Process State DiagramProcess State Diagram

Refined Queuing Diagram

P^

bl

bl

k d

diff

t^

t

Problem: processes blocked on different events

must search entire queue

Solution:

one queue for each type of event

Solution:

one queue for each type of event

Are Five States Enough?

g

Problem: Can’t have

all

processes in RAM

  • Problem: Can’t have

all

processes in RAM

S

l^

ti

t^

di k

  • Solution: swap some to disk
    • i.e., move all or part of a process to disk
      • Requires new state:

suspend

on disk

therefore not available to CPU

  • on disk, therefore not available to CPU

Six

-State Model

Six State Model