Please complete the required studio exercises listed below, along with any of the (optional) enrichment exercises that interest you.
As you work through the exercises, please record your answers in a file, and upon completion please e-mail your answers to the firstname.lastname@example.org course e-mail account with Atomic Types Studio in the subject line.
Please make sure that the name of each person who worked on these exercises is listed in the first answer, and that you number your answers so they are easy for us to match up with the appropriate exercise.
In the main C++ source code file for the project (which should be named something like
atomic_types.cpp) please modify the main function signature so that it
looks like the standard (i.e., portable between Windows and Linux) main function entry point
int main (int, char * )
In your main function, declare instances of the various
atomic_types listed in tables 5.1
and 5.2 of the required course text book ("C++ Concurrency in Action" by Williams, referred to as [Williams]
on the course web site, and in the rest of this studio description), and see which of them are supported
by Visual Studio 2013 (don't forget to include the
<atomic> library, etc.).
Build and run your program and as the answer to this exercise, please list all of the atomic types that are supported in Visual Studio 2013 on the windows lab machines (a.k.a. the studio environment).
Build and run your program, and as the answer to this exercise, please list all of the atomic types that are lock free in the studio environment, and then list all of the atomic types that are not lock free in the studio environment.
z(and you can leave off including the
<assert.h>library) please have your program print out the value of variable
zat the end of your program.
Also modify your program so that the main function accepts a single command line argument for the number
of times to run the test (which defaults to 1 if no command line argument is given) and then loops that many
times: resetting the values of the
y (but not
and then launching the two threads and then joining with both of them, each time through the loop.
Build and run your program with different numbers of iterations of the test, and as the answer to this exercise please indicate for each run: (1) how many iterations were run, and (2) what value of z was printed out.
memory_order_relaxed) it enforces a sequential consistent ordering (
Build and run your program with the same set of trials as in the previous exercise, and as the answer to this exercise please indicate: (1) whether (and if so how) the behavior changed, and (2) why you think it did or did not change based on the program outputs for each exercise.
Build and run your program with the same set of trials as in the previous two exercises, and as the answer to this exercise please indicate: (1) which one (or perhaps both) of the previous exercises showed program behavior that was most similar to that seen in this exercise, and (2) why you think that.
memory_order_relaxed), but then add a memory fence (or fences) to re-establish strict synchronization.
Build and run your program with the same set of trials as in the previous three exercises, and as the answer to this exercise please (1) show your code and then indicate: (2) which one (or two or three) of the previous exercises showed program behavior that was most similar to that seen in this exercise, and (3) why you think that.