Networks and Operating Systems: Exercise Session 2

Slides:



Advertisements
Similar presentations
CPU Scheduling Tanenbaum Ch 2.4 Silberchatz and Galvin Ch 5.
Advertisements

Operating Systems Process Scheduling (Ch 3.2, )
MM Process Management Karrie Karahalios Spring 2007 (based off slides created by Brian Bailey)
1 CSE451 Scheduling Autumn 2002 Gary Kimura Lecture #6 October 11, 2002.
CPU Scheduling CSCI 444/544 Operating Systems Fall 2008.
ITFN 2601 Introduction to Operating Systems Lecture 4 Scheduling.
Processor Scheduling Hank Levy. 22/4/2016 Goals for Multiprogramming In a multiprogramming system, we try to increase utilization and thruput by overlapping.
Lecture Topics: 11/15 CPU scheduling: –Scheduling goals and algorithms.
CPU Scheduling Operating Systems CS 550. Last Time Deadlock Detection and Recovery Methods to handle deadlock – Ignore it! – Detect and Recover – Avoidance.
Process Scheduling Schedulers and Scheduling Methods.
Operating Systems Scheduling. Scheduling Short term scheduler (CPU Scheduler) –Whenever the CPU becomes idle, a process must be selected for execution.
Lecture 5 Scheduling. Today CPSC Tyson Kendon Updates Assignment 1 Assignment 2 Concept Review Scheduling Processes Concepts Algorithms.
Lecturer 5: Process Scheduling Process Scheduling  Criteria & Objectives Types of Scheduling  Long term  Medium term  Short term CPU Scheduling Algorithms.
CPU Scheduling Scheduling processes (or kernel-level threads) onto the cpu is one of the most important OS functions. The cpu is an expensive resource.
UNIT–II: Process Management
Networks and Operating Systems: Exercise Session 3
OPERATING SYSTEMS CS 3502 Fall 2017
lecture 5: CPU Scheduling
Dan C. Marinescu Office: HEC 439 B. Office hours: M, Wd 3 – 4:30 PM.
EEE Embedded Systems Design Process in Operating Systems 서강대학교 전자공학과
Chapter 5a: CPU Scheduling
CPU Scheduling Shmuel Wimer prepared and instructed by
April 6, 2001 Gary Kimura Lecture #6 April 6, 2001
Chapter 2 Scheduling.
Chapter 8 – Processor Scheduling
Operating Systems Processes Scheduling.
Chapter 2.2 : Process Scheduling
Scheduling (Priority Based)
CPU Scheduling.
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
Process management Information maintained by OS for process management
CPU Scheduling Basic Concepts Scheduling Criteria
CPU Scheduling G.Anuradha
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
Operating System Concepts
Chapter 5: CPU Scheduling
Scheduling Adapted from:
Chapter5: CPU Scheduling
TDC 311 Process Scheduling.
Chapter 6: CPU Scheduling
CPU SCHEDULING.
Outline Scheduling algorithms Multi-processor scheduling
CPU scheduling decisions may take place when a process:
Chapter 6: CPU Scheduling
Process Scheduling Decide which process should run and for how long
Chapter 5: CPU Scheduling
Lecture 2 Part 3 CPU Scheduling
CSE 451: Operating Systems Winter 2003 Lecture 6 Scheduling
Processor Scheduling Hank Levy 1.
Scheduling.
Operating System , Fall 2000 EA101 W 9:00-10:00 F 9:00-11:00
Shortest-Job-First (SJR) Scheduling
Chapter 6: CPU Scheduling
Concurrency and Threading: CPU Scheduling
Module 5: CPU Scheduling
CPU SCHEDULING CPU SCHEDULING.
Chapter 6: Scheduling Algorithms Dr. Amjad Ali
Scheduling 21 May 2019.
Chapter 6: CPU Scheduling
Don Porter Portions courtesy Emmett Witchel
CPU Scheduling.
CPU Scheduling: Basic Concepts
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
CPU Scheduling CSE 2431: Introduction to Operating Systems
CSE 451: Operating Systems Winter 2001 Lecture 6 Scheduling
Presentation transcript:

Networks and Operating Systems: Exercise Session 2 Salvatore di Girolamo (TA) Networks and Operating Systems: Exercise Session 2

