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.

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.
Threads, SMP, and Microkernels Chapter 4. Process Resource ownership - process is allocated a virtual address space to hold the process image Scheduling/execution-
Chapter 4 Threads, SMP, and Microkernels Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design.
Computer Systems/Operating Systems - Class 8
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 Threads, SMP, and Microkernels Chapter 4. 2 Process: Some Info. Motivation for threads! Two fundamental aspects of a “process”: Resource ownership Scheduling.
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,
Introduction to Kernel
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.
Threads. Processes and Threads  Two characteristics of “processes” as considered so far: Unit of resource allocation Unit of dispatch  Characteristics.
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...
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.
CS 162 Discussion Section Week 1 (9/9 – 9/13) 1. Who am I? Kevin Klues Office Hours:
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.
Operating System 4 THREADS, SMP AND MICROKERNELS
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,
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Threads G.Anuradha (Reference : William Stallings)
1 Threads, SMP, and Microkernels Chapter Multithreading Operating system supports multiple threads of execution within a single process MS-DOS.
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
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Processes and Threads.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
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.
What is a Process ? A program in execution.
Chapter 4 Threads, SMP, and Microkernels Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E.
Operating Systems CMPSC 473 Processes (5) September Lecture 11 Instructor: Bhuvan Urgaonkar.
1 Threads, SMP, and Microkernels Chapter 4. 2 Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-
Threads, SMP, and Microkernels Chapter 4. Processes and Threads Operating systems use processes for two purposes - Resource allocation and resource ownership.
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
1 Chapter 5: Threads Overview Multithreading Models & Issues Read Chapter 5 pages
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
Threads and Scheduling
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?
Lecture 10: Threads Implementation
Mid Term review CSC345.
Threads Chapter 4.
Lecture 4- Threads, SMP, and Microkernels
Threads and Concurrency
Threads Chapter 4.
Lecture 10: Threads Implementation
Operating Systems: A Modern Perspective, Chapter 6
CSE 153 Design of Operating Systems Winter 2019
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... Lecture 18, Nov 03

Administrivia P3 reminders: Send me/Nick your group members and team name Schedule P3M1 meeting with us Nov 11 coming up like a freight train… So far, only 1 group has started scheduling process I’m out of town on Mon, Nov 9

Now and then Last time: Quiz 2 P2 Rollout P3 handed out; discussion Today: Beginning of Threads Beginning of Graphics2d

Threading intro

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/files 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 Data corruption is trivial... 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

Context switch: Design Principle o’ the Day

Design principle: Interfaces Make your interfaces sophisticated, so that your algorithms can be simple.

Design principle: Interfaces More modularity: break code into small chunks Algorithms are hard to debug Make them as readable/comprehensible as possible Note: sophisticated, not complicated Make your interfaces sophisticated, so that your algorithms can be simple.

Intro to AWT Graphics