1 Review of Process Mechanisms. 2 Scheduling: Policy and Mechanism Scheduling policy answers the question: Which process/thread, among all those ready.

Slides:



Advertisements
Similar presentations
Copyright © 2000, Daniel W. Lewis. All Rights Reserved. CHAPTER 8 SCHEDULING.
Advertisements

More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Process Description and Control
CSE 451: Operating Systems Winter 2006 Module 4 Processes Ed Lazowska Allen Center 570.
Processes CSCI 444/544 Operating Systems Fall 2008.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
Ceng Operating Systems Chapter 2.1 : Processes Process concept Process scheduling Interprocess communication Deadlocks Threads.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
CSSE Operating Systems
CSE451 Processes Spring 2001 Gary Kimura Lecture #4 April 2, 2001.
Wk 2 – Scheduling 1 CS502 Spring 2006 Scheduling The art and science of allocating the CPU and other resources to processes.
Chapter 6 Implementing Processes, Threads, and Resources.
Processes April 5, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Process Description and Control A process is sometimes called a task, it is a program in execution.
Slide 6-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6.
Slide 6-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6.
Process Description and Control Chapter 3. Major Requirements of an OS Interleave the execution of several processes to maximize processor utilization.
CPU Scheduling Chapter 6 Chapter 6.
Implementing Processes and Process Management Brian Bershad.
Scheduling Basic scheduling policies, for OS schedulers (threads, tasks, processes) or thread library schedulers Review of Context Switching overheads.
Chapter 41 Processes Chapter 4. 2 Processes  Multiprogramming operating systems are built around the concept of process (also called task).  A process.
Chapter 3 Process Description and Control
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Thread Scheduling.
Scheduling Example 3 (1) Assume: FIFO Job Scheduling 100 K Main Memory Processor Sharing Process Scheduling (Cont…)
1 Chapter 2.1 : Processes Process concept Process concept Process scheduling Process scheduling Interprocess communication Interprocess communication Threads.
Multiprogramming. Readings r Silberschatz, Galvin, Gagne, “Operating System Concepts”, 8 th edition: Chapter 3.1, 3.2.
Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model.
Chapter 2 Processes and Threads Introduction 2.2 Processes A Process is the execution of a Program More specifically… – A process is a program.
Linux Processes Travis Willey Jeff Mihalik. What is a process? A process is a program in execution A process includes: –program counter –stack –data section.
Concurrency & Context Switching Process Control Block What's in it and why? How is it used? Who sees it? 5 State Process Model State Labels. Causes of.
4300 Lines Added 1800 Lines Removed 1500 Lines Modified PER DAY DURING SUSE Lab.
1  process  process creation/termination  context  process control block (PCB)  context switch  5-state process model  process scheduling short/medium/long.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Process Description and Control Chapter 3. Source Modified slides from Missouri U. of Science and Tech.
2 Processor(s)Main MemoryDevices Process, Thread & Resource Manager Memory Manager Device Manager File Manager.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
Managing Processors Jeff Chase Duke University. The story so far: protected CPU mode user mode kernel mode kernel “top half” kernel “bottom half” (interrupt.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Scheduling.
1 Outline for Today Objectives: –To review the process and thread abstractions. the mechanisms for implementing processes (threads), including scheduling.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
Multiprogramming. Readings r Chapter 2.1 of the textbook.
Copyright ©: Nahrstedt, Angrave, Abdelzaher
OPERATING SYSTEMS CS3502 Fall 2017
Lecture Topics: 11/1 Processes Process Management
Operating Systems: A Modern Perspective, Chapter 6
Chapter 3: Processes.
Outline for Today Objectives: Announcements To review To detail
Intro to Processes CSSE 332 Operating Systems
Structure of Processes
Process & its States Lecture 5.
Lecture Topics: 11/1 General Operating System Concepts Processes
Process Description and Control
Processes Hank Levy 1.
Processes and Process Management
Process Description and Control
Process Description and Control
Chapter 3: Processes.
CSE 451: Operating Systems Winter 2003 Lecture 4 Processes
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Implementing Processes, Threads, and Resources
CS510 Operating System Foundations
CSE 451: Operating Systems Autumn 2004 Module 4 Processes
Processes Hank Levy 1.
Implementing Processes, Threads, and Resources
Chapter 3: Process Management
Presentation transcript:

1 Review of Process Mechanisms

2 Scheduling: Policy and Mechanism Scheduling policy answers the question: Which process/thread, among all those ready to run, should be given the chance to run next? In what order do the processes/threads get to run? For how long? Mechanisms are the tools for supporting the process/thread abstractions and affect how the scheduling policy can be implemented. –How the process or thread is represented to the system - process descriptor. –What happens on a context switch. –When do we get the chance to make these scheduling decisions (timer interrupts, thread operations that yield or block, user program system calls)

3 Context Switching When a process is running, its program counter, register values, stack pointer, etc. are contained in the hardware registers of the CPU. The process has direct control of the CPU hardware for now. When a process is not the one currently running, its current register values are saved in a process descriptor data structure (task_struct) Context switching involves moving state between CPU and various processes’ descriptors by the OS.

4 PCBs & Queues process state process identifier PC Stack Pointer (SP) general purpose reg owner userid open files scheduling parameters memory mgt stuff queue ptrs...other stuff... process state process identifier PC Stack Pointer (SP) general purpose reg owner userid open files scheduling parameters memory mgt stuff queue ptrs...other stuff... process state process identifier PC Stack Pointer (SP) general purpose reg owner userid open files scheduling parameters memory mgt stuff queue ptrs...other stuff... head ptr tail ptr head ptr tail ptr Ready QueueWait on Disk Read

5 Linux task_struct Process descriptor in kernel memory represents a process (allocated on process creation, deallocated on termination). –Linux: task_struct, located via task pointer in thread_info structure on process’s kernel state. state prio policy *parent tasks pid … task_struct

6 Linux task_struct state prio policy *parent tasks pid … process stack thread_info *task task_struct

7 Process State Transitions Ready Create Process Running Blocked Wakeup (due to event) sleep (due to outstanding request of syscall) scheduled suspended while another process scheduled Done

8 Linux Process States TASK_RUNNING Ready fork( ) TASK_INTERRUPTABLE TASK_UNINTERRUPTABLE Blocked Wakeup (due to event) sleep (due to outstanding request of syscall) scheduled suspended while another process scheduled TASK_RUNNING Running TASK_ZOMBIE Done exit( )

9 Scheduling Mechanisms

10 Preemption Scheduling policies may be preemptive or non- preemptive. Preemptive: scheduler may unilaterally force a task to relinquish the processor before the task blocks, yields, or completes. –timeslicing prevents jobs from monopolizing the CPU Scheduler chooses a job and runs it for a quantum of CPU time. A job executing longer than its quantum is forced to yield by scheduler code running from the clock interrupt handler. –use preemption to honor priorities Preempt a job if a higher priority job enters the ready state.

Timer Operation Timer set to generate an interrupt in a given time. OS uses it to regain control from user code. –Sets timer before transferring to user code. –when time expires, the executing program is interrupted and the OS is back in control. Setting timer is privileged.

12 Priority Some goals can be met by incorporating a notion of priority into a “base” scheduling discipline. Each job in the ready pool has an associated priority value; the scheduler favors jobs with higher priority values. External priority values: –imposed on the system from outside –reflect external preferences for particular users or tasks “All jobs are equal, but some jobs are more equal than others.” –Example: Unix nice system call to lower priority of a task. –Example: Urgent tasks in a real-time process control system. Internal priorities –scheduler dynamically calculates and uses for queuing discipline. System adjusts priority values internally as as an implementation technique within the scheduler.

13 Internal Priority Drop priority of tasks consuming more than their share Boost tasks that already hold resources that are in demand Boost tasks that have starved in the recent past Adaptive to observed behavior: typically a continuous, dynamic, readjustment in response to observed conditions and events –May be visible and controllable to other parts of the system –Priority reassigned if I/O bound (large unused portion of quantum) or if CPU bound (nothing left)

14 Linux task_struct Process descriptor in kernel memory represents a process (allocated on process creation, deallocated on termination). –Linux: task_struct, located via task pointer in thread_info structure on process’s kernel state. state prio policy static_prio sleep_avg time_slice … task_struct

15 Keeping Your Priorities Straight Priorities must be handled carefully when there are dependencies among tasks with different priorities. –A task with priority P should never impede the progress of a task with priority Q > P. This is called priority inversion, and it is to be avoided. –The basic solution is some form of priority inheritance. When a task with priority Q waits on some resource, the holder (with priority P) temporarily inherits priority Q if Q > P. Inheritance may also be needed when tasks coordinate with IPC. –Inheritance is useful to meet deadlines and preserve low-jitter execution, as well as to honor priorities.

16 Pitfalls: Mars Pathfinder Example In July 1997, Pathfinder’s computer reset itself several times during data collection and transmission from Mars. –One of its processes failed to complete by a deadline, triggering the reset. Priority Inversion Problem. –A low priority process held a mutual exclusion semaphore on a shared data structure, but was preempted to let higher priority processes run. –The higher priority process which failed to complete in time was blocked on this semaphore. –Meanwhile a bunch of medium priority processes ran, until finally the deadline ran out. The low priority semaphore-holding process never got the chance to run again in that time to get to the point of releasing the semaphore –Priority inheritance had not been enabled on semaphore.