cmps 270 lecture 6 ., Lecture notes of Computer Science

lecture 6 cmps 270 courses aub

Typology: Lecture notes

2023/2024

Uploaded on 11/09/2025

adam-sinno
adam-sinno 🇱🇧

2 documents

1 / 520

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CMPS 240 - Operating Systems
Lecture 8: Process Scheduling
Maurice Khabbaz, Ph.D. – Edited by Mohamad Zalghout, Ph.D.
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download cmps 270 lecture 6 . and more Lecture notes Computer Science in PDF only on Docsity!

CMPS 240 - Operating Systems

Lecture 8: Process Scheduling

Maurice Khabbaz, Ph.D. – Edited by Mohamad Zalghout, Ph.D.

Last Time

AUB - CMPS 240 - M. J. KHABBAZ, Ph.D.

Critical Section Problem

Hardware-based Solutions

Software-based Solutions

Semaphores

Classical Problems of Synchronization

Monitors

Basic Concepts

AUB - CMPS 240 - M. J. KHABBAZ, Ph.D.

  • Single-CPU System: only one process can run at a time.
    • Other processes must wait until CPU is freed and can be rescheduled.

AUB - CMPS 240 - M. J. KHABBAZ, Ph.D.

  • Single-CPU System: only one process can run at a time.
    • Other processes must wait until CPU is freed and can be rescheduled.
  • Multitasking OS can simultaneously interleave execution of multiple processes.
    • Several processes may be found in memory at any point in time.
    • On single-CPU machines → illusion of multiple processes running concurrently.
    • On multi-CPU machines → enable process concurrency and parallelism on different CPUs.
  • Scheduling: main OS function that schedules all computer resources before use:
    • CPU is one of the primary computer resources.

AUB - CMPS 240 - M. J. KHABBAZ, Ph.D.

  • Single-CPU System: only one process can run at a time.
    • Other processes must wait until CPU is freed and can be rescheduled.
  • Multitasking OS can simultaneously interleave execution of multiple processes.
    • Several processes may be found in memory at any point in time.
    • On single-CPU machines → illusion of multiple processes running concurrently.
    • On multi-CPU machines → enable process concurrency and parallelism on different CPUs.
  • Scheduling: main OS function that schedules all computer resources before use:
    • CPU is one of the primary computer resources.
  • Whenever CPU is idle:
    • CPU scheduler (STS(short-term scheduler)) selects a process from ready queue for execution.^ AUB - CMPS 240 - M. J. KHABBAZ, Ph.D.
  • Single-CPU System: only one process can run at a time.
    • Other processes must wait until CPU is freed and can be rescheduled.
  • Multitasking OS can simultaneously interleave execution of multiple processes.
    • Several processes may be found in memory at any point in time.
    • On single-CPU machines → illusion of multiple processes running concurrently.
    • On multi-CPU machines → enable process concurrency and parallelism on different CPUs.
  • Scheduling: main OS function that schedules all computer resources before use:
    • CPU is one of the primary computer resources.
  • Whenever CPU is idle:
    • CPU scheduler (STS(short-term scheduler)) selects a process from ready queue for execution.
    • CPU scheduling decisions take place when a process:
      1. Switches from running to waiting state.
      2. Switches from running to ready state.
      3. Switches from waiting to ready state.
      4. Terminates.

Ready^ AUB - CMPS 240 - M. J. KHABBAZ, Ph.D.

Waiting

start scheduler dispatch

interrupt I/O event or wait() I/O or event completion

Terminated exit() Running

New

  • Single-CPU System: only one process can run at a time.
    • Other processes must wait until CPU is freed and can be rescheduled.
  • Multitasking OS can simultaneously interleave execution of multiple processes.
    • Several processes may be found in memory at any point in time.
    • On single-CPU machines → illusion of multiple processes running concurrently.
    • On multi-CPU machines → enable process concurrency and parallelism on different CPUs.
  • Scheduling: main OS function that schedules all computer resources before use:
    • CPU is one of the primary computer resources.
  • Whenever CPU is idle:
    • CPU scheduler (STS(short-term scheduler)) selects a process from ready queue for execution.
    • CPU scheduling decisions take place when a process:
      1. Switches from running to waiting state.
      2. Switches from running to ready state.
      3. Switches from waiting to ready state.
      4. Terminates.

Ready^ AUB - CMPS 240 - M. J. KHABBAZ, Ph.D.

Waiting

start scheduler dispatch

interrupt I/O event or wait() I/O or event completion

Terminated exit() Running

New

5

  • REMARK:
    • Scheduling under (1.) and (4.) is non-preemptive ( i.e. , cooperative ).
    • Otherwise, scheduling is preemptive.

Definitions

AUB - CMPS 240 - M. J. KHABBAZ, Ph.D.

  • Non-Preemptive Scheduling:
    • Process keeps CPU until either it terminates or it switches to waiting state.
    • Used on some HW platforms → does not require any special HW ( e.g. timer).
  • Preemptive Scheduling:

Definitions

AUB - CMPS 240 - M. J. KHABBAZ, Ph.D.

  • Non-Preemptive Scheduling:
    • Process keeps CPU until either it terminates or it switches to waiting state.
    • Used on some HW platforms → does not require any special HW ( e.g. timer).
  • Preemptive Scheduling:
    • Process releases CPU before terminating or willingly switching to waiting state.
    • When an interrupt arises, it preempts a process to handle the interrupt.

Dispatcher Module

  • Component involved in CPU scheduling.
  • Gives control of CPU to process selected by STS (short-term scheduler).
  • Dispatching involves:
    • Switching context.
    • Switching to user mode.
    • Jumping to proper location in the user program to restart that program.

AUB - CMPS 240 - M. J. KHABBAZ, Ph.D. 7

Dispatcher Module

  • Component involved in CPU scheduling.
  • Gives control of CPU to process selected by STS (short-term scheduler).
  • Dispatching involves:
    • Switching context.
    • Switching to user mode.
    • Jumping to proper location in the user program to restart that program.
  • Dispatcher should be as fast as possible:
    • It is invoked during every process switch.

AUB - CMPS 240 - M. J. KHABBAZ, Ph.D. 7

Burst Cycles

  • CPU Burst Cycle (CPU-BC): cycle of CPU execution.
  • I/O Burst Cycle (I/O-BC): wait for I/O. AUB - CMPS 240 - M. J. KHABBAZ, Ph.D.

add store

  • When executing a process alternates between two burst cycles: read from file

Burst Cycles

  • CPU Burst Cycle (CPU-BC): cycle of CPU execution.
  • I/O Burst Cycle (I/O-BC): wait for I/O. AUB - CMPS 240 - M. J. KHABBAZ, Ph.D.

add store

  • When executing a process alternates between two burst cycles: read from file

time