mod05-2up

mod05-2up - 12-03-15 CS 230 Introduction to Computers and...

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

View Full Document Right Arrow Icon
12-03-15 1 CS 230 - Winter 2012 5-1 CS 230 – Introduction to Computers and Computer Systems Module 5 – Concurrency (Slides based on materials prepared by Martin Karsten ) CS 230 - Winter 2012 5-2 Overview multiprogramming / multiprocessing mutual exclusion / signalling communication
Background image of page 1

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

View Full DocumentRight Arrow Icon
12-03-15 2 CS 230 - Winter 2012 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 CS 230 - Winter 2012 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 2
12-03-15 3 CS 230 - Winter 2012 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. .. CS 230 - Winter 2012 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 3

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

View Full DocumentRight Arrow Icon
12-03-15 4 CS 230 - Winter 2012 5-7 Execution Context CPU state control: PC, SP, status register, etc. data registers memory state – details later. .. code data stack CS 230 - Winter 2012 5-8 Thread 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 4
12-03-15 5 CS 230 - Winter 2012 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 CS 230 - Winter 2012 5-10 Thread Switch similar, but different from subroutine context switch can happen at any time not known which thread is next all registers must be saved switching of stacks (isolation) process switch address space context must also be switched
Background image of page 5

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

View Full DocumentRight Arrow Icon
12-03-15 6 CS 230 - Winter 2012 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 CS 230 - Winter 2012 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 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/01/2012 for the course CS 230 taught by Professor Bb during the Spring '11 term at Waterloo.

Page1 / 24

mod05-2up - 12-03-15 CS 230 Introduction to Computers and...

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

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