Threads: Light-Weight Processes

Slides:



Advertisements
Similar presentations
Department of Computer Science Southern Illinois University Edwardsville Spring, 2010 Dr. Hiroshi Fujinoki CS 547/490 Network.
Advertisements

Chapter 4: Threads. Overview Multithreading Models Threading Issues Pthreads Windows XP Threads.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Three fundamental concepts in computer security: Reference Monitors: An access control concept that refers to an abstract machine that mediates all accesses.
Chapter 2 (PART 1) Light-Weight Process (Threads) Department of Computer Science Southern Illinois University Edwardsville Summer, 2004 Dr. Hiroshi Fujinoki.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 13 Threads Read Ch 5.1.
Department of Computer Science Southern Illinois University Edwardsville Spring, 2010 Dr. Hiroshi Fujinoki IPC1.PPT/001 Inter-Process.
Multi-Tasking The Multi-Tasking service is offered by VxWorks with its real- time kernel “WIND”.
Operating System Concepts Part II Department of Computer Science Southern Illinois University Edwardsville Spring, 2009 Dr. Hiroshi Fujinoki
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Processes. Process Concept Process Scheduling Operations on Processes Interprocess Communication Communication in Client-Server Systems.
Chapter 1 (PART 2) Operating System Concepts Department of Computer Science Southern Illinois University Edwardsville Spring, 2016 Dr. Hiroshi Fujinoki.
Operating Systems Unit 2: – Process Context switch Interrupt Interprocess communication – Thread Thread models Operating Systems.
Uniprocessor Process Management & Process Scheduling Department of Computer Science Southern Illinois University Edwardsville Spring, 2016 Dr. Hiroshi.
OS Boot Sequence and File System (implication to “Boot Sector Viruses”) Department of Computer Science Southern Illinois University Edwardsville Spring,
Processes Chapter 3. Processes in Distributed Systems Processes and threads –Introduction to threads –Distinction between threads and processes Threads.
Embedded Real-Time Systems
CS 312 Computer Architecture & Organization
Processes and threads.
Operating System Concepts
Operating Systems (CS 340 D)
CS 286 Computer Organization and Architecture
Day 12 Threads.
Process Management Presented By Aditya Gupta Assistant Professor
Intro to Processes CSSE 332 Operating Systems
CS 286 Computer Organization and Architecture
CS 286: Memory Paging and Virtual Memory
Operating Systems (CS 340 D)
CS 286 Computer Organization and Architecture
Threads & multithreading
Operating System Concepts
Applied Operating System Concepts
Operating Systems (CS 340 D)
Chapter 3 Process Management.
Implementing Threads in User Space
Operating Systems : Overview
Threads and Concurrency
EE 472 – Embedded Systems Dr. Shwetak Patel.
Operating Systems (CS 340 D)
Operating Systems : Overview
Operating Systems : Overview
Chapter 3: Processes.
CS 286 Computer Organization and Architecture
CS 286 Computer Architecture & Organization
CS 286 Computer Organization and Architecture
CS533 Concepts of Operating Systems Class 13
Operating Systems : Overview
Uniprocessor Process Management & Process Scheduling
CS 286 Computer Organization and Architecture
Introduction to OS (concept, evolution, some keywords)
CS533 Concepts of Operating Systems Class 11
Process Synchronization
Real-Time Process Scheduling Concepts, Design and Implementations
Welcome to CS314 Operating Systems A Quick Tour for Introduction to OS
Introduction to OS (concept, evolution, some keywords)
Department of Computer Science
Welcome to CS314 Operating Systems A Quick Tour for Introduction to OS
OS Boot Sequence and File System
Department of Computer Science
Operating System Concepts
Operating System Concepts
Real-Time Process Scheduling Concepts, Design and Implementations
Process Synchronization
OS Boot Sequence and File System
Light-Weight Process (Threads)
Uniprocessor Process Management & Process Scheduling
CS 286 Computer Architecture & Organization
MIPS R3000 Subroutine Calls and Stack
CS Introduction to Operating Systems
Presentation transcript:

Threads: Light-Weight Processes CS 314 Operating Systems Threads: Light-Weight Processes Department of Computer Science Southern Illinois University Edwardsville Spring, 2019 Dr. Hiroshi Fujinoki E-mail: hfujino@siue.edu UK_Threads/000

CS 314 Operating Systems Processes and Threads  Problems in processes  Concept of threads  How do threads solve the problem in processes?  Two different thread implementations UK_Threads/001

CS 314 Operating Systems Processes and Threads  Problems in processes High overhead in inter-process-communication (IPC) High context-switching overhead in multitasking using processes UK_Threads/002

CS 314 Operating Systems Processes and Threads  Problems in processes High overhead in inter-process-communication (IPC) Processes can not access memory address outside of its address space Memory address space for each process Memory P1 P2 P3 Data in Memory What if, some process need to share some information (data)? Processes exchange information through OS (IPC) “shared memory” “pipe” OS “semaphore” “message passing” UK_Threads/003

