COMP10052-AAAF-09-2010-for-viewing

For example on queues onto which we put and from which

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview:   Opera<ons that seem atomic (i.e., executable in one single step) actually compile into several steps one level down in the sofware stack. When processes run concurrently, we must concern ourselves with what order they can run in, and with the places at which they can cause (one level down) interrup<ons to one another. P1: fun foo(x,y) -> eax <- mem[x]; inc eax; mem[x] <- eax; ebx <- mem[x]; mem[y] <- ebx; P2: fun bar(x,y) -> eax < mem[y]; inc eax; mem[y] <- eax; eax <- mem[x]; add eax, 3; mem[x] <- eax; Synchronize/Sequence (3) 14       The risk is bad enough already for scalar values (like integers), but it gets worse on collec<ons. For example, on queues, onto which we put, and from which we take, items. In a master ­and ­workers segng, we need to be sure that items are collected and results deposited in such a way that the computa<on is ul<mately correct.     A synchroniza/on primi/ve is a special programming language construct deno<ng a shared variable that comes with a OS/hardware ­ enforced guarantee that it can only be accessed atomically. This means that code blocks guarded by such primi<ves lead to enforced execu<on sequences. Synchronize/Sequence (4) 15         One popular synchroniza<on primi<ve is referred to as a barrier. A barrier knows in advance how many independent processes it should wait for. When, in the execu<on path, a process reaches the barrier, this event is recorded. The process then goes into wai<ng mode.       When all processes have reached the barrier, all wai<ng processes are no<fied and allowed to resume execu<on. This presupposes processes reach the barrier more or less together. This, in turn, presupposes balanced workloads (e.g., par<<ons that are similar in size on machines that similarly capable). Task Independence 16     When independent branches of an algebraic expression commute and do not access (i.e., make no reference to) shared state, they can be executed in an...
View Full Document

Ask a homework question - tutors are online