The Zen of Threads When you can snatch the lock from the object, grasshopper, then you are ready to spawn the thread...

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

Chapter 4 Threads Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William.
Threads, SMP, and Microkernels
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.
Chorus and other Microkernels Presented by: Jonathan Tanner and Brian Doyle Articles By: Jon Udell Peter D. Varhol Dick Pountain.
Chapter 4 Threads, SMP, and Microkernels Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design.
Day 10 Threads. Threads and Processes  Process is seen as two entities Unit of resource allocation (process or task) Unit of dispatch or scheduling (thread.
Chapter 4: Threads. Overview Multithreading Models Threading Issues Pthreads Windows XP Threads.
1 Last Time: OS & Computer Architecture Modern OS Functionality (brief review) Architecture Basics Hardware Support for OS Features.
1 Processes and Pipes COS 217 Professor Jennifer Rexford.
Processes CSCI 444/544 Operating Systems Fall 2008.
The Zen of Threads. 3 Types of Execution Single, lone process doing all the work No problems with multiple-access Can be inconvenient/inefficient -- blocking,
Ceng Operating Systems Chapter 2.5 : Threads Process concept  Process scheduling  Interprocess communication  Deadlocks  Threads.
Threads - Definition - Advantages using Threads - User and Kernel Threads - Multithreading Models - Java and Solaris Threads - Examples - Definition -
The Zen of Threads When you can snatch the lock from the object, grasshopper, then you are ready to spawn the thread...
Threads CSCI 444/544 Operating Systems Fall 2008.
1 Chapter 4 Threads Threads: Resource ownership and execution.
Inter-Process Communication  most OSs provide several abstractions for inter- process communication: message passing, shared memory, etc.  communication.
Threads. Processes and Threads  Two characteristics of “processes” as considered so far: Unit of resource allocation Unit of dispatch  Characteristics.
A. Frank - P. Weisberg Operating Systems Introduction to Tasks/Threads.
Threads Chapter 4. Modern Process & Thread –Process is an infrastructure in which execution takes place  (address space + resources) –Thread is a program.
The Zen of Threads When you can snatch the lock from the object, grasshopper, then you are ready to spawn the thread... Lecture 18, Nov 03.
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, SMP, and Microkernels Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E.
1 Lecture 4: Threads Operating System Fall Contents Overview: Processes & Threads Benefits of Threads Thread State and Operations User Thread.
Multithreading Allows application to split itself into multiple “threads” of execution (“threads of execution”). OS support for creating threads, terminating.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Threads, SMP, and Microkernels Chapter 4. 2 Outline n Threads n Symmetric Multiprocessing (SMP) n Microkernel n Linux Threads.
Chapter 4 Threads, SMP, and Microkernels Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design.
ICOM 6115©Manuel Rodriguez-Martinez ICOM 6115 – Computer Networks and the WWW Manuel Rodriguez-Martinez, Ph.D. Lecture 6.
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
Processes and Threads Processes have two characteristics: – Resource ownership - process includes a virtual address space to hold the process image – Scheduling/execution.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Threads G.Anuradha (Reference : William Stallings)
Processes Introduction to Operating Systems: Module 3.
CS533 - Concepts of Operating Systems 1 The Mach System Presented by Catherine Vilhauer.
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.
Department of Computer Science and Software Engineering
Operating Systems: Internals and Design Principles
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Processes and Threads.
1 Chapter 2.5 : Threads Process concept  Process concept  Process scheduling  Process scheduling  Interprocess communication  Interprocess communication.
Threads. Readings r Silberschatz et al : Chapter 4.
Goals for Today How do we provide multiprogramming? What are Processes? How are they related to Threads and Address Spaces? Note: Some slides and/or pictures.
Chapter 4 Threads, SMP, and Microkernels Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E.
1 Threads, SMP, and Microkernels Chapter 4. 2 Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
Processes Chapter 3. Processes in Distributed Systems Processes and threads –Introduction to threads –Distinction between threads and processes Threads.
Embedded Real-Time Systems
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Introduction to Kernel
Processes and threads.
Chapter 3: Process Concept
Processes and Threads Processes and their scheduling
Threads and Scheduling
Chapter 4: Multithreaded Programming
Process Management Presented By Aditya Gupta Assistant Professor
Chapter 4 Threads.
Operating Systems Processes and Threads.
ICS 143 Principles of Operating Systems
Threads and Data Sharing
More examples How many processes does this piece of code create?
Operating Systems Threads ENCE 360.
Threads Chapter 4.
CSE 451: Operating Systems Autumn 2003 Lecture 5 Threads
Threads and Concurrency
Threads Chapter 4.
Threads CSE 2431: Introduction to Operating Systems
CS Introduction to Operating Systems
Presentation transcript:

The Zen of Threads When you can snatch the lock from the object, grasshopper, then you are ready to spawn the thread...

Time keeps on rollin’... Last time: Quiz 2 P3 assigned This time: Threads vs. procs Synchronization Fail fast principle (maybe)

Three models of execution Single process, running alone Multiple access? No worries Can be inconvenient/inefficient -- single user, blocking, etc. Multiple procs, comm via sockets/pipes/etc. More efficient: no blocking, >1 user, etc. Data sharing: hard -- all via messages Little synchronization problem

Three modes of execution Threads Called “light weight processes” Efficient: >1 user, no blocking, efficient use of resources Data sharing: shared memory Multiple threads read/write same memory space Synchronization: very tricky

Multi-process model Process (UNIX sense): Separate program, running in own memory space, independent of all other programs/processes on computer Each process has own copy of: Program instructions/code (“text” segment) Program counter (PC) Registers Method local variables (stack) Object local variables (heap)

Multi-process model

Multi-process commun. Process separation enforced by kernel & hardware Communication via kernel mechanisms File I/O Sockets Pipes FIFOs etc. New process created via: fork() (UNIX system call) Process.start() or Runtime.exec() (Java)

Inter-process comm. pipe.write() pipe.read()

Multi-thread model Threads run within a single process Each thread has its own Program counter (PC) Registers Method-local variables (stack) All threads in a single process share: Program instructions/code (text) Object local variables/“main memory” (heap) No kernel/hardware separation! All separation is done by you!

The joy/hazards of threads All threads share same memory Communication is trivial All threads share same memory Incredibly easy to stomp on another thread’s data! Two threads can write to same data at same time, or can read/write same data at same time Inconsistent data state Violates pre/post conditions & expectations There be monsters...

The Multi-Thread Model

Thread communication