mod05 - CS 230 Introduction to Computers and Computer...

Info iconThis preview shows pages 1–14. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 230 - Winter 2011 5-1 CS 230 – Introduction to Computers and Computer Systems Module 5 – Concurrency Martin Karsten mkarsten@cs.uwaterloo.ca
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 230 - Winter 2011 5-2 Overview multiprogramming / multiprocessing mutual exclusion / signalling communication
Background image of page 2
CS 230 - Winter 2011 5-3 Multiprogramming CPUs are very fast many computer tasks do not saturate CPU everything but pure calculation tasks tasks interact with slow external entities devices: disk, network, mouse, keyboard, etc. human users (which read, think, wait, etc.) goal: use CPU to execute multiple tasks concurrently
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 230 - Winter 2011 5-4 One Size Fits All? use single program for everything? infeasible: size, structure, maintenance complexity innovation? => need structure tasks are implemented as programs , and executed as processes
Background image of page 4
CS 230 - Winter 2011 5-5 One to Rule Them All. .. operating system manages processes virtual execution environment for programs manage resources: CPU, memory, devices provides high-level abstraction goals: isolation, protection, resource access “OS is part cop, part facilitator.” (CS 350) -> details later. ..
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 230 - Winter 2011 5-6 Process process comprised of execution state –> thread describes the ongoing “activity” data –> address space I/O associations open files network connections, etc. multiple threads –> concurrency
Background image of page 6
CS 230 - Winter 2011 5-7 Execution Context CPU state control: PC, SP, status register data registers memory code data stack
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 230 - Winter 2011 5-8 Context Switch assume enough memory for multiple processes switching between processes: thread switch suspend execution of a thread store CPU state on stack store stack pointer in per-thread data structure resume execution of another thread load stack pointer load CPU state from stack
Background image of page 8
CS 230 - Winter 2011 5-9 Context Switch - Stack Thread 1 Thread 2 T1 T2 T3 ... SP etc. SP etc. SP etc. 0 0 SP before switch SP SP SP after switch CPU state CPU state
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 230 - Winter 2011 5-10 Context Switch similar, but different from subroutine context switch can happen at any time all registers must be saved switching of stacks (isolation) process switch address space context must also be switched
Background image of page 10
CS 230 - Winter 2011 5-11 Multithreading rapid and somewhat unpredictable thread context switching illusion of parallel execution interactivity –> fast response to events threads without work are sent to sleep waiting for I/O event: blocking
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 230 - Winter 2011 5-12 Scheduler (operating system) entity managing threads keeps list of ready threads and decides which to activate next scheduler is invoked whenever a thread pauses execution (for possibly different reasons)
Background image of page 12
CS 230 - Winter 2011 5-13 Scheduler think of a coach managing players: active threads = players on field
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 14
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/28/2011 for the course CS 230 taught by Professor Bb during the Spring '11 term at Waterloo.

Page1 / 48

mod05 - CS 230 Introduction to Computers and Computer...

This preview shows document pages 1 - 14. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online