Project2 - Threads - CS180 Synopsis Project 2 Due: Oct 20...

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

View Full Document Right Arrow Icon
CS180 Project 2 Due: Oct 20 Synopsis In this project, you will use a semaphore (a kind of synchronization primitive) to fix some synchronization issues in a small threaded program. Details The program supplied for this project (in a file named threads.cpp ) illustrates several problems with threaded programs, each of which you will fix. 1.The main thread initializes a variable count=0 and then starts up two threads. One thread will increment count 2 million times, and the other will decrement count 2 million times. The net result should leave count with a value of zero, however, because the two threads clash over the use of count , the result will often not be zero. You will fix this problem by protecting access to count with a semaphore. 2.In order to maximize the possibilities for the two threads to clash, I carefully synchronize the start of execution of the two threads. (Otherwise, one thread is done before the other starts, and no
Background image of page 1

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

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

Page1 / 2

Project2 - Threads - CS180 Synopsis Project 2 Due: Oct 20...

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

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