CSE 451 Autumn 2003 Section 3 October 16.

Slides:



Advertisements
Similar presentations
Operating Systems Semaphores II
Advertisements

3.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process An operating system executes a variety of programs: Batch system.
CSE 451: Operating Systems Section 6 Project 2b; Midterm Review.
1 CS318 Project #3 Preemptive Kernel. 2 Continuing from Project 2 Project 2 involved: Context Switch Stack Manipulation Saving State Moving between threads,
Precept 3 COS 461. Concurrency is Useful Multi Processor/Core Multiple Inputs Don’t wait on slow devices.
Server Architecture Models Operating Systems Hebrew University Spring 2004.
Threads 1 CS502 Spring 2006 Threads CS-502 Spring 2006.
Monitors CSCI 444/544 Operating Systems Fall 2008.
CSSE Operating Systems
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Ch 4: Threads Dr. Mohamed Hefeeda.
CPS110: Implementing threads/locks on a uni-processor Landon Cox.
CSE 451: Operating Systems Section 5: Synchronization.
Scheduler Activations Jeff Chase. Threads in a Process Threads are useful at user-level – Parallelism, hide I/O latency, interactivity Option A (early.
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
CS252: Systems Programming Ninghui Li Final Exam Review.
Introduction to Processes CS Intoduction to Operating Systems.
CE Operating Systems Lecture 10 Processes and process management in Linux.
4P13 Week 3 Talking Points 1. Process State 2 Process Structure Catagories – Process identification: the PID and the parent PID – Signal state: signals.
CS333 Intro to Operating Systems Jonathan Walpole.
Linux Processes Travis Willey Jeff Mihalik. What is a process? A process is a program in execution A process includes: –program counter –stack –data section.
Java Thread and Memory Model
Discussion Week 2 TA: Kyle Dewey. Overview Concurrency Process level Thread level MIPS - switch.s Project #1.
Multithreaded Programing. Outline Overview of threads Threads Multithreaded Models  Many-to-One  One-to-One  Many-to-Many Thread Libraries  Pthread.
Week 3 January 22, 2004 Adrienne Noble. Today CVS – a great tool to use with your groups Threads – basic thread operations Intro to synchronization Hand.
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
CS399 New Beginnings Jonathan Walpole. 2 Concurrent Programming & Synchronization Primitives.
CSCI1600: Embedded and Real Time Software Lecture 17: Concurrent Programming Steven Reiss, Fall 2015.
CSE 451: Operating Systems Section 6 Project 2b. Midterm  Scores will be on Catalyst and midterms were handed back on Friday(?) in class  Talk to Ed,
CS162 Section 2. True/False A thread needs to own a semaphore, meaning the thread has called semaphore.P(), before it can call semaphore.V() False: Any.
CSE 451 Section #3. Questions from Lecture Kinds of threads When threads are used How threads are implemented Scheduling.
Introduction to threads
CS703 - Advanced Operating Systems
Processes and threads.
CMSC621: Advanced Operating Systems Advanced Operating Systems
Process Management Process Concept Why only the global variables?
PROCESS MANAGEMENT IN MACH
CS703 – Advanced Operating Systems
January 29, 2004 Adrienne Noble
CS399 New Beginnings Jonathan Walpole.
Threading and Project 2 (Some slides taken from Sec. 3 Winter 2006)
Section 10: Last section! Final review.
CSE451 Basic Synchronization Spring 2001
Linux kernel: Processes, threads and scheduling
CS 143A Quiz 1 Solution.
Light-weight Contexts: An OS Abstraction for Safety and Performance
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Jonathan Walpole Computer Science Portland State University
Processes and Threads.
Thread Implementation Issues
Threads Chapter 5 2/17/2019 B.Ramamurthy.
CSCI1600: Embedded and Real Time Software
Jonathan Walpole Computer Science Portland State University
Threads Chapter 5 2/23/2019 B.Ramamurthy.
Still Chapter 2 (Based on Silberchatz’s text and Nachos Roadmap.)
October 9, 2002 Gary Kimura Lecture #5 October 9, 2002
Why Threads Are A Bad Idea (for most purposes)
CSE 451: Operating Systems Autumn 2003 Lecture 7 Synchronization
CSE 451: Operating Systems Autumn 2005 Lecture 7 Synchronization
CSE 153 Design of Operating Systems Winter 19
CSE 153 Design of Operating Systems Winter 2019
CS333 Intro to Operating Systems
CSCI1600: Embedded and Real Time Software
CSE 153 Design of Operating Systems Winter 2019
Concurrency, Processes and Threads
CSE 451 Section 1/27/2000.
Why Threads Are A Bad Idea (for most purposes)
Why Threads Are A Bad Idea (for most purposes)
CS703 – Advanced Operating Systems
Monitors and Inter-Process Communication
Threads CSE 2431: Introduction to Operating Systems
Presentation transcript:

CSE 451 Autumn 2003 Section 3 October 16

Questions from lecture Threads vs. processes? Kernel vs. user threads?

Homeworks Context Switches Threads vs. processes

Threads in the real world Linux: Kernel only knows about processes (called tasks) Threads are implemented by allowing portions of a process to be shared Clone() system call implements fork with varying degrees of sharing Nothing Address space Address space plus file descriptors Implementation:???

Windows Full kernel thread support Process has no context information Thread has no resource information Process points to list of threads, threads point to containing process Scheduler only looks at threads Why the difference?

Who uses threads? Web servers Databases Web browsers Scientific programs Word processors

Project questions? You will implement threads You will implement mutexes and condition variables

Simple Threads sthread_new_ctx sthread_fee_ctx sthread_switch: creates a new thread context that can be switched to calls the supplied function with no parameters sthread_fee_ctx Deletes the supplied context sthread_switch: saves current context switches to supplied context sthread_queue.h: generic queue implementation: when do you need a queue?

Threads Hints: Handling the initial thread Starting up a thread hint: you don’t need context information for a thread while it is running - only when it is waiting to run Starting up a thread The supplied routine for creating a thread (sthread_new_ctx) doesn’t pass parameters to the function it runs How do you pass parameters to a function with no arguments?

Mutexes Simple locks that prevent two threads from executing Usage: sthread_user_mutex_init() to initialize sthread_user_mutex_lock() Only one thread can do this at a time sthread_user_mutex_unlock() Lets another thread continue past lock sthread_user_mutex_free() Frees lock (can’t be any waiters)

Mutex Example int I = 0; void update() { sthread_mutex_lock(mtx); } sthread_mutex_unlock(mtx); }

Condition variables Used to signal another thread that a condition is true Usage: c = sthread_user_cond_init() to initialize sthread_user_cond_free(c) to free sthread_user_cond_wait(c,mtx) Waits until signal unlocks mtx before waiting locks mtx before returning sthread_user_cond_signal(c) Wakes up one waiter sthread_user_cond_broadcast(c) Wakes up all users

Condition Variable Example sthread_mutex_lock(mtx); while (empty(buffer)) { sthread_cond_wait(c, mtx); } process_buffer(buffer); sthread_mutex_unlock(mtx); ---------- buffer[i++]= x sthread_cond_signal(c);

How are threads used? Thread-per-pipeline stage Thread-per-request Thread pools

Thread pools Save on cost of creating threads Limits number of threads (you see how many are useful)

Thread pool pattern One thread accepts requests, puts them in a queue Pool threads wait on queue When triggered, wake up and do work Else sleep Can dynamically grow/shrink