Operating Systems CMPSC 473 Processes (5) September 22 2008 - Lecture 11 Instructor: Bhuvan Urgaonkar.

Slides:



Advertisements
Similar presentations
Chap 4 Multithreaded Programming. Thread A thread is a basic unit of CPU utilization It comprises a thread ID, a program counter, a register set and a.
Advertisements

Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Multithreaded Programming.
Threads. Objectives To introduce the notion of a thread — a fundamental unit of CPU utilization that forms the basis of multithreaded computer systems.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Chapter 4: Multithreaded Programming
Chapter 5 Threads os5.
Modified from Silberschatz, Galvin and Gagne ©2009 Lecture 7 Chapter 4: Threads (cont)
Threads Irfan Khan Myo Thein What Are Threads ? a light, fine, string like length of material made up of two or more fibers or strands of spun cotton,
Chapter 4: Threads. Overview Multithreading Models Threading Issues Pthreads Windows XP Threads.
Chapter 4: Multithreaded Programming
Chapter 5 Processes and Threads Copyright © 2008.
Course: Operating Systems Instructor: Umar Kalim NUST Institute of Information Technology, Pakistan Operating Systems.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 5: Threads Overview Multithreading Models Threading Issues Pthreads Solaris.
4.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 4 Multithreaded Programming Objectives Objectives To introduce a notion of.
3.5 Interprocess Communication Many operating systems provide mechanisms for interprocess communication (IPC) –Processes must communicate with one another.
Based on Silberschatz, Galvin and Gagne  2009 Threads Definition and motivation Multithreading Models Threading Issues Examples.
3.5 Interprocess Communication
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Chapter 4: Threads Overview Multithreading.
Threads. Processes and Threads  Two characteristics of “processes” as considered so far: Unit of resource allocation Unit of dispatch  Characteristics.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Objectives Thread definitions and relationship to process Multithreading.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Chapter 4: Threads READ 4.1 & 4.2 NOT RESPONSIBLE FOR 4.3 &
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Multithreaded Programming.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 4: Threads Overview Multithreading Models Threading Issues.
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.
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 4: Threads.
Operating Systems CSE 411 CPU Management Sept Lecture 11 Instructor: Bhuvan Urgaonkar.
9/13/20151 Threads ICS 240: Operating Systems –William Albritton Information and Computer Sciences Department at Leeward Community College –Original slides.
1 From Processes to Threads. 2 Processes, Threads and Processors Hardware can interpret N instruction streams at once  Uniprocessor, N==1  Dual-core,
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Threads.
Operating System Principles Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh.
Operating Systems CMPSC 473 Threads September 16, Lecture 7 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.
Multithreading Allows application to split itself into multiple “threads” of execution (“threads of execution”). OS support for creating threads, terminating.
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 4: Threads.
Silberschatz, Galvin and Gagne ©2011Operating System Concepts Essentials – 8 th Edition Chapter 4: Threads.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Operating Systems CMPSC 473 Processes (4) September Lecture 10 Instructor: Bhuvan Urgaonkar.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 13 Threads Read Ch 5.1.
Operating Systems CMPSC 473 Lecture 8: Threads September Instructor: Bhuvan Urgaonkar.
Source: Operating System Concepts by Silberschatz, Galvin and Gagne.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Chapter 4: Threads Overview Multithreading.
Chapter 4: Threads. 2 Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads.
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.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 4: Threads Modified from the slides of the text book. TY, Sept 2010.
Multithreaded Programing. Outline Overview of threads Threads Multithreaded Models  Many-to-One  One-to-One  Many-to-Many Thread Libraries  Pthread.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 4: Threads.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Chapter 4: Threads Overview Multithreading.
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
Operating Systems CMPSC 473 Processes (6) September Lecture 12 Instructor: Bhuvan Urgaonkar.
Department of Computer Science and Software Engineering
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Threads.
Lecture 3 Threads Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
Operating Systems CMPSC 473 Processes (3) September Lecture 9 Instructor: Bhuvan Urgaonkar.
Saurav Karmakar. Chapter 4: Threads  Overview  Multithreading Models  Thread Libraries  Threading Issues  Operating System Examples  Windows XP.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-2: Threads Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
Operating System Concepts
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Lecturer 3: Processes multithreaded Operating System Concepts Process Concept Process Scheduling Operation on Processes Cooperating Processes Interprocess.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
1 Chapter 5: Threads Overview Multithreading Models & Issues Read Chapter 5 pages
Lecture 5. Example for periority The average waiting time : = 41/5= 8.2.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Threads.
Operating Systems CMPSC 473
Chapter 4: Multithreaded Programming
Threads & multithreading
Chapter 4: Threads.
Chapter 4: Threads.
Chapter 4: Threads.
Presentation transcript:

Operating Systems CMPSC 473 Processes (5) September Lecture 11 Instructor: Bhuvan Urgaonkar

Announcements Quiz 1 will be out tonight and due in a week Suggested reading: Chapter 4 of SGG If you want to do more work/learn more things –Get in touch with us –We can provide more work in your projects Honors credits? Honors thesis? Just for fun?! Impress me and get good letters when you apply to grad school?

Overview of Process- related Topics How a process is born –Parent/child relationship –fork, clone, … How it leads its life –Loaded: Later in the course –Executed CPU scheduling Context switching Where a process “lives”: Address space –OS maintains some info. for each process: PCB –Process = Address Space + PCB How processes request services from the OS –System calls How processes communicate Some variants of processes: LWPs and threads How processes die Done Partially done Done Start today

codedatafiles registersstack heap The notion of a thread Roughly, a flow of execution that is a basic unit of CPU utilization –E.g., a process, a KCP Note: this is not showing an address space (Fig. 4.1 from GGN) thread A single-threaded process

