Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Chapter 5 Processes and Threads Copyright © 2008.
6/9/2015B.Ramamurthy1 Process Description and Control B.Ramamurthy.
Process Description and Control
The Process Model.
Thursday, June 08, 2006 The number of UNIX installations has grown to 10, with more expected. The UNIX Programmer's Manual, 2nd Edition, June, 1972.
Figure 2.8 Compiler phases Compiling. Figure 2.9 Object module Linking.
Page 1 Processes and Threads Chapter 2. Page 2 Processes The Process Model Multiprogramming of four programs Conceptual model of 4 independent, sequential.
Page 1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
1 Concurrent and Distributed Systems Introduction 8 lectures on concurrency control in centralised systems - interaction of components in main memory -
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
Process in Unix, Linux and Windows CS-3013 C-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
1 When to Switch Processes 3 triggers –System call, Interrupt and Trap System call –when a user program invokes a system call. e.g., a system call that.
CSE451 Processes Spring 2001 Gary Kimura Lecture #4 April 2, 2001.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
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.
1 Lecture 10: Uniprocessor Scheduling. 2 CPU Scheduling n The problem: scheduling the usage of a single processor among all the existing processes in.
Processes in Unix, Linux, and Windows CS-502 Fall Processes in Unix, Linux, and Windows CS502 Operating Systems (Slides include materials from Operating.
Process Description and Control Chapter 3. Major Requirements of an OS Interleave the execution of several processes to maximize processor utilization.
Chapter 8 Windows Outline Programming Windows 2000 System structure Processes and threads in Windows 2000 Memory management The Windows 2000 file.
Process in Unix, Linux, and Windows CS-3013 A-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
Processes and Threads.
Implementing Processes and Process Management Brian Bershad.
Operating Systems Part III: Process Management (Process States and Transitions)
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
CE Operating Systems Lecture 11 Windows – Object manager and process management.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-1: Process Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
Processes Introduction to Operating Systems: Module 3.
Chapter 2 Processes and Threads Introduction 2.2 Processes A Process is the execution of a Program More specifically… – A process is a program.
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.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
1 Process Description and Control Chapter 3. 2 Process A program in execution An instance of a program running on a computer The entity that can be assigned.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 3.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
UNIT–II: Process Management
Lecture 3 Process.
Process Management Process Concept Why only the global variables?
Protection of System Resources
Uniprocessor Scheduling
Lecture Topics: 11/1 Processes Process Management
System Structure and Process Model
System Structure and Process Model
Structure of Processes
Chapter 3: Windows7 Part 2.
System Structure B. Ramamurthy.
System Structure and Process Model
Chapter 3: Windows7 Part 2.
Process & its States Lecture 5.
Chapter 2: The Linux System Part 3
TDC 311 Process Scheduling.
Process Description and Control
Processes Hank Levy 1.
Process Description and Control
Processes and Process Management
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Process Description and Control
Process Description and Control
Process Description and Control
Process Description and Control
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
CS510 Operating System Foundations
Process Description and Control
Process Description and Control in Unix
Processes Hank Levy 1.
Presentation transcript:

Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority and scheduling Thread synchronisation Interprocess communication

Windows structure overview

Processes and threads In Windows a process consists of program code, execution context ( the address space of the process plus such things as the access token) resources allocated to the process i.e. handles, one or more threads Threads are the units of execution – they execute program code using the processes context and resources

A thread has its own context (register values including instruction pointer, execution stack, and such things as scheduling priority) Threads are scheduled onto the processor, not a process

Processes and threads are managed by 2 components in Windows: the process and thread manager and the kernel

kernel The kernel is responsible for: –Thread scheduling –Interrupt and exception handling –Low level processor synchronisation –Recovery after power failure In normal Operating Systems the kernel refers to all the operating systems components that run in kernel mode. In Windows as we have seen this applies to all the Windows Executive components (everything below the line in the diagram).

However, perversely, Windows applies the name kernel to just one component - a low level layer of the OS that manages much of the execution of threads within processes The kernel uses objects to represent and manage low level threads and processes However these kernel objects are different from those managed by the Object Manager They are lower level and provide support for the higher level objects used by the Object Manager

Process and thread manager Process manager is part of the Windows Executive and implements the representation of processes and threads that are available to other parts of the Executive and provides high level services to manage and control processes and threads Process and thread manager provides functions to –Create and destroy processes –Control resource allocation to processes –Keep track of information about processes and threads

Processes are created by other processes by making a CreateProcess system call Unlike Unix/Linux the parent and child process are independent of each other – remember fork in Unix/Linux creates the child as a copy of the parent and hence has a copy of the parents address space In Windows child process has completely separate address space, etc. Hence Windows does not keep track of process hierarchies

Thread scheduling Windows maintains a list of threads that are in the system Threads may be in one of several different states Ready – thread can execute but waiting for a processor Running – running on a processor Standby - selected to run next on a processor

Waiting – unable to execute until some event occurs (typically I/O) Terminated All processes have at least one thread known as the base thread – created when the process is created

The kernel implements the dispatcher code, which determines which thread to run next The dispatcher implements pre-emptive scheduling among threads The dispatcher schedules threads without reference to the process they belong to – hence a process that has more threads will if everything else is equal have a greater share of the processor

The scheduling algorithm is based on a multilevel priority queue approach with each thread having a priority and hence belonging to a given queue A ready thread is placed in the queue which represents its assigned priority There are 32 priority queue levels designated by numbers with 31 highest priority and 0 lowest Dispatcher starts with highest priority queue and schedules threads in order in queue in round robin fashion

Each thread is given a time quantum in which to execute and it either blocks itself waiting on some I/O event or synchronisation event or the quantum expires Once a given queue is empty, the dispatcher then proceeds to the next lowest priority queue and so on until the queues are all empty or a higher level priority thread enters a ready state i.e. one of the higher level queues is now no longer empty – and dispatcher pre-empts lower priority running thread

Highest priority levels (16-31) is for real- time threads (needing immediate responsiveness) – the real-time priorities are static Lower priority levels (0-15) are for dynamic priority threads A processes base thread is given a base priority – which is the minimum priority a thread can have

Each process has: a base priority class (a range of priority levels which the define the possible range of base priorities) and a base priority level which specifies the relative base priority a threads should have in the base priority class

Each thread then takes on priority values dynamically i.e. it changes over time e.g. if the thread is delayed waiting on an I/O event, when the I/O event occurs and the thread becomes ready again, its priority is increased temporarily. The size of the increase depends on the length of the wait – the longer the wait the greater the increase in priority

Traps and exception handling Kernel implements a trap handler which deals with hardware interrupts and processor exceptions The trap handler disables interrupts, determines the cause of the interrupt, saves processor state, re-enables interrupts and dispatches code to deal with type of interrupt/exception found (Interrupt service routine for I/O events or traps from running code to request some service or exception handler to handle problems such as attempt to execute invalid instruction)

Thread synchronisation Windows provides a set of dispatcher objects which can be used for synchronisation of thread behaviour These dispatcher objects can be in a signalled state (when the event that the thread is waiting for occurs) or a unsignaled state (when the event has not yet occurred)

Event objects represent events such as I/O events – when the relevant event occurs the object manager sets the event object to the signalled state Mutex objects provide mutual exclusion – only one thread can have a mutex object – it does this by setting the object into an unsignaled state. Once the thread completes its activity it sets the mutex object to the signalled state Waitable timer objects – these objects remain unsignaled until a given time has elapsed

Interprocess communication Threads (and hence also processes) can communicate using a variety of methods Pipes – work very similar to Unix – unidirectional communication via a shared buffer Sockets – similar to pipes but usually connect processes and threads on different machines Remote procedure calls – allows a thread in one process to invoke the execution of code in different processes address space File sharing is also implemented