CS 314 Operating Systems Processes and Threads  Problems in processes High overhead in inter-process-communication (IPC) Processes can not access memory address outside of its address space Memory P1 P2 P3 What if, some process need to share some information (data)? move it to shared memory Processes exchange information through OS (IPC) Shared Memory OS performs this operation “shared memory” “pipe” OS “semaphore” “message passing” UK_Threads/003

CS 314 Operating Systems Processes and Threads  Problems in processes The high-overhead IPC’s are acceptable for loosely-coupled processes  Problems in processes High overhead in inter-process-communication (IPC) Processes can not access memory address outside of its address space Memory address space for each process Memory P1 What if, some process need to share some information (data)? P2 P3 system call Processes exchange information through OS (IPC) Closely-coupled processes Keyboard input “shared memory” Background spell-check “pipe” OS Automatic file-save “semaphore” “message passing” UK_Threads/004

CS 314 Operating Systems Processes and Threads  Problems in processes High context-switching overhead in multitasking using processes Memory Processor P1 P2 Registers    P3 SAVE LOAD Time PCB-P1 PCB-P2 PCB-P3 OS UK_Threads/005

CS 314 Operating Systems Processes and Threads  Problems in processes The high-overhead IPC’s are acceptable for loosely-coupled processes  Problems in processes High context-switching overhead in multitasking using processes Closely-coupled processes Memory Keyboard input Processor P1 Background spell-check Automatic file-save P2 Registers    P3 SAVE LOAD Time PCB-P1 PCB-P2 PCB-P3 OS UK_Threads/006

CS 314 Operating Systems Processes and Threads  Concept of threads P1 Memory Memory OS P1 Thread1 Thread2 Thread3 Process P2 P3 OS UK_Threads/007

CS 314 Operating Systems Processes and Threads  Concept of threads Global Variable Area  Concept of threads Memory Memory P1 Thread1 Process Address Space P2 Thread2 Thread3 P3 OS OS UK_Threads/008

CS 314 Operating Systems Processes and Threads  How do threads solve the problem in processes? High overhead in inter-process-communication (IPC) High context-switching overhead in multitasking using processes UK_Threads/009

CS 314 Operating Systems Processes and Threads Inter-process communications must go through OS (system call) The member threads can access shared data w/out going through a system call Processes and Threads Solved   How do threads solve the problem in processes? High overhead in inter-process-communication (IPC) Memory OS P1 P2 P3 system call IPC by “message passing” Memory OS P1 P2 P3 Shared Memory move it to shared memory OS performs this operation IPC by “shared memory” Memory Thread1 Thread2 Thread3 OS UK_Threads/010

CS 314 Operating Systems PCB Processes and Threads  How do threads solve the problem in processes? High context-switching overhead in multitasking using processes PCB TCB TCB is a subset of PCB UK_Threads/011

CS 314 Operating Systems PCB Processes and Threads  How do threads solve the problem in processes? High context-switching overhead in multitasking using processes PCB TCB TCB TCB TCB TCB is a subset of PCB UK_Threads/012

CS 314 Operating Systems PCB Processes and Threads  How do threads solve the problem in processes? High context-switching overhead in multitasking using processes PCB TCB TCB TCB TCB TCB is a subset of PCB UK_Threads/013

CS 314 Operating Systems PCB Processes and Threads Solved   How do threads solve the problem in processes? High context-switching overhead in multitasking using processes PCB TCB User ID Total CPU time Total amount of memory TCB TCB TCB TCB is a subset of PCB UK_Threads/014

CS 314 Operating Systems Processes and Threads  How do threads solve the problem in processes? High context-switching overhead in multitasking using processes Memory Memory Where are “TCB’s”? P1 Thread1 Thread2 Thread3 Processor    Registers Process P2 P3 PCB-P1 PCB-P2 PCB-P3 OS OS PCB UK_Threads/015

CS 314 Operating Systems Processes and Threads  Two different thread implementations Kernel-Mode Threads OS manages each thread (as well as processes) Thread Implementation OS has thread manager (scheduler) Application-Mode Threads A.K.A. “OS-mode threads” OS does NOT manage each thread (it manages only processes) OS does not have thread manager A.K.A. “user-mode threads” UK_Threads/016

CS 314 Operating Systems Processes and Threads Thread1 Thread1 Thread2 Kernel-Mode Threads Application-Mode Threads Memory Memory Thread1 Thread1 Thread2 Thread2 Thread3 Thread3 Process Scheduler Process Scheduler OS OS Thread Scheduler = PCB = TCB UK_Threads/017

CS 314 Operating Systems Processes and Threads Thread1 Thread1 Thread2 Kernel-Mode Threads Application-Mode Threads Memory Memory Thread1 Thread1 Thread2 Thread2 Thread3 Thread3 Thread Scheduler Process Scheduler Process Scheduler OS OS Thread Scheduler = PCB = TCB UK_Threads/018

CS 314 Operating Systems Processes and Threads Process T1 T2 Process System call Function call (faster than system call) Process T1 Kernel-Mode Threads T2 Process T3 OS Process Thread Scheduler T1 Process T2 Application-Mode Threads T3 OS UK_Threads/019