What we will learn. Multi Process Systems: Processes &Threads. Architectural support: Processor Modes. Processes (classic vs.

Size: px
Start display at page:

Download "What we will learn. Multi Process Systems: Processes &Threads. Architectural support: Processor Modes. Processes (classic vs."

Transcription

1 What we will learn Multi Systems: es &Threads A thread-driven approach is attractive in sensor networks for many of the same reasons that it has been adopted for PDAs, laptops, and servers. In a thread-driven system, an application programmer need not be concerned about indefinitely blocking or being indefinitely blocked by other tasks during execution, except for shared resources, because the scheduler will preemptively time-slice between threads, allowing some tasks to continue execution even though others may be blocked. This automated time-slicing considerably simplifies programming for an application developer. es (classic vs. modern) ST OS MT OS MP OS { Bag of functions & procedures Coroutines weak AUCs Threads es AUCs (AUCs) (AUCs) AUCs (AUCs) Architectural support: or Modes Mode bit: Supervisor or User mode Supervisor mode Can execute all machine instructions Can reference all memory locations User mode Can only execute a subset of instructions Can only reference a subset of memory locations

2 Architectural support: or Modes Total CPU time percentage Architectural support: or Modes The status register contains information about the status of features of the computer that can be set by the processor while in kernel mode Kernel mode time percentage indicates whether the processor was in kernel or user mode when the last exception occurred indicates whether current status is kernel or user Architectural support: or Modes (MIPS) The processor contains registers useful for handling exceptions but is not accessible in user mode. the status register, cause register, BadVaddr, and EPC (exception program counter). Architectural support: or Modes (MIPS) name number information BadVaddr 8 memory address at which address exception occurred Status 12 interrupt mask and enable bits Cause 13 exception type and pending interrupts EPC(IAR) 14 address of instruction that caused exception

3 Architectural support: or Modes (MIPS) The status register contains information about the status of features of the computer that can be set by the processor while in kernel mode indicates whether the processor was in kernel or user mode when the last exception occurred Mode: 1=user, 0=kernel Enable: 1=on, 0=off indicates whether current status is kernel or user Mode Enable Mode Enable Mode Enable Old Prev Cur Kernels The part of the OS critical to correct operation (trusted software) Executes in supervisor mode The trap instruction is used to switch from user to supervisor mode, entering the OS What happens on a trap/interrupt? 1. Hardware saves program counter (on stack or in a special register) 2. Hardware loads new PC, identifies interrupt 3. Assembly language routine saves registers 4. Assembly language routine sets up stack 5. Assembly language calls C to run service routine 6. Service routine calls scheduler 7. Scheduler selects a process to run next (might be the one interrupted) What happens on a trap? OS runs in privileged mode Some operations are permitted only in privileged (also called supervisor or system) mode Example: access a device like a disk or network card Example: change allocation of memory to processes User programs run in user mode and can t do the operations Programs want the OS to perform a service Operating Systems and 11Distributed Systems Operating Systems and 12Distributed Systems

4 How system calls work User program enters supervisor mode Must enter via well-defined entry point Program passes relevant information to OS OS performs the service if The OS is able to do so The service is permitted for this program at this time OS checks information passed to make sure it s OK Don t want programs reading data into other System call: Sleep() Program pushes arguments, calls library Library sets up trap, calls OS OS handles system call Control returns to library Library returns to user program 0xffffffff User space Kernel space (OS) Return to caller Trap to kernel Trap code in register Increment SP Call Sleep Push arguments 5 6 Dispatch 9 8 Sys call handler Library (Sleep call) 7 User code Operating Systems and 13Distributed Systems Operating Systems and 14Distributed Systems traps.h #define! TRAP_SLEEP! 0x410 process.h extern void!sleep (void); Supervisor and User Memory ;;; Stub functions for traps..proc _Sleep.global _Sleep _Sleep:!! trap! #0x410!! nop! jr! r31! nop.endproc _Sleep.proc _intrhandler.global _intrhandler _intrhandler:... ;; push regs on stack j! _dointerrupt!.endproc _intrhandler #include <sys/process.h > void main(){!...! Sleep();!... } void dointerrupt (unsigned int cause, unsigned int iar, unsigned int isr,! uint32 *trapargs) { // TRAP_INSTR bit is set: trap instruction. // bit isn't set:system interrupt. if (cause & TRAP_TRAP_INSTR) {... switch (cause) { case TRAP_SLEEP: Suspend (currentpcb); Schedule (); break;... intrreturn (); } User Supervisor User Space Supervisor Space STATUS register.proc! _intrreturn!.global!_intrreturn _intrreturn:! ;; Disable interrupts CAUSE register...;; Reload the regs for new process..endproc _intrreturn

5 Threads, es, Modern es Implementing the Abstraction P i CPU P j CPU P k CPU Thread P i Executable Memory P j Executable Memory P k Executable Memory OS interface Thread Thread Thread Thread CPU ALU Control Unit OS Address Space P i Address Space P k Address Space P j Address Space Machine Executable Memory What s in a process? The Address Space A process consists of (at least): an address space the code for the running program the data for the running program an execution stack and stack pointer (SP) traces state of procedure calls made the program counter (PC), indicating the next instruction general-purpose processor registers and their values 0xFFFFFFFF address space 0x stack (dynamic allocated mem) heap (dynamic allocated mem) static data (data segment) code (text segment) SP PC Operating Systems and 19Distributed Systems Operating Systems and 20Distributed Systems

6 The Address Space Address Space Address Binding Executable Memory Files Other objects Building the Address Space Some parts are built into the environment Files System services Some parts are imported at runtime Mailboxes Network connections Memory addresses are created at compile (and run) time Manager Overview Program Device Manager Devices File Manager Abstract Computing Environment Memory Manager Memory Protection Deadlock Synchronization Scheduler CPU Description Resource Resource Manager Resource Manager Manager Other H/W Libraries Device Manager UNIX Organization File Manager Memory Manager Monolithic Kernel Devices Memory System Call Interface Protection Deadlock Synchronization Scheduler CPU Description Resource Resource Manager Resource Manager Manager Other H/W

7 Windows NT Organization External View of the Manager User Libraries T T T Subsystem T Subsystem T T T T T Subsystem wait() fork() exec() Application Program CreateThread() CloseHandle() Create() WaitForSingleObject() NT Executive NT Kernel Hardware Abstraction Layer I/O Subsystem UNIX Device Mgr Mgr Memory Mgr File Mgr Device Mgr Mgr Memory Mgr File Mgr Windows or(s) Main Memory Devices Hardware Manager Responsibilities Define & implement the essential characteristics of a process and thread Algorithms to define the behavior Data structures to preserve the state of the execution Define what things threads in the process can reference the address space (most of the things are memory locations) Manage the resources used by the processes/threads Tools to create/destroy/manipulate processes & threads Tools to time-multiplex the CPU Scheduling Tools to allow threads to synchronization the operation with one another Mechanisms to handle deadlock Mechanisms to handle protection User Mode Instructions The Abstract Machine Interface Application Program User Mode Instructions Trap Instruction Abstract Machine Instructions OS open() Supervisor Mode Instructions create() fork()

8 Machine is Powered up Hardware process progress Tracing the Hardware Load the kernel Initialization Execute a thread Schedule Bootstap Service an interrupt Loader Manager Interrupt Handler P 1 P,2 P n Interrupt Context Switching Initialization Executable Memory 2 Manager Interrupt Handler P 1 P P n Descriptors There s a data structure called the process control block (PCB) that holds all this stuff The PCB is identified by an integer process ID (PID) OS keeps all of a process s hardware execution state in the PCB when the process isn t running PC, SP, registers, etc. when a process is unscheduled, the state is transferred out of the hardware into the PCB Note: It s natural to think that there must be some esoteric techniques being used fancy data structures that d you d never think of yourself Wrong! It s pretty much just what you d think of! Descriptors ID Pointer to parent List of children state Pointer to address space descriptor Program count stack pointer (all) register values uid (user id) gid (group id) euid (effective user id) Open file list Scheduling priority Accounting info Pointers for state queues This is (a simplification of) what each of those PCBs looks like inside! 12/31/ Gribble, Lazowska, Levy, Zahorjan 31 Exit ( return ) code value 32

9 What s in a process table entry? Unix Descriptor May be stored on stack management Registers Program counter CPU status word Stack pointer state Priority / scheduling parameters ID Parent process ID Signals start time Total CPU usage File management Root directory Working (current) directory File descriptors User ID Group ID Memory management Pointers to text, data, stack! or Pointer to page table Operating Systems and 33Distributed Systems Linux Descriptor Windows NT Descriptor NT Kernel EPROCESS KPROCESS uint32 KernelTime; uint32 UserTime; Byte state; NT Executive void *UniqueId;

10 Windows NT Thread Descriptor EPROCESS KPROCESS ETHREAD KTHREAD NT Kernel NT Executive When is a process created? es can be created in two ways System initialization (creatio ex nihilo): one or more processes created when the OS starts up Execution of a process creation system call: something explicitly asks for a new process System calls can come from User request to create a new process (system call executed from user shell) Already running processes User programs System daemons Operating Systems and 38Distributed Systems Creating a in UNIX Creating a in NT Create(); pid = fork(); Table UNIX kernel Win32 Subsystem ntcreate(); ntcreatethread(); NT Executive Descriptor Handle Table Descriptor NT Kernel

11 Windows NT Handles states Each process has an execution state, which indicates what it is currently doing ready: waiting to be assigned to CPU could run, but another process has the CPU running: executing on the CPU is the process that currently controls the CPU pop quiz: how many processes can be running simultaneously? waiting: waiting for an event, e.g., I/O cannot make progress until event happens Operating Systems and 42Distributed Systems Simple State Diagram Done exception (I/O, page fault, etc.) Blocked Request Running dispatch / schedule interrupt (I/O complete) Ready interrupt (unschedule) Start The PCB revisited (Unix) The PCB is a data structure with many, many fields: process ID (PID) execution state program counter, stack pointer, registers address space info UNIX username of owner scheduling priority accounting info pointers for state queues In linux: defined in task_struct (include/linux/sched.h) over 95 fields!!! Operating Systems and 44Distributed Systems

12 Refined state model Linux State Transition Diagram 5 Blocked (waiting) 7 Created 1 Ready Exit 2 Running 6! in one of 5 states " Created " Ready " Running " Blocked " Exit! Transitions between states 1. enters ready queue 2. Scheduler picks this process 3. Scheduler picks a different process 4. waits for event (such as I/ O) 5. Event occurs 6. exits 7. ended by another process Request Wait by parent Done Running zombie Request Schedule Sleeping I/O Request Start Allocate Uninterruptible Sleep I/O Complete Resume Runnable Traced or Stopped Operating Systems and 45Distributed Systems Linux State Transition Diagram Windows NT Thread States TASK_INTERRUPTIBLE The process is suspended (sleeping) until some condition becomes true. Raising a hardware interrupt, releasing a system resource the process is waiting for, or delivering a signal are examples of conditions that might wake up the process (put its state back to TASK_RUNNING). TASK_UNINTERRUPTIBLE Like TASK_INTERRUPTIBLE, except that delivering a signal to the sleeping process leaves its state unchanged. This process state is seldom used. It is valuable, however, under certain specific conditions in which a process must wait until a given event occurs without being interrupted. For instance, this state may be used when a process opens a device file and the corresponding device driver starts probing for a corresponding hardware device. The device driver must not be interrupted until the probing is complete, or the hardware device could be left in an unpredictable state. TASK_STOPPED execution has been stopped; the process enters this state after receiving a SIGSTOP, SIGTSTP, SIGTTIN, or SIGTTOU signal. TASK_TRACED execution has been stopped by a debugger. When a process is being monitored by another (such as when a debugger executes a ptrace( ) system call to monitor a test program), each signal may put the process in the TASK_TRACED state. Two additional states of the process can be stored both in the state field and in the exit_state field of the process descriptor; as the field name suggests, a process reaches one of these two states only when its execution is terminated: Terminated Running Exit CreateThread Reinitialize Initialized Dispatch Activate Wait Waiting Wait Complete Ready EXIT_ZOMBIE execution is terminated, but the parent process has not yet issued a wait4( ) or waitpid( ) system call to return information about the dead process.[*] Before the wait( )-like call is issued, the kernel cannot discard the data contained in the dead process descriptor because the parent might need it. (See the section " Removal" near the end of this chapter.) [*] There are other wait( ) -like library functions, such as wait3( ) and wait( ), but in Linux they are implemented by means of the wait4( ) and waitpid( ) system calls. Wait Complete Transition Select Preempt EXIT_DEAD The final state: the process is being removed by the system because the parent process has just issued a wait4( ) or waitpid( ) system call for it. Changing its state from EXIT_ZOMBIE to EXIT_DEAD avoids race conditions due to other threads of execution that execute wait( )-like calls on the same process (see Chapter 5). The value of the state field is usually set with a simple assignment. For instance: Dispatch Standby p->state = TASK_RUNNING;

13 Modern processes: concurrency Imagine a web server, which might like to handle multiple requests concurrently While waiting for the credit card server to approve a purchase for one client, it could be retrieving the data requested by another client from disk, and assembling the response for a third client from cached information Imagine a web client (browser), which might like to initiate multiple requests concurrently The CSE home page has 46 src= html commands, each of which is going to involve a lot of sitting around! Wouldn t it be nice to be able to launch these requests concurrently? Imagine a parallel program running on a multiprocessor, which might like to employ physical concurrency For example, multiplying a large matrix split the output matrix into k regions and compute the entries in each region concurrently using k processors Operating Systems and 49Distributed Systems Modern processes: concurrency In each of these examples of concurrency (web server, web client, parallel program): Everybody wants to run the same code Everybody wants to access the same data Everybody has the same privileges Everybody uses the same resources (open files, network connections, etc.) But you d like to have multiple hardware execution states: an execution stack and stack pointer (SP) traces state of procedure calls made the program counter (PC), indicating the next instruction a set of general-purpose processor registers and their values Operating Systems and 50Distributed Systems Modern processes: concurrency Given the process abstraction as we know it: fork several processes cause each to map to the same physical memory to share data see the shmget() system call for one way to do this (kind of) This is like making a pig fly it s really inefficient space: PCB, page tables, etc. time: creating OS structures, fork and copy addr space, etc. Some equally bad alternatives for some of the examples: Entirely separate web servers Manually programmed asynchronous programming (non-blocking I/O) in the web client (browser) Can we do better? Key idea: separate the concept of a process (address space, etc.) from that of a minimal thread of control (execution state: PC, etc.) This execution state is usually called a thread, or sometimes, a lightweight process Operating Systems and 51Distributed Systems Operating Systems and 52Distributed Systems

14 Modern es and Threads Thrd j in P i Thrd k in P i Single and Multithreaded es P i CPU OS interface Threads: processes sharing memory == address space Thread == program counter / stream of instructions Two examples Three processes, each with one thread One process with three threads & thread information Per process items Address space Open files Child processes Signals & handlers Accounting info Global variables User space System space Threads Kernel Threads Kernel Per thread items Program counter Registers Stack & stack pointer State Per thread items Program counter Registers Stack & stack pointer State Per thread items Program counter Registers Stack & stack pointer State Operating Systems and 55Distributed Systems Operating Systems and 56Distributed Systems

15 Threads & stacks Multithreaded Web server Thread 1"s stack Thread 1 Thread 2 Thread 3 User space Dispatcher thread Worker thread while(true) { getnextrequest(&buf); handoffwork(&buf); } Thread 2"s stack Kernel => Each thread has its own stack! Thread 3"s stack Network connection Kernel Web page cache while(true) { waitforwork(&buf); lookforpageincache(&buf,&page); if(pagenotincache(&page)) { readpagefromdisk(&buf,&page); } returnpage(&page); } Operating Systems and 57Distributed Systems Operating Systems and 58Distributed Systems Threads and processes The design space Most modern OS s (Mach, Chorus, NT, modern UNIX) therefore support two entities: the process, which defines the address space and general process attributes (such as open files, etc.) the thread, which defines a sequential execution stream within a process A thread is bound to a single process / address space address spaces, however, can have multiple threads executing within them sharing data between threads is cheap: all see the same address space creating threads is cheap too! Threads become the unit of scheduling processes / address spaces are just containers in which threads execute Operating Systems and 59Distributed Systems Key address space thread MS/DOS Java one thread/process one process many threads/process one process Operating Systems and 60Distributed Systems one thread/process many processes many threads/process many processes older UNIXes Mach, NT, Chorus, Linux,

16 (old) address space 0xFFFFFFFF address space 0x stack (dynamic allocated mem) heap (dynamic allocated mem) static data (data segment) code (text segment) Operating Systems and 61Distributed Systems SP PC (new) address space with threads 0xFFFFFFFF address space 0x thread 1 stack thread 2 stack thread 3 stack heap (dynamic allocated mem) static data (data segment) code (text segment) Operating Systems and 62Distributed Systems SP (T1) SP (T2) SP (T3) PC (T2) PC (T1) PC (T3) /thread separation: advantages Concurrency (multithreading) is useful for: handling concurrent events (e.g., web servers and clients) building parallel programs (e.g., matrix multiply, ray tracing) improving program structure (the Java argument) Multithreading is useful even on a uniprocessor even though only one thread can run at a time Supporting multithreading that is, separating the concept of a process (address space, files, etc.) from that of a minimal thread of control (execution state), is a big win creating concurrency does not require creating new processes faster / better / cheaper Operating Systems and 63Distributed Systems Where do threads come from? Natural answer: the kernel is responsible for creating/managing threads for example, the kernel call to create a new thread would allocate an execution stack within the process address space create and initialize a Thread Control Block stack pointer, program counter, register values stick it on the ready queue we call these kernel threads Operating Systems and 64Distributed Systems

17 Where do threads come from? (2) Threads can also be managed at the user level (that is, entirely from within the process) a library linked into the program manages the threads because threads share the same address space, the thread manager doesn t need to manipulate address spaces (which only the kernel can do) threads differ (roughly) only in hardware contexts (PC, SP, registers), which can be manipulated by user-level code the thread package multiplexes user-level threads on top of kernel thread(s), which it treats as virtual processors we call these user-level threads Run-time system Implementing threads Thread table Kernel table User-level threads + No need for kernel support - May be slower than kernel threads - Harder to do non-blocking I/O Thread Kernel table Kernel-level threads + More flexible scheduling + Non-blocking I/O - Not portable Thread table Operating Systems and 65Distributed Systems Operating Systems and 66Distributed Systems Kernel Threads Supported by the Kernel Examples Windows XP/2000 Solaris Linux Tru64 UNIX Mac OS X User Threads Thread management done by user-level threads library Three primary thread libraries: POSIX Pthreads Win32 threads Java threads

18 Kernel threads OS now manages threads and processes all thread operations implemented in the kernel OS schedules all of the threads in a system one thread in a process blocks ( I/O): the OS knows about it, and can run other threads from that process possible to overlap I/O and computation inside a process Kernel threads are cheaper than processes less state to allocate and initialize Still pretty expensive for fine-grained use (e.g., orders of magnitude more expensive than a procedure call) thread operations are all system calls context switch argument checks must maintain kernel state for each thread User-level threads To make threads cheap and fast, they need to be implemented at the user level managed entirely by user-level library, e.g., libpthreads.a The thread package multiplexes user-level threads on top of kernel thread(s), which it treats as virtual processors User-level threads are small and fast each thread is represented simply by PC & registers, stack, small thread control block (TCB) creating a thread, switching between threads, and synchronizing threads are done via procedure calls no kernel involvement is necessary! user-level thread operations can be x faster than kernel threads as a result Operating Systems and 69Distributed Systems Operating Systems and 70Distributed Systems Performance example On a 700MHz Pentium running Linux : es fork/exit: 251 µs Kernel threads pthread_create()/pthread_join(): 94 µs (2.5x faster) User-level threads pthread_create()/pthread_join: 4.5 µs (another 20x faster) Performance example (2) On a 700MHz Pentium running Linux : On a DEC SRC Firefly running Ultrix, 1989 es fork/exit: 251 µs / 11,300 µs Kernel threads pthread_create()/pthread_join(): 94 µs / 948 µs (12x faster) User-level threads pthread_create()/pthread_join: 4.5 µs / 34 µs (another 28x faster) Operating Systems and 71Distributed Systems Operating Systems and 72Distributed Systems

19 The design space Kernel thread implementation address space MS/DOS one thread/process one process one thread/process many processes older UNIXes address space Mach, NT, Chorus, Linux, os kernel thread Java many threads/process one process many threads/process many processes Mach, NT, Chorus, Linux, thread CPU (thread create, destroy, signal, wait, etc.) Operating Systems and 73Distributed Systems Operating Systems and 74Distributed Systems User-level threads: conceptually user-level thread library User-level threads: implemented user-level thread library address space? os kernel Mach, NT, Chorus, Linux, (thread create, destroy, signal, wait, etc.) address space os kernel Mach, NT, Chorus, Linux, (thread create, destroy, signal, wait, etc.) kernel threads thread CPU thread CPU (kernel thread create, destroy, signal, wait, etc.) Operating Systems and 75Distributed Systems Operating Systems and 76Distributed Systems

20 User-level threads: implemented Multithreading Models user-level thread library address space Mach, NT, Chorus, Linux, (thread create, destroy, signal, wait, etc.) Many-to-One One-to-One thread os kernel CPU kernel threads Many-to-Many (kernel thread create, destroy, signal, wait, etc.) Operating Systems and 77Distributed Systems Many-to-One Many-to-One Model Many user-level threads mapped to single kernel thread Examples: Solaris Green Threads GNU Portable Threads

21 One-to-One One-to-one Model Each user-level thread maps to kernel thread Examples Windows NT/XP/2000 Linux Solaris 9 and later Many-to-Many Model Many-to-Many Model Allows many user level threads to be mapped to many kernel threads Allows the operating system to create a sufficient number of kernel threads Solaris prior to version 9 Windows NT/2000 with the ThreadFiber package

22 Two-level Model Two-level Model Similar to M:M, except that it allows a user thread to be bound to kernel thread Examples IRIX HP-UX Tru64 UNIX Solaris 8 and earlier User-level thread implementation The kernel believes the user-level process is just a normal process running code But, this code includes the thread support library + its associated thread scheduler The thread scheduler determines when a thread runs it uses queues to keep track of what threads are doing: run, ready, wait just like the OS and processes but, implemented at user-level as a library How to keep a user-level thread from hogging the CPU? Strategy 1: force everyone to cooperate a thread willingly gives up the CPU by calling yield() yield() calls into the scheduler, which context switches to another ready thread what happens if a thread never calls yield()? Strategy 2: use preemption scheduler requests that a timer interrupt be delivered by the OS periodically usually delivered as a UNIX signal (man signal) signals are just like software interrupts, but delivered to user-level by the OS instead of delivered to OS by hardware at each timer interrupt, scheduler gains control and context switches as appropriate Operating Systems and 87Distributed Systems Operating Systems and 88Distributed Systems

23 Thread context switch Very simple for user-level threads: save context of currently running thread push machine state onto thread stack restore context of the next thread pop machine state from next thread s stack return as the new thread execution resumes at PC of next thread This is all done by assembly language it works at the level of the procedure calling convention thus, it cannot be implemented using procedure calls e.g., a thread might be preempted (and then resumed) in the middle of a procedure call What if a thread tries to do I/O? The kernel thread powering it is lost for the duration of the (synchronous) I/O operation! Could have one kernel thread powering each user-level thread no real difference from kernel threads common case operations (e.g., synchronization) would be quick Could have a limited-size pool of kernel threads powering all the user-level threads in the address space the kernel will be scheduling these threads, obliviously to what s going on at user-level Operating Systems and 89Distributed Systems Operating Systems and 90Distributed Systems What if the kernel preempts a thread holding a lock? Other threads will be unable to enter the critical section and will block (stall) tradeoff, as with everything else Solving this requires coordination between the kernel and the user-level thread manager Possible solution: scheduler activations each process can request one or more kernel threads process is given responsibility for mapping user-level threads onto kernel threads kernel promises to notify user-level before it suspends or destroys a kernel thread Summary Operating Systems and 91Distributed Systems

Threads. Computer Systems. 5/12/2009 cse threads Perkins, DW Johnson and University of Washington 1

Threads. Computer Systems.   5/12/2009 cse threads Perkins, DW Johnson and University of Washington 1 Threads CSE 410, Spring 2009 Computer Systems http://www.cs.washington.edu/410 5/12/2009 cse410-20-threads 2006-09 Perkins, DW Johnson and University of Washington 1 Reading and References Reading» Read

More information

What s in a process?

What s in a process? CSE 451: Operating Systems Winter 2015 Module 5 Threads Mark Zbikowski mzbik@cs.washington.edu Allen Center 476 2013 Gribble, Lazowska, Levy, Zahorjan What s in a process? A process consists of (at least):

More information

10/10/ Gribble, Lazowska, Levy, Zahorjan 2. 10/10/ Gribble, Lazowska, Levy, Zahorjan 4

10/10/ Gribble, Lazowska, Levy, Zahorjan 2. 10/10/ Gribble, Lazowska, Levy, Zahorjan 4 What s in a process? CSE 451: Operating Systems Autumn 2010 Module 5 Threads Ed Lazowska lazowska@cs.washington.edu Allen Center 570 A process consists of (at least): An, containing the code (instructions)

More information

What s in a traditional process? Concurrency/Parallelism. What s needed? CSE 451: Operating Systems Autumn 2012

What s in a traditional process? Concurrency/Parallelism. What s needed? CSE 451: Operating Systems Autumn 2012 What s in a traditional process? CSE 451: Operating Systems Autumn 2012 Ed Lazowska lazowska @cs.washi ngton.edu Allen Center 570 A process consists of (at least): An, containing the code (instructions)

More information

Threads. Raju Pandey Department of Computer Sciences University of California, Davis Spring 2011

Threads. Raju Pandey Department of Computer Sciences University of California, Davis Spring 2011 Threads Raju Pandey Department of Computer Sciences University of California, Davis Spring 2011 Threads Effectiveness of parallel computing depends on the performance of the primitives used to express

More information

Notes. CS 537 Lecture 5 Threads and Cooperation. Questions answered in this lecture: What s in a process?

Notes. CS 537 Lecture 5 Threads and Cooperation. Questions answered in this lecture: What s in a process? Notes CS 537 Lecture 5 Threads and Cooperation Michael Swift OS news MS lost antitrust in EU: harder to integrate features Quiz tomorrow on material from chapters 2 and 3 in the book Hardware support for

More information

Questions answered in this lecture: CS 537 Lecture 19 Threads and Cooperation. What s in a process? Organizing a Process

Questions answered in this lecture: CS 537 Lecture 19 Threads and Cooperation. What s in a process? Organizing a Process Questions answered in this lecture: CS 537 Lecture 19 Threads and Cooperation Why are threads useful? How does one use POSIX pthreads? Michael Swift 1 2 What s in a process? Organizing a Process A process

More information

Threads Implementation. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Threads Implementation. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University Threads Implementation Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Today s Topics How to implement threads? User-level threads Kernel-level

More information

CSE325 Principles of Operating Systems. Processes. David P. Duggan February 1, 2011

CSE325 Principles of Operating Systems. Processes. David P. Duggan February 1, 2011 CSE325 Principles of Operating Systems Processes David P. Duggan dduggan@sandia.gov February 1, 2011 Today s Goal: 1. Process Concept 2. Process Manager Responsibilities 3. Process Scheduling 4. Operations

More information

Threads Implementation. Jo, Heeseung

Threads Implementation. Jo, Heeseung Threads Implementation Jo, Heeseung Today's Topics How to implement threads? User-level threads Kernel-level threads Threading models 2 Kernel/User-level Threads Who is responsible for creating/managing

More information

Chapter 4: Threads. Operating System Concepts 8 th Edition,

Chapter 4: Threads. Operating System Concepts 8 th Edition, Chapter 4: Threads, Silberschatz, Galvin and Gagne 2009 Chapter 4: Threads Overview Multithreading Models Thread Libraries 4.2 Silberschatz, Galvin and Gagne 2009 Objectives To introduce the notion of

More information

CSE 120 Principles of Operating Systems

CSE 120 Principles of Operating Systems CSE 120 Principles of Operating Systems Fall 2000 Lecture 5: Threads Geoffrey M. Voelker Processes Recall that a process includes many things An address space (defining all the code and data pages) OS

More information

CSE 120 Principles of Operating Systems

CSE 120 Principles of Operating Systems CSE 120 Principles of Operating Systems Fall 2015 Lecture 4: Threads Geoffrey M. Voelker Announcements Project 0 due Project 1 out October 6, 2015 CSE 120 Lecture 4 Threads 2 Processes Recall that a process

More information

CSE 120 Principles of Operating Systems

CSE 120 Principles of Operating Systems CSE 120 Principles of Operating Systems Spring 2009 Lecture 4: Threads Geoffrey M. Voelker Announcements Homework #1 due now Project 0 due tonight Project 1 out April 9, 2009 CSE 120 Lecture 4 Threads

More information

CSCE 313 Introduction to Computer Systems. Instructor: Dezhen Song

CSCE 313 Introduction to Computer Systems. Instructor: Dezhen Song CSCE 313 Introduction to Computer Systems Instructor: Dezhen Song Programs, Processes, and Threads Programs and Processes Threads Programs, Processes, and Threads Programs and Processes Threads Processes

More information

CSCE 313: Intro to Computer Systems

CSCE 313: Intro to Computer Systems CSCE 313 Introduction to Computer Systems Instructor: Dr. Guofei Gu http://courses.cse.tamu.edu/guofei/csce313/ Programs, Processes, and Threads Programs and Processes Threads 1 Programs, Processes, and

More information

Outline. Threads. Single and Multithreaded Processes. Benefits of Threads. Eike Ritter 1. Modified: October 16, 2012

Outline. Threads. Single and Multithreaded Processes. Benefits of Threads. Eike Ritter 1. Modified: October 16, 2012 Eike Ritter 1 Modified: October 16, 2012 Lecture 8: Operating Systems with C/C++ School of Computer Science, University of Birmingham, UK 1 Based on material by Matt Smart and Nick Blundell Outline 1 Concurrent

More information

I.-C. Lin, Assistant Professor. Textbook: Operating System Concepts 8ed CHAPTER 4: MULTITHREADED PROGRAMMING

I.-C. Lin, Assistant Professor. Textbook: Operating System Concepts 8ed CHAPTER 4: MULTITHREADED PROGRAMMING I.-C. Lin, Assistant Professor. Textbook: Operating System Concepts 8ed CHAPTER 4: MULTITHREADED PROGRAMMING Chapter 4: Multithreaded Programming Overview Multithreading Models Thread Libraries Threading

More information

Lecture 4: Threads; weaving control flow

Lecture 4: Threads; weaving control flow Lecture 4: Threads; weaving control flow CSE 120: Principles of Operating Systems Alex C. Snoeren HW 1 Due NOW Announcements Homework #1 due now Project 0 due tonight Project groups Please send project

More information

Processes and Non-Preemptive Scheduling. Otto J. Anshus

Processes and Non-Preemptive Scheduling. Otto J. Anshus Processes and Non-Preemptive Scheduling Otto J. Anshus Threads Processes Processes Kernel An aside on concurrency Timing and sequence of events are key concurrency issues We will study classical OS concurrency

More information

OPERATING SYSTEM. Chapter 4: Threads

OPERATING SYSTEM. Chapter 4: Threads OPERATING SYSTEM Chapter 4: Threads Chapter 4: Threads Overview Multicore Programming Multithreading Models Thread Libraries Implicit Threading Threading Issues Operating System Examples Objectives To

More information

Chapter 4: Threads. Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads

Chapter 4: Threads. Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads Chapter 4: Threads Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads Chapter 4: Threads Objectives To introduce the notion of a

More information

CSE 153 Design of Operating Systems Fall 2018

CSE 153 Design of Operating Systems Fall 2018 CSE 153 Design of Operating Systems Fall 2018 Lecture 4: Processes (2) Threads Process Creation: Unix In Unix, processes are created using fork() int fork() fork() Creates and initializes a new PCB Creates

More information

Chapter 5: Threads. Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads Java Threads

Chapter 5: Threads. Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads Java Threads Chapter 5: Threads Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads Java Threads 5.1 Silberschatz, Galvin and Gagne 2003 More About Processes A process encapsulates

More information

CSE 451: Operating Systems Winter Module 4 Processes. Mark Zbikowski Allen Center 476

CSE 451: Operating Systems Winter Module 4 Processes. Mark Zbikowski Allen Center 476 CSE 451: Operating Systems Winter 2015 Module 4 Processes Mark Zbikowski mzbik@cs.washington.edu Allen Center 476 2013 Gribble, Lazowska, Levy, Zahorjan Process management This module begins a series of

More information

CSE 410: Computer Systems Spring Processes. John Zahorjan Allen Center 534

CSE 410: Computer Systems Spring Processes. John Zahorjan Allen Center 534 CSE 410: Computer Systems Spring 2018 Processes John Zahorjan zahorjan@cs.washington.edu Allen Center 534 1. What is a process? Processes 2. What's the process namespace? 3. How are processes represented

More information

Chapter 4: Multi-Threaded Programming

Chapter 4: Multi-Threaded Programming Chapter 4: Multi-Threaded Programming Chapter 4: Threads 4.1 Overview 4.2 Multicore Programming 4.3 Multithreading Models 4.4 Thread Libraries Pthreads Win32 Threads Java Threads 4.5 Implicit Threading

More information

Chapter 4: Threads. Chapter 4: Threads

Chapter 4: Threads. Chapter 4: Threads Chapter 4: Threads Silberschatz, Galvin and Gagne 2009 Chapter 4: Threads Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads 4.2

More information

Chapter 4: Threads. Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads Java Threads. Operating System Concepts

Chapter 4: Threads. Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads Java Threads. Operating System Concepts Chapter 4: Threads Chapter 4: Threads Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads Java Threads 4.2 Silberschatz, Galvin and Gagne 2005 Single and Multithreaded

More information

Process management. What s in a process? What is a process? The OS s process namespace. A process s address space (idealized)

Process management. What s in a process? What is a process? The OS s process namespace. A process s address space (idealized) Process management CSE 451: Operating Systems Spring 2012 Module 4 Processes Ed Lazowska lazowska@cs.washington.edu Allen Center 570 This module begins a series of topics on processes, threads, and synchronization

More information

Process Description and Control

Process Description and Control Process Description and Control 1 Process:the concept Process = a program in execution Example processes: OS kernel OS shell Program executing after compilation www-browser Process management by OS : Allocate

More information

Chapter 5: Threads. Outline

Chapter 5: Threads. Outline Department of Electr rical Eng ineering, Chapter 5: Threads 王振傑 (Chen-Chieh Wang) ccwang@mail.ee.ncku.edu.tw ncku edu Feng-Chia Unive ersity Outline Overview Multithreading Models Threading Issues 2 Depar

More information

Chapter 4: Multithreaded Programming

Chapter 4: Multithreaded Programming Chapter 4: Multithreaded Programming Silberschatz, Galvin and Gagne 2013! Chapter 4: Multithreaded Programming Overview Multicore Programming Multithreading Models Threading Issues Operating System Examples

More information

Distributed Systems Operation System Support

Distributed Systems Operation System Support Hajussüsteemid MTAT.08.009 Distributed Systems Operation System Support slides are adopted from: lecture: Operating System(OS) support (years 2016, 2017) book: Distributed Systems: Concepts and Design,

More information

Threads. What is a thread? Motivation. Single and Multithreaded Processes. Benefits

Threads. What is a thread? Motivation. Single and Multithreaded Processes. Benefits CS307 What is a thread? Threads A thread is a basic unit of CPU utilization contains a thread ID, a program counter, a register set, and a stack shares with other threads belonging to the same process

More information

Threads. CS-3013 Operating Systems Hugh C. Lauer. CS-3013, C-Term 2012 Threads 1

Threads. CS-3013 Operating Systems Hugh C. Lauer. CS-3013, C-Term 2012 Threads 1 Threads CS-3013 Operating Systems Hugh C. Lauer (Slides include materials from Slides include materials from Modern Operating Systems, 3 rd ed., by Andrew Tanenbaum and from Operating System Concepts,

More information

CS 450 Operating System Week 4 Lecture Notes

CS 450 Operating System Week 4 Lecture Notes CS 450 Operating System Week 4 Lecture Notes Reading: Operating System Concepts (7 th Edition) - Silberschatz, Galvin, Gagne Chapter 5 - Pages 129 147 Objectives: 1. Explain the main Objective of Threads

More information

Agenda. Threads. Single and Multi-threaded Processes. What is Thread. CSCI 444/544 Operating Systems Fall 2008

Agenda. Threads. Single and Multi-threaded Processes. What is Thread. CSCI 444/544 Operating Systems Fall 2008 Agenda Threads CSCI 444/544 Operating Systems Fall 2008 Thread concept Thread vs process Thread implementation - user-level - kernel-level - hybrid Inter-process (inter-thread) communication What is Thread

More information

DISTRIBUTED COMPUTER SYSTEMS

DISTRIBUTED COMPUTER SYSTEMS 9/17/15 DISTRIBUTED COMPUTER SYSTEMS PROCESSES AND THREADS Dr. Jack Lange Computer Science Department University of Pittsburgh Fall 2015 Outline Heavy Weight Processes Threads and Thread Implementation

More information

!! How is a thread different from a process? !! Why are threads useful? !! How can POSIX threads be useful?

!! How is a thread different from a process? !! Why are threads useful? !! How can POSIX threads be useful? Chapter 2: Threads: Questions CSCI [4 6]730 Operating Systems Threads!! How is a thread different from a process?!! Why are threads useful?!! How can OSIX threads be useful?!! What are user-level and kernel-level

More information

Processes & Threads. Process Management. Managing Concurrency in Computer Systems. The Process. What s in a Process?

Processes & Threads. Process Management. Managing Concurrency in Computer Systems. The Process. What s in a Process? Process Management Processes & Threads Managing Concurrency in Computer Systems Process management deals with several issues: what are the units of execution how are those units of execution represented

More information

Chapter 4: Threads. Chapter 4: Threads

Chapter 4: Threads. Chapter 4: Threads Chapter 4: Threads Silberschatz, Galvin and Gagne 2013 Chapter 4: Threads Overview Multicore Programming Multithreading Models Thread Libraries Implicit Threading Threading Issues Operating System Examples

More information

Chapter 3 Process Description and Control

Chapter 3 Process Description and Control Operating Systems: Internals and Design Principles Chapter 3 Process Description and Control Seventh Edition By William Stallings Process Control Block Structure of Process Images in Virtual Memory How

More information

CS307: Operating Systems

CS307: Operating Systems CS307: Operating Systems Chentao Wu 吴晨涛 Associate Professor Dept. of Computer Science and Engineering Shanghai Jiao Tong University SEIEE Building 3-513 wuct@cs.sjtu.edu.cn Download Lectures ftp://public.sjtu.edu.cn

More information

Chapter 4 Multithreaded Programming

Chapter 4 Multithreaded Programming Chapter 4 Multithreaded Programming Da-Wei Chang CSIE.NCKU Source: Abraham Silberschatz, Peter B. Galvin, and Greg Gagne, "Operating System Concepts", 9th Edition, Wiley. 1 1 Outline Overview Multithreading

More information

Page 1. Analogy: Problems: Operating Systems Lecture 7. Operating Systems Lecture 7

Page 1. Analogy: Problems: Operating Systems Lecture 7. Operating Systems Lecture 7 Os-slide#1 /*Sequential Producer & Consumer*/ int i=0; repeat forever Gather material for item i; Produce item i; Use item i; Discard item i; I=I+1; end repeat Analogy: Manufacturing and distribution Print

More information

Motivation. Threads. Multithreaded Server Architecture. Thread of execution. Chapter 4

Motivation. Threads. Multithreaded Server Architecture. Thread of execution. Chapter 4 Motivation Threads Chapter 4 Most modern applications are multithreaded Threads run within application Multiple tasks with the application can be implemented by separate Update display Fetch data Spell

More information

Chapter 4: Threads. Operating System Concepts 9 th Edition

Chapter 4: Threads. Operating System Concepts 9 th Edition Chapter 4: Threads Silberschatz, Galvin and Gagne 2013 Chapter 4: Threads Overview Multicore Programming Multithreading Models Thread Libraries Implicit Threading Threading Issues Operating System Examples

More information

Chapter 4: Threads. Operating System Concepts 9 th Edition

Chapter 4: Threads. Operating System Concepts 9 th Edition Chapter 4: Threads Silberschatz, Galvin and Gagne 2013 Chapter 4: Threads Overview Multicore Programming Multithreading Models Thread Libraries Implicit Threading Threading Issues Operating System Examples

More information

CS 318 Principles of Operating Systems

CS 318 Principles of Operating Systems CS 318 Principles of Operating Systems Fall 2017 Lecture 5: Thread Ryan Huang Administrivia HW1 solution released on Piazza resources Lab 0 grading - In progress - Cheating policy Lab 1 review session

More information

Processes and Threads. Processes and Threads. Processes (2) Processes (1)

Processes and Threads. Processes and Threads. Processes (2) Processes (1) Processes and Threads (Topic 2-1) 2 홍성수 Processes and Threads Question: What is a process and why is it useful? Why? With many things happening at once in a system, need some way of separating them all

More information

Chapter 4: Multithreaded

Chapter 4: Multithreaded Chapter 4: Multithreaded Programming Chapter 4: Multithreaded Programming Overview Multithreading Models Thread Libraries Threading Issues Operating-System Examples 2009/10/19 2 4.1 Overview A thread is

More information

! How is a thread different from a process? ! Why are threads useful? ! How can POSIX threads be useful?

! How is a thread different from a process? ! Why are threads useful? ! How can POSIX threads be useful? Chapter 2: Threads: Questions CSCI [4 6]730 Operating Systems Threads! How is a thread different from a process?! Why are threads useful?! How can OSIX threads be useful?! What are user-level and kernel-level

More information

Processes Prof. James L. Frankel Harvard University. Version of 6:16 PM 10-Feb-2017 Copyright 2017, 2015 James L. Frankel. All rights reserved.

Processes Prof. James L. Frankel Harvard University. Version of 6:16 PM 10-Feb-2017 Copyright 2017, 2015 James L. Frankel. All rights reserved. Processes Prof. James L. Frankel Harvard University Version of 6:16 PM 10-Feb-2017 Copyright 2017, 2015 James L. Frankel. All rights reserved. Process Model Each process consists of a sequential program

More information

Last time: introduction. Networks and Operating Systems ( ) Chapter 2: Processes. This time. General OS structure. The kernel is a program!

Last time: introduction. Networks and Operating Systems ( ) Chapter 2: Processes. This time. General OS structure. The kernel is a program! ADRIAN PERRIG & TORSTEN HOEFLER Networks and Operating Systems (252-0062-00) Chapter 2: Processes Last time: introduction Introduction: Why? February 12, 2016 Roles of the OS Referee Illusionist Glue Structure

More information

CS 326: Operating Systems. Process Execution. Lecture 5

CS 326: Operating Systems. Process Execution. Lecture 5 CS 326: Operating Systems Process Execution Lecture 5 Today s Schedule Process Creation Threads Limited Direct Execution Basic Scheduling 2/5/18 CS 326: Operating Systems 2 Today s Schedule Process Creation

More information

Multithreaded Programming

Multithreaded Programming Multithreaded Programming The slides do not contain all the information and cannot be treated as a study material for Operating System. Please refer the text book for exams. September 4, 2014 Topics Overview

More information

PROCESS CONTROL BLOCK TWO-STATE MODEL (CONT D)

PROCESS CONTROL BLOCK TWO-STATE MODEL (CONT D) MANAGEMENT OF APPLICATION EXECUTION PROCESS CONTROL BLOCK Resources (processor, I/O devices, etc.) are made available to multiple applications The processor in particular is switched among multiple applications

More information

Slide 6-1. Processes. Operating Systems: A Modern Perspective, Chapter 6. Copyright 2004 Pearson Education, Inc.

Slide 6-1. Processes. Operating Systems: A Modern Perspective, Chapter 6. Copyright 2004 Pearson Education, Inc. Slide 6-1 6 es Announcements Slide 6-2 Extension til Friday 11 am for HW #1 Previous lectures online Program Assignment #1 online later today, due 2 weeks from today Homework Set #2 online later today,

More information

Chapter 4: Multithreaded Programming. Operating System Concepts 8 th Edition,

Chapter 4: Multithreaded Programming. Operating System Concepts 8 th Edition, Chapter 4: Multithreaded Programming, Silberschatz, Galvin and Gagne 2009 Chapter 4: Multithreaded Programming Overview Multithreading Models Thread Libraries Threading Issues 4.2 Silberschatz, Galvin

More information

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017 CS 471 Operating Systems Yue Cheng George Mason University Fall 2017 Outline o Process concept o Process creation o Process states and scheduling o Preemption and context switch o Inter-process communication

More information

CS 318 Principles of Operating Systems

CS 318 Principles of Operating Systems CS 318 Principles of Operating Systems Fall 2018 Lecture 5: Thread Ryan Huang Slides adapted from Geoff Voelker s and David Mazières lectures Administrivia Lab 0 grading in progress Lab 1 review session

More information

OS lpr. www. nfsd gcc emacs ls 1/27/09. Process Management. CS 537 Lecture 3: Processes. Example OS in operation. Why Processes? Simplicity + Speed

OS lpr. www. nfsd gcc emacs ls 1/27/09. Process Management. CS 537 Lecture 3: Processes. Example OS in operation. Why Processes? Simplicity + Speed Process Management CS 537 Lecture 3: Processes Michael Swift This lecture begins a series of topics on processes, threads, and synchronization Today: processes and process management what are the OS units

More information

Processes and Threads

Processes and Threads TDDI04 Concurrent Programming, Operating Systems, and Real-time Operating Systems Processes and Threads [SGG7] Chapters 3 and 4 Copyright Notice: The lecture notes are mainly based on Silberschatz s, Galvin

More information

Yi Shi Fall 2017 Xi an Jiaotong University

Yi Shi Fall 2017 Xi an Jiaotong University Threads Yi Shi Fall 2017 Xi an Jiaotong University Goals for Today Case for Threads Thread details Case for Parallelism main() read_data() for(all data) compute(); write_data(); endfor main() read_data()

More information

Introduction to OS Processes in Unix, Linux, and Windows MOS 2.1 Mahmoud El-Gayyar

Introduction to OS Processes in Unix, Linux, and Windows MOS 2.1 Mahmoud El-Gayyar Introduction to OS Processes in Unix, Linux, and Windows MOS 2.1 Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Mahmoud El-Gayyar / Introduction to OS 1 Processes in Unix, Linux, and Windows Unix pre-empted

More information

Lecture 2 Process Management

Lecture 2 Process Management Lecture 2 Process Management Process Concept An operating system executes a variety of programs: Batch system jobs Time-shared systems user programs or tasks The terms job and process may be interchangeable

More information

Process Manager Overview

Process Manager Overview Process Management Process Manager Overview Program Process Abstract Computing Environment Device Manager File Manager Memory Manager Deadlock Protection Synchronization Scheduler Process Description Resource

More information

Chapter 4: Multithreaded Programming Dr. Varin Chouvatut. Operating System Concepts 8 th Edition,

Chapter 4: Multithreaded Programming Dr. Varin Chouvatut. Operating System Concepts 8 th Edition, Chapter 4: Multithreaded Programming Dr. Varin Chouvatut, Silberschatz, Galvin and Gagne 2010 Chapter 4: Multithreaded Programming Overview Multithreading Models Thread Libraries Threading Issues Operating

More information

Process Concepts. CSC400 - Operating Systems. 3. Process Concepts. J. Sumey

Process Concepts. CSC400 - Operating Systems. 3. Process Concepts. J. Sumey CSC400 - Operating Systems 3. Process Concepts J. Sumey Overview Concurrency Processes & Process States Process Accounting Interrupts & Interrupt Processing Interprocess Communication CSC400 - Process

More information

Processes and Threads

Processes and Threads Processes and Threads Giuseppe Anastasi g.anastasi@iet.unipi.it Pervasive Computing & Networking Lab. () Dept. of Information Engineering, University of Pisa Based on original slides by Silberschatz, Galvin

More information

Chapter 4: Multithreaded Programming

Chapter 4: Multithreaded Programming Chapter 4: Multithreaded Programming Chapter 4: Multithreaded Programming Overview Multicore Programming Multithreading Models Threading Issues Operating System Examples Objectives To introduce the notion

More information

Announcement. Exercise #2 will be out today. Due date is next Monday

Announcement. Exercise #2 will be out today. Due date is next Monday Announcement Exercise #2 will be out today Due date is next Monday Major OS Developments 2 Evolution of Operating Systems Generations include: Serial Processing Simple Batch Systems Multiprogrammed Batch

More information

Chapter 4: Multithreaded Programming

Chapter 4: Multithreaded Programming Chapter 4: Multithreaded Programming Chapter 4: Multithreaded Programming Overview Multicore Programming Multithreading Models Threading Issues Operating System Examples Objectives To introduce the notion

More information

OS Structure, Processes & Process Management. Don Porter Portions courtesy Emmett Witchel

OS Structure, Processes & Process Management. Don Porter Portions courtesy Emmett Witchel OS Structure, Processes & Process Management Don Porter Portions courtesy Emmett Witchel 1 What is a Process?! A process is a program during execution. Ø Program = static file (image) Ø Process = executing

More information

Processes and Threads

Processes and Threads COS 318: Operating Systems Processes and Threads Kai Li and Andy Bavier Computer Science Department Princeton University http://www.cs.princeton.edu/courses/archive/fall13/cos318 Today s Topics u Concurrency

More information

What is a Process? Processes and Process Management Details for running a program

What is a Process? Processes and Process Management Details for running a program 1 What is a Process? Program to Process OS Structure, Processes & Process Management Don Porter Portions courtesy Emmett Witchel! A process is a program during execution. Ø Program = static file (image)

More information

W4118 Operating Systems. Junfeng Yang

W4118 Operating Systems. Junfeng Yang W4118 Operating Systems Junfeng Yang What is a process? Outline Process dispatching Common process operations Inter-process Communication What is a process Program in execution virtual CPU Process: an

More information

Computer Systems II. First Two Major Computer System Evolution Steps

Computer Systems II. First Two Major Computer System Evolution Steps Computer Systems II Introduction to Processes 1 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent processes) 2 1 At First (1945 1955) In the beginning,

More information

Lecture Topics. Announcements. Today: Threads (Stallings, chapter , 4.6) Next: Concurrency (Stallings, chapter , 5.

Lecture Topics. Announcements. Today: Threads (Stallings, chapter , 4.6) Next: Concurrency (Stallings, chapter , 5. Lecture Topics Today: Threads (Stallings, chapter 4.1-4.3, 4.6) Next: Concurrency (Stallings, chapter 5.1-5.4, 5.7) 1 Announcements Make tutorial Self-Study Exercise #4 Project #2 (due 9/20) Project #3

More information

OS lpr. www. nfsd gcc emacs ls 9/18/11. Process Management. CS 537 Lecture 4: Processes. The Process. Why Processes? Simplicity + Speed

OS lpr. www. nfsd gcc emacs ls 9/18/11. Process Management. CS 537 Lecture 4: Processes. The Process. Why Processes? Simplicity + Speed Process Management CS 537 Lecture 4: Processes Today: processes and process management what are the OS units of execution? how are they represented inside the OS? how is the CPU scheduled across processes?

More information

Thread and Synchronization

Thread and Synchronization Thread and Synchronization Task Model (Module 18) Yann-Hang Lee Arizona State University yhlee@asu.edu (480) 727-7507 Summer 2014 Real-time Systems Lab, Computer Science and Engineering, ASU Why Talk About

More information

www nfsd emacs lpr Process Management CS 537 Lecture 4: Processes Example OS in operation Why Processes? Simplicity + Speed

www nfsd emacs lpr Process Management CS 537 Lecture 4: Processes Example OS in operation Why Processes? Simplicity + Speed Process Management CS 537 Lecture 4: Processes Michael Swift This lecture begins a series of topics on processes, threads, and synchronization Today: processes and process management what are the OS units

More information

Threads. CS3026 Operating Systems Lecture 06

Threads. CS3026 Operating Systems Lecture 06 Threads CS3026 Operating Systems Lecture 06 Multithreading Multithreading is the ability of an operating system to support multiple threads of execution within a single process Processes have at least

More information

CSE 4/521 Introduction to Operating Systems

CSE 4/521 Introduction to Operating Systems CSE 4/521 Introduction to Operating Systems Lecture 5 Threads (Overview, Multicore Programming, Multithreading Models, Thread Libraries, Implicit Threading, Operating- System Examples) Summer 2018 Overview

More information

Today s Topics. u Thread implementation. l Non-preemptive versus preemptive threads. l Kernel vs. user threads

Today s Topics. u Thread implementation. l Non-preemptive versus preemptive threads. l Kernel vs. user threads Today s Topics COS 318: Operating Systems Implementing Threads u Thread implementation l Non-preemptive versus preemptive threads l Kernel vs. user threads Jaswinder Pal Singh and a Fabulous Course Staff

More information

THREADS. Jo, Heeseung

THREADS. Jo, Heeseung THREADS Jo, Heeseung TODAY'S TOPICS Why threads? Threading issues 2 PROCESSES Heavy-weight A process includes many things: - An address space (all the code and data pages) - OS resources (e.g., open files)

More information

Chapter 3: Processes. Operating System Concepts 8th Edition

Chapter 3: Processes. Operating System Concepts 8th Edition Chapter 3: Processes Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication in Client-Server Systems 3.2 Objectives

More information

Computer Systems Laboratory Sungkyunkwan University

Computer Systems Laboratory Sungkyunkwan University Threads Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Today s Topics Why threads? Threading issues 2 Processes Heavy-weight A process includes

More information

Processes. Dr. Yingwu Zhu

Processes. Dr. Yingwu Zhu Processes Dr. Yingwu Zhu Process Growing Memory Stack expands automatically Data area (heap) can grow via a system call that requests more memory - malloc() in c/c++ Entering the kernel (mode) Hardware

More information

Outline. Process and Thread Management. Data Structures (2) Data Structures. Kernel Process Block (PCB)

Outline. Process and Thread Management. Data Structures (2) Data Structures. Kernel Process Block (PCB) Outline Process and Thread Management Ausgewählte Betriebssysteme Professur Betriebssysteme Fakultät Informatik Data Structures Process Creation Thread Creation Scheduling 2 Data Structures Data Structures

More information

Process and Thread Management

Process and Thread Management Process and Thread Management Ausgewählte Betriebssysteme Professur Betriebssysteme Fakultät Informatik Data Structures Process Creation Thread Creation Scheduling Outline 2 1 Data Structures Process represented

More information

Operating Systems 2 nd semester 2016/2017. Chapter 4: Threads

Operating Systems 2 nd semester 2016/2017. Chapter 4: Threads Operating Systems 2 nd semester 2016/2017 Chapter 4: Threads Mohamed B. Abubaker Palestine Technical College Deir El-Balah Note: Adapted from the resources of textbox Operating System Concepts, 9 th edition

More information

Sistemi in Tempo Reale

Sistemi in Tempo Reale Laurea Specialistica in Ingegneria dell'automazione Sistemi in Tempo Reale Giuseppe Lipari Introduzione alla concorrenza Fundamentals Algorithm: It is the logical procedure to solve a certain problem It

More information

Chapter 5: Processes & Process Concept. Objectives. Process Concept Process Scheduling Operations on Processes. Communication in Client-Server Systems

Chapter 5: Processes & Process Concept. Objectives. Process Concept Process Scheduling Operations on Processes. Communication in Client-Server Systems Chapter 5: Processes Chapter 5: Processes & Threads Process Concept Process Scheduling Operations on Processes Interprocess Communication Communication in Client-Server Systems, Silberschatz, Galvin and

More information

Processes. CS439: Principles of Computer Systems January 24, 2018

Processes. CS439: Principles of Computer Systems January 24, 2018 Processes CS439: Principles of Computer Systems January 24, 2018 Last Time History Lesson Hardware expensive, humans cheap Hardware cheap, humans expensive Hardware very cheap, humans very expensive Dual-mode

More information

Reading Assignment 4. n Chapter 4 Threads, due 2/7. 1/31/13 CSE325 - Processes 1

Reading Assignment 4. n Chapter 4 Threads, due 2/7. 1/31/13 CSE325 - Processes 1 Reading Assignment 4 Chapter 4 Threads, due 2/7 1/31/13 CSE325 - Processes 1 What s Next? 1. Process Concept 2. Process Manager Responsibilities 3. Operations on Processes 4. Process Scheduling 5. Cooperating

More information

Processes. 4: Threads. Problem needs > 1 independent sequential process? Example: Web Server. Last Modified: 9/17/2002 2:27:59 PM

Processes. 4: Threads. Problem needs > 1 independent sequential process? Example: Web Server. Last Modified: 9/17/2002 2:27:59 PM Processes 4: Threads Last Modified: 9/17/2002 2:27:59 PM Recall: A process includes Address space (Code, Data, Heap, Stack) Register values (including the PC) Resources allocated to the process Memory,

More information

Chapter 4: Multithreaded Programming

Chapter 4: Multithreaded Programming Chapter 4: Multithreaded Programming Silberschatz, Galvin and Gagne 2013 Chapter 4: Multithreaded Programming Overview Multicore Programming Multithreading Models Thread Libraries Implicit Threading Threading

More information

Chapter 4: Threads. Chapter 4: Threads. Overview Multicore Programming Multithreading Models Thread Libraries Implicit Threading Threading Issues

Chapter 4: Threads. Chapter 4: Threads. Overview Multicore Programming Multithreading Models Thread Libraries Implicit Threading Threading Issues Chapter 4: Threads Silberschatz, Galvin and Gagne 2013 Chapter 4: Threads Overview Multicore Programming Multithreading Models Thread Libraries Implicit Threading Threading Issues 4.2 Silberschatz, Galvin

More information