Presentation is loading. Please wait.

Presentation is loading. Please wait.

Threads and Scheduling

Similar presentations


Presentation on theme: "Threads and Scheduling"— Presentation transcript:

1 Threads and Scheduling
Section 4 Threads and Scheduling February 10th, 2017 Taught by Josh Don

2 Waiting/Synchronization Context Switching Overhead
Process Thread Data/Memory Communication Creation Waiting/Synchronization Use case Context Switching Overhead

3 Waiting/Synchronization Context Switching Overhead
Process Thread Data/Memory Independent address space Communication Creation Waiting/Synchronization Use case Context Switching Overhead

4 Waiting/Synchronization Context Switching Overhead
Process Thread Data/Memory Independent address space Shares address space with other threads in same process. Each thread still has own registers and stack Communication Creation Waiting/Synchronization Use case Context Switching Overhead

5 Waiting/Synchronization Context Switching Overhead
Process Thread Data/Memory Independent address space Shares address space with other threads in same process. Each thread still has own registers and stack Communication Pipes, files, sockets High overhead Creation Waiting/Synchronization Use case Context Switching Overhead

6 Waiting/Synchronization Context Switching Overhead
Process Thread Data/Memory Independent address space Shares address space with other threads in same process. Each thread still has own registers and stack Communication Pipes, files, sockets High overhead Read data of another thread Low overhead Creation Waiting/Synchronization Use case Context Switching Overhead

7 Waiting/Synchronization Context Switching Overhead
Process Thread Data/Memory Independent address space Shares address space with other threads in same process. Each thread still has own registers and stack Communication Pipes, files, sockets High overhead Read data of another thread Low overhead Creation fork() Higher overhead Waiting/Synchronization Use case Context Switching Overhead

8 Waiting/Synchronization Context Switching Overhead
Process Thread Data/Memory Independent address space Shares address space with other threads in same process. Each thread still has own registers and stack Communication Pipes, files, sockets High overhead Read data of another thread Low overhead Creation fork() Higher overhead pthread_create() Lower overhead Waiting/Synchronization Use case Context Switching Overhead

9 Waiting/Synchronization Context Switching Overhead
Process Thread Data/Memory Independent address space Shares address space with other threads in same process. Each thread still has own registers and stack Communication Pipes, files, sockets High overhead Read data of another thread Low overhead Creation fork() Higher overhead pthread_create() Lower overhead Waiting/Synchronization wait() Use case Context Switching Overhead

10 Waiting/Synchronization Context Switching Overhead
Process Thread Data/Memory Independent address space Shares address space with other threads in same process. Each thread still has own registers and stack Communication Pipes, files, sockets High overhead Read data of another thread Low overhead Creation fork() Higher overhead pthread_create() Lower overhead Waiting/Synchronization wait() join() Use case Context Switching Overhead

11 Waiting/Synchronization Context Switching Overhead
Process Thread Data/Memory Independent address space Shares address space with other threads in same process. Each thread still has own registers and stack Communication Pipes, files, sockets High overhead Read data of another thread Low overhead Creation fork() Higher overhead pthread_create() Lower overhead Waiting/Synchronization wait() join() Use case Instance of a running program (an executable) Context Switching Overhead

12 Waiting/Synchronization Context Switching Overhead
Process Thread Data/Memory Independent address space Shares address space with other threads in same process. Each thread still has own registers and stack Communication Pipes, files, sockets High overhead Read data of another thread Low overhead Creation fork() Higher overhead pthread_create() Lower overhead Waiting/Synchronization wait() join() Use case Instance of a running program (an executable) Multithreaded process: divide up parallel tasks for a given program Context Switching Overhead

13 Waiting/Synchronization Context Switching Overhead
Process Thread Data/Memory Independent address space Shares address space with other threads in same process. Each thread still has own registers and stack Communication Pipes, files, sockets High overhead Read data of another thread Low overhead Creation fork() Higher overhead pthread_create() Lower overhead Waiting/Synchronization wait() join() Use case Instance of a running program (an executable) Multithreaded process: divide up parallel tasks for a given program Context Switching Overhead higher overhead (need to swap memory, page tables, etc.)

14 Waiting/Synchronization Context Switching Overhead
Process Thread Data/Memory Independent address space Shares address space with other threads in same process. Each thread still has own registers and stack Communication Pipes, files, sockets High overhead Read data of another thread Low overhead Creation fork() Higher overhead pthread_create() Lower overhead Waiting/Synchronization wait() join() Use case Instance of a running program (an executable) Multithreaded process: divide up parallel tasks for a given program Context Switching Overhead higher overhead (need to swap memory, page tables, etc.) lower overhead (only need to swap thread state)

15 Scheduling Scheduling: The process by which the kernel chooses the next thread to run There may be many threads ready to run at any given time Kernel must choose amongst the ready threads, and start running the chosen thread The kernel switches very quickly between threads of currently running processes, so everything gets some time to run A running thread can either yield to the scheduler, or a timer will go off to preempt the running thread Context Switch: The period during which we stop the current running thread, and load a new thread to run Priority Scheduling: Every thread is assigned a priority. The scheduler chooses the highest priority ready thread to run

16 Scheduling overview Creation Scheduler exit exit Yield, timer
New Terminated Creation Scheduler exit Ready Running exit Zombie Yield, timer I/O or syscall completion, lock_release of desired lock, etc. I/O, syscall, lock_acquire, join/wait, etc. Waiting


Download ppt "Threads and Scheduling"

Similar presentations


Ads by Google