Difference between user- and kernel-level threads? Kernel-level threads: implemented in kernel-space, the OS sees them User-level threads: managed by user-level libraries, much cheaper than kernel threads Advantages/disadvantages Good for frequently blocking applications Scheduling can be inefficient Can block the entire process Significant memory overhead in the kernel Fast switching CPU-time can be assigned according to the their number Slow management operations No OS support required

Threads: user- to kernel- level threads mapping One-to-one Many-to-one Many-to-many Kernel User CPU 0 CPU 1 Kernel User CPU 0 CPU 1 Kernel User CPU 0 CPU 1 Text Data BSS Thread 1 stack Thread 2 stack Thread 3 stack Text BSS Thread 1 stack Thread 2 stack Thread 3 stack Data

Scheduling Life of a scheduler: What to schedule? When to schedule? For how long? Scheduler needs CPU to decide what to schedule Any time spent in scheduler is “wasted” time Want to minimize overhead of decisions To maximize utilization of CPU But low overhead is no good if your scheduler picks the “wrong” things to run! Trade-off between: scheduler complexity/overhead and quality of resulting schedule

When to schedule? When: A running process blocks (or calls yield()) e.g., initiates blocking I/O or waits on a child A blocked process unblocks I/O completes A running or waiting process terminates An interrupt occurs I/O or timer 2 or 4 can involve preemption

Scheduling: Preemption Difference between preemptive and non-preemptive scheduling? Preemptive: Processes dispatched and descheduled without warning How? timer interrupt, page fault, etc. Non-preemptive: Each process explicitly gives up the scheduler How? Start I/O, executes a “yield()” call, etc. What could be the problem with non-preemptive scheduling? Which one would you use in a real time system?

Round-robin Simplest interactive algorithm Run all runnable tasks for fixed quantum in turn Advantages: It’s easy to implement It’s easy to understand, and analyze Higher turnaround time than SJF, but better response Disadvantages: It’s rarely what you want Treats all tasks the same

Priority Very general class of scheduling algorithms Assign every task a priority Dispatch highest priority runnable task Priorities can be dynamically changed Schedule processes with same priority using Round Robin FCFS etc. Priority 100 Priority 4 Priority 3 Priority 2 Priority 1 T Runnable tasks Priority …

Scheduling: First-come first-served Simplest algorithm! Task Execution time A 24 B 3 C What about the waiting time? Waiting times: 0, 24, 27 Avg. = (0+24+27)/3 = 17 A B C 24 27 30

Scheduling: First-come first-served Different arrival order Task Execution time A 24 B 3 C What about the waiting time? Waiting times: 6, 0, 3 Avg. = (0+3+6)/3 = 3 Much better  But unpredictable  B C A 3 6 30

Scheduling: Shortest-job first Task Execution time A 6 B 8 C 7 D 3 Always run process with the shortest execution time. Optimal: minimizes waiting time (and hence turnaround time) Task Execution time A 6 B 8 C 7 D 3 What to do if new jobs arrive (interactive load)? Shortest Remaining Time First: new, short jobs may preempt longer jobs already running D A C B

Scheduling: Round Robin Simplest interactive algorithm Run all runnable tasks for fixed quantum in turn Advantages: It’s easy to implement It’s easy to understand, and analyze Higher turnaround time than SJF, but better response Disadvantages: It’s rarely what you want Treats all tasks the same

RT Scheduling: Earliest Deadline First Schedule task with earliest deadline first (duh..) Dynamic, online. Tasks don’t actually have to be periodic… More complex - O(n) – for scheduling decisions EDF will find a feasible schedule if: Which is very handy. Assuming zero context switch time…

Scheduling: exercise Process Burst time Priority P1 10 1 2 5 3 1 4 2 Notes: SJF: equal burst length processes are scheduled in FCFS Priority: non-preemptive priority, small priority number means high priority, equal priority processes are scheduled in FCFS) RR: quantum=1. P2 P3 P4 P5 Time: 1 2 3 4 5 6 7 8 10 9 11 12 13 19 16 14 15 17 18 FCFS: P1 P1 P1 P1 P1 P1 P1 P1 P1 P1 P2 P3 P3 P4 P5 P5 P5 P5 P5 SJF: P2 P4 P3 P3 P5 P5 P5 P5 P5 P1 P1 P1 P1 P1 P1 P1 P1 P1 P1 RR: P1 P2 P3 P4 P5 P1 P3 P5 P1 P5 P1 P5 P1 P5 P1 P1 P1 P1 P1 Source: https://prof.hti.bfh.ch/myf1/opsys1/Exercises/Chap5/Problems1.sol.html