Chapter 2 (PART 1) Light-Weight Process (Threads) Department of Computer Science Southern Illinois University Edwardsville Summer, 2004 Dr. Hiroshi Fujinoki.

Slides:



Advertisements
Similar presentations
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Advertisements

Department of Computer Science Southern Illinois University Edwardsville Spring, 2010 Dr. Hiroshi Fujinoki CS 547/490 Network.
Chapter 4: Threads. Overview Multithreading Models Threading Issues Pthreads Windows XP Threads.
Figure 2.8 Compiler phases Compiling. Figure 2.9 Object module Linking.
3.5 Interprocess Communication Many operating systems provide mechanisms for interprocess communication (IPC) –Processes must communicate with one another.
3.5 Interprocess Communication
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
1 Chapter 4 Threads Threads: Resource ownership and execution.
Process Concept An operating system executes a variety of programs
A. Frank - P. Weisberg Operating Systems Introduction to Tasks/Threads.
Threads CS 416: Operating Systems Design, Spring 2001 Department of Computer Science Rutgers University
Chapter 51 Threads Chapter 5. 2 Process Characteristics  Concept of Process has two facets.  A Process is: A Unit of resource ownership:  a virtual.
Processes Part I Processes & Threads* *Referred to slides by Dr. Sanjeev Setia at George Mason University Chapter 3.
Operating Systems CSE 411 CPU Management Sept Lecture 11 Instructor: Bhuvan Urgaonkar.
Chapter 4: Threads. From Processes to Threads 4.3 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Threads.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Introduction to Threads CS240 Programming in C. Introduction to Threads A thread is a path execution By default, a C/C++ program has one thread called.
E X C E E D I N G E X P E C T A T I O N S OP SYS Linux System Administration Dr. Hoganson Kennesaw State University Operating Systems Functions of an operating.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 13 Threads Read Ch 5.1.
Copyright ©: University of Illinois CS 241 Staff1 Threads Systems Concepts.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Cooperating.
Department of Computer Science Southern Illinois University Edwardsville Spring, 2010 Dr. Hiroshi Fujinoki IPC1.PPT/001 Inter-Process.
11/13/20151 Processes ICS 240: Operating Systems –William Albritton Information and Computer Sciences Department at Leeward Community College –Original.
Chapter 1 (PART 1) Introduction to OS (concept, evolution, some keywords) Department of Computer Science Southern Illinois University Edwardsville Summer,
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Chapter 4: Threads Overview Multithreading.
Lecture 5: Threads process as a unit of scheduling and a unit of resource allocation processes vs. threads what to program with threads why use threads.
Operating System Concepts Part II Department of Computer Science Southern Illinois University Edwardsville Spring, 2009 Dr. Hiroshi Fujinoki
Department of Computer Science and Software Engineering
Processes & Threads Introduction to Operating Systems: Module 5.
Operating Systems (CS 340 D) Dr. Abeer Mahmoud Princess Nora University Faculty of Computer & Information Systems Computer science Department.
Chapter 1 (PART 2) Operating System Concepts Department of Computer Science Southern Illinois University Edwardsville Spring, 2016 Dr. Hiroshi Fujinoki.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 4: Threads.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
Operating Systems Unit 2: – Process Context switch Interrupt Interprocess communication – Thread Thread models Operating Systems.
Uniprocessor Process Management & Process Scheduling Department of Computer Science Southern Illinois University Edwardsville Spring, 2016 Dr. Hiroshi.
Operating System Concepts
1 Threads, SMP, and Microkernels Chapter 4. 2 Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
1 Chapter 5: Threads Overview Multithreading Models & Issues Read Chapter 5 pages
Process concept.
Chapter 3: Process Concept
CS 6560: Operating Systems Design
Operating Systems (CS 340 D)
OPERATING SYSTEMS CS3502 Fall 2017
Process Management Presented By Aditya Gupta Assistant Professor
Chapter 3: Process-Concept
Chapter 4 Threads.
Operating Systems (CS 340 D)
Threads & multithreading
Chapter 3: Processes.
Chapter 3: Processes.
Threads Chapter 4.
Multithreaded Programming
Operating System Introduction.
Chapter 3: Processes.
Uniprocessor Process Management & Process Scheduling
Introduction to OS (concept, evolution, some keywords)
Chapter 3: Processes Process Concept Process Scheduling
Introduction to OS (concept, evolution, some keywords)
Chapter 4: Threads.
Department of Computer Science
Department of Computer Science
Operating System Concepts
Threads: Light-Weight Processes
Operating System Concepts
Light-Weight Process (Threads)
Uniprocessor Process Management & Process Scheduling
Presentation transcript:

Chapter 2 (PART 1) Light-Weight Process (Threads) Department of Computer Science Southern Illinois University Edwardsville Summer, 2004 Dr. Hiroshi Fujinoki CS 414 Operating Systems Threads/001

CS 414 Operating Systems Threads/002 Presentation Agenda Two inefficiency problems in “process” The two problems motivate “light-weigh process” (“Light-weight process” = “Thread”) Introduce “thread” as a solution for the two problems in “process” How thread works?

CS 414 Operating Systems Threads/003 Structure of process PCB Address Space  Stack  Code  Heap For some applications, this structure gives problems Assume an application program that (1) Requires multiple processes to execute an application program (2) Requires inter-process communications

BBS Server Host Implementation CS 414 Operating Systems Threads/004 Example Network BBS Server BBS DB Client A Client B Client C Client D BBS DB Client A Client B Client C Process A Process B Process C Multiprogramming

CS 414 Operating Systems Threads/005 Two inefficiency problems using processes in this BBS Server  Context-switching overhead - When a context-switch happens, an entire PCB of the running process has to be saved and the one for the next has to be loaded.  System call overhead in accessing shared information - In order for the BBS information to be shared, the shared information needs to be in a different address space - To access data in a different address space, each process needs to call a system call

CS 414 Operating Systems Threads/006 Problem 1: Overhead for context switching Process A Process B Process C Client B arrives Client A arrives Running Ready What if the number of concurrent clients increased? Running Client C arrives Ready Running Context-switching overhead

CS 414 Operating Systems Threads/007 Problem 1: Overhead for context switching (continued) If we just increase the number of clients, what will happen? Process A Process B Process C Process D Process E Running Ready Running Ready Running Ready Running Ready Running Ready Non-responding interval

CS 414 Operating Systems Threads/008 Problem 1: Overhead for context switching (continued) What could we do to reduce non-responding interval? Process A Process B Process C Process D Process E Running Ready Running Ready Running Ready Running This causes another problem Effective CPU goes down Non-responding interval

CS 414 Operating Systems Threads/009 Problem 2: System call overhead in accessing shared information BBS Server Host BBS DB Client A Client B Client C Process A Process B Process C Multiprogramming Process A Process C Process B BBS DB (Shared data) OS

CS 414 Operating Systems Threads/010 Two inefficiency problems using processes in this BBS Server - If number of clients is increased  Context-switching overhead  System call overhead in accessing shared information Either response time or effective CPU utilization is sacrificed - Shared data is implemented with another address space Slower program execution Light-weight process (thread) is a solution for the two problems

One Address Space CS 414 Operating Systems Threads/011 Concepts of light-weight process Multiple execution paths in a process Thread PCB A Address Space Process A PCB B Address Space Process B PCB C Address Space Process C PCB X Global Stack Global Heap Global PCB

Process CS 414 Operating Systems Threads/012 Concepts of light-weight process PCB A Address Space Process A PCB B Address Space Process B PCB C Address Space Process C PCB X Global Stack Global Heap Global PCB Private Stack Code Private Heap Private PCB

CS 414 Operating Systems Threads/013 Concepts of light-weight process PCB A Address Space Process A PCB B Address Space Process B PCB C Address Space Process C Process PCB X Global Stack Global Heap Private Stack Code Private Heap Private PCB Global PCB PCB N = Global PCB + Private PCB

CS 414 Operating Systems Threads/014 Concepts of light-weight process PCB w/out thread support Global PCB Private PCB When a CPU needs to be switched from a thread to another, only this part should be swapped Remaining Question: How context-switching overhead can be reduced?

CS 414 Operating Systems Threads/015 Concepts of light-weight process PCB w/out thread support Global PCB Private PCB When a CPU needs to be switched from a thread to another, only this part should be swapped For CPU switching between threads, global PCB remains remains same

CS 414 Operating Systems Threads/016 Definition of Threads Thread = Multi-threading - Making multiple threads in ready state - Similar to “multi-programming” - Much less overhead for context-switching and communication Multiple execution paths within a process “light-weight process”

CS 414 Operating Systems Threads/017 Major Advantages in threads Thread reduces context-switching and inter-process communication overhead (thus “light-weight”). The general advantages in threads are: - Share all resources assigned to a “process” Files opened, I/O devices assigned, global memory allocated, etc. - Ability to execute multiple different tasks in asynchronous way With easy and fast inter-thread communication

CS 414 Operating Systems Threads/018 Major Disadvantages in threads No memory protection between threads Managing assigned I/O resources could be very complex - Any thread in a process can use any resources assigned to a process - Multiple threads can be executed in any order Example Implementation of threads is not standardized - Each major OS (Solaris, LINUX, BSD, Windows) has its own implementation of threads and all different Programmers are responsible for avoiding “illegal access”