CHESS Tutorial - Visual Studio

  1. Computer Requirements
  2. VS Chess Tutorial With LFQ Test 1
back to top

Computer Requirements

  1. Windows XP or later
  2. Visual Studio 2008 or later
  3. Microsoft CHESS (download here)
back to top

VS Chess Tutorial With LFQ Test 1

  1. You will first need the code for LockFreeQueue and the tests. You may download the zip file here. Extract it where you want. For this tutorial, I will be downloading the file to the desktop and I will extract it to the desktop.
  2. Open Visual Studio 2008.
  3. Create a new project. My new project will be a class library because I don't intend to have a Main method in my project. If I did intend to have a Main method in my project, I would probably choose a Console Application. I will call my new project and my new solution LockFreeQueue.
  4. The new project contains an empty class called Class1.cs that is not needed, so I'm going to delete it. Just right-click on the file in the Solution Explorer and select Delete.
  5. Now I'm going to add the class files that constitute the LockFreeQueue that were unzipped onto my desktop. Right-click on the project LockFreeQueue and select Add > Existing Item... Now go to where you extracted the LockFreeQueue.zip and add EmptyException.cs, LockFreeQueue.cs, LockFreeQueueWithError1.cs, LockFreeQueueWithError2.cs, and Node.cs.
  6. Now, add a test to the solution. Go to Test > New Test... and pick Unit Test. Make sure that the type of test is a C# test project. It doesn't matter what you call the test file because we'll delete it later anyways.
  7. Now you can delete the test class inside of the newly created test project. In my case, I will be deleting UnitTest1.cs. Just right-click on it in the Solution Explorer and select Delete.
  8. Now we are going to add the test class that already exists from the extracted LockFreeQueue.zip. Right-click on the new Test Project we created called TestLockFreeQueue and select Add > Existing Item and add QueueTest.cs from the extracted LockFreeQueue folder.
  9. Now, the class QueueTest.cs inside of the TestLockFreeQueue project needs to use the code that is in the classes in the LockFreeQueue project, so, we must add a reference inside of the TestLockFreeQueue class. In the Solution Explorer, inside of the TestLockFreeQueue project, right-click on References and select Add Reference. In the new window that pops up, select the Projects tab and select the LockFreeQueue project and press OK. This is intended to let the classes inside of the TestLockFreeQueue project to include usings for the namespaces inside of the LockFreeQueue project.
  10. Everything should be setup to run the Chess Tests. Double left-click on the ChessTest.cs class to open it. Find the method called TestLockFreeQueueWithError1( ) and press CTRL+R and then press T. This should run Chess on this method. This method is intended to test for the error introduced in the LockFreeQueueWithError1.cs class.
  11. Double-click on the failed test and a new tab should open up with a little bit more information on the results of the test. Go to the bottom of the results and copy the code in the section Standard Console Error. Paste the selection in the QueueTest class just before the TestLockFreeQueueWithError1 class and just after [HostType("Chess")].
  12. At this point, we can debug our code and step through the code using the interleaving that CHESS found that caused the error. In order to debug this test, press CTRL+R then CTRL+T.
  13. Unfortunately, the debug doesn't help very much, as it only stays in one thread until there is a break point in the other thread. If you really want to understand where the code goes line by line, you need to add a break point on every line of code in the enq( ) method inside of the LockFreeQueueWithError1 class. It isn't required, but placing a breakpoint on every line will give you a clue as to what is happening.
  14. Examine all you wish using this debugger, this tutorial is over. You may view the tutorial of how to use the command-line tool mchess.exe to analyze the code and use ConcurrencyExplorer.exe to understand the interleavings in a more detailed manor.