10.07.2015 Views

Is Parallel Programming Hard, And, If So, What Can You Do About It?

Is Parallel Programming Hard, And, If So, What Can You Do About It?

Is Parallel Programming Hard, And, If So, What Can You Do About It?

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

A.1. WHAT DOES “AFTER” MEAN? 155TimeProducerss.t = dgettimeofday();ss.a = ss.c + 1;ss.b = ss.a + 1;ss.c = ss.b + 1;ProducerConsumercurssc.tc = gettimeofday();curssc.t = ss.t;curssc.a = ss.a;curssc.b = ss.b;curssc.c = ss.c;ss.t = dgettimeofday();ss.a = ss.c + 1;ss.b = ss.a + 1;ss.c = ss.b + 1;FigureA.3: EffectofLockingonSnapshotCollectionprior holder of that lock. No need to worry aboutwhich CPU did or did not execute a memory barrier,no need to worry about the CPU or compilerreordering operations – life is simple. Of course, thefact that this locking prevents these two pieces ofcode from running concurrently might limit the program’sability to gain increased performance on multiprocessors,possibly resulting in a “safe but slow”situation. Chapter 5 describes ways of gaining performanceand scalability in many situations.However, in most cases, if you find yourself worryingabout what happens before or after a given pieceofcode, youshouldtakethisasahinttomakebetteruse of the standard primitives. Let these primitivesdo the worrying for you.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!