Multi-process Applications Many applications need to do multiple activities simultaneously –E.g., Web browser Parse requested URL and find IP address from DNS server Use system calls to send request to some Web server Receive response Assemble response and display it –Can you give another example? Solution #1: Write multi-process application as follows: –forks off multiple processes, each responsible for a certain “flow of execution” Programmer’s choice/decision –Employ IPC mechanisms for these processes to communicate (coming up soon) We already know about signals, how many have used pipes? Shared memory? –Employ synchronization (ccoming up in a few lectures) We would like these “flows of execution” (and not just the initiating process or the entire application) to be the basic unit across which CPU is partitioned (schedulable entity) –Why? –What about resources other than the CPU? (Will discuss this in a little while) –The OS design we have studied so far already achieves this

Multi-process Applications Many applications need to do multiple activities simultaneously –E.g., Web browser Parse requested URL and find IP address from DNS server Use system calls to send request to some Web server Receive response Assemble response and display it –Can you give another example? Approach #1: Write multi-process application as follows: –forks off multiple processes, each responsible for a certain “flow of execution” Programmer’s choice/decision –Employ IPC mechanisms for these processes to communicate (coming up soon) We already know about signals, how many have used pipes? Shared memory? –Employ synchronization (coming up in a few lectures) We would like these “flows of execution” (and not just the initiating process or the entire application) to be the basic unit across which CPU is partitioned (schedulable entity) –Why? –What about resources other than the CPU? (Will discuss this in a little while) –The OS design we have studied so far already achieves this

Multi-process Applications Many applications need to do multiple activities simultaneously –E.g., Web browser Parse requested URL and find IP address from DNS server Use system calls to send request to some Web server Receive response Assemble response and display it –Can you give another example? Approach #1: Write multi-process application as follows: –forks off multiple processes, each responsible for a certain “flow of execution” Programmer’s choice/decision –Employ IPC mechanisms for these processes to communicate (coming up soon) We already know about signals, how many have used pipes? Shared memory? –Employ synchronization (coming up in a few lectures) We would like these “flows of execution” (and not just the initiating process or the entire application) to be the basic unit across which CPU is partitioned (schedulable entity) –Why? –What about resources other than the CPU? (Will discuss this again for VMM and IO) –The OS design we have studied so far already achieves this

Approach #1: Writing a multi-process Application E.g., a Web browser What’s wrong with (or lacking in) this approach to programming? –Hint: Approach #1 has performance problems, although it is great for the programmer (why?) Potentially lot of redundancy in code and data segments! –Virtual memory wastage => More contention for precious RAM codedatafiles registersstack heap URL parsing process codedatafiles registersstack heap codedatafiles registersstack heap codedatafiles registersstack heap Network sending process Network reception process Interprets response, composes media together and displays on browser screen In virtual memory

Approach #1: Writing a multi-process Application E.g., a Web browser What’s wrong with (or lacking in) this approach to programming? –Hint: Approach #1 has performance problems, although it is great for the programmer (why?) Potentially, lot of redundancy in code and data segments! –Virtual memory wastage => More contention for precious RAM => More work for the memory manager => Reduction in computer’s throughput URL parsing processNetwork sending process Network reception process Interprets response, composes media together and displays on browser screen In virtual memory codedatafiles registersstack heap codedatafiles registersstack heap codedatafiles registersstack heap codedatafiles registersstack heap

Approach #2: Share code, data, files! E.g., a Web browser Share code, data, files (mmaped), via shared memory mechanisms (coming up) –Burden on the programmer Better yet, let kernel or a user-library handle sharing of these parts of the address spaces and let the programmer deal with synchronization issues –User-level and kernel-level threads URL parsing processNetwork sending process Network reception process Interprets response, composes media together and displays on browser screen In virtual memory codedata files registersstack heap registersstackregistersstackregistersstack

Approach #3: User or kernel support to automatically share code, data, files! E.g., a Web browser Share code, data, files (mmaped), via shared memory mechanisms (coming up) –Burden on the programmer Better yet, let kernel or a user-library handle sharing of these parts of the address spaces and let the programmer deal only with synchronization issues URL parsing processNetwork sending process Network reception process Interprets response, composes media together and displays on browser screen In virtual memory codedata files registersstack heap registersstackregistersstackregistersstack threads

Approach #3: User or kernel support to automatically share code, data, files! E.g., a Web browser Share code, data, files (mmaped), via shared memory mechanisms (coming up) –Burden on the programmer Better yet, let kernel or a user-library handle sharing of these parts of the address spaces and let the programmer deal with synchronization issues –User-level and kernel-level threads URL parsing processNetwork sending process Network reception process Interprets response, composes media together and displays on browser screen In virtual memory codedata files registersstackregistersstackregistersstackregistersstack threads heap

Multi-threading Models User-level thread libraries –E.g., the one provided with Project 1 –Implementation: You are expected to gain this understanding as you work on Project 1 –Pop quiz: Context switch overhead smaller. Why? –What other overheads are reduced? Creation? Removal? Kernel-level threads There must exist some relationship between user threads and kernel threads –Why? Which is better?

Multi-threading Models: Many-to-one Model Thread management done by user library Context switching, creation, removal, etc. efficient (if designed well) Blocking call blocks the entire process No parallelism on uPs? Why? Green threads library on Solaris k Kernel thread User thread

Multi-threading Models: One-to-many Model Each u-l thread mapped to one k-l thread Allows more concurrency –If one thread blocks, another ready thread can run –Can exploit parallelism on uPs Popular: Linux, several Windows (NT, 2000, XP) kkkk Kernel thread User thread

Multi-threading Models: Many-to-many Model # u-l threads >= #k-l threads Best of both previous approaches? kkk Kernel thread User thread