Operating Systems :: Project Pages :: Project 4
Project 4: Threads in C++11
Revision dated 3/21/16
Educational Objectives:
After the assignment the student should be able to:
Operational Objectives:
- Use C++11 thread management tools to correct the program race0.cpp
so that no data race conditions can occur.
- Use C++11 thread management tools to correct the program pro-con0.cpp
so that no deadlocks can occur.
Deliverables: Two files: race.cpp and pro-con.cpp.
C++11 Thread Support
Please see the on-going writeup here:
C++ Thread Library. The short Bo Qian videos 1-6 will be
helpful as well.
Procedural Requirements
Copy all of the files in LIB/proj4 into your proj4
directory. Note that deliverables.sh and a makefile are supplied.
Copy race0.cpp to race.cpp and modify the code
in race.cpp to prevent data race conditions.
Copy pro-con0.cpp to pro-con.cpp and modify the code
in pro-con.cpp to prevent deadlocks.
Submit the assignment using the command submit.sh.
Warning: Submit scripts do not work on the program and
linprog servers. Use shell.cs.fsu.edu to submit assignments. If you do
not receive the second confirmation with the contents of your assignment, there has
been a malfunction.
Technical Requirements and Specifications
Use RAII to handle possible unusual exits from scope, such as exception throws.
Have no "busy-waiting" loops.
Do not modify "0" versions below the indicated location in the file.
Do not call thread "detach".
Programs must build without errors or warnings using the supplied
makefile:
make race.x # builds race.c
make pro-con.x # builds pro-con.x
The possibility of race conditions must be eliminated.
Access to shared resources must be effectively controlled.
Hints:
Please read and understand the supplied source code in: race0.cpp, pro-con0.cpp, and
random_demo.cpp before beginning your own code modifications.
The supplied buffer.h provides an implementation of the Queue
API that has its own self-contained diagnostics and allows setting of a
bound for buffer size. Note that this is not a deliverable. You can assume
that a copy of the file will be in your portfolio.
The makefile builds both project executables and a demo program on
random distributions:
make random_demo.x # builds random_demo.x
make race.x # builds race.x
make pro-con.x # builds pro-con.x
make # builds all 3
|