CS 3733 Operating Systems, Fall 2003 Recitation Session 7


Week of October 20.
In this session you will use a producer-consumer, bounded buffer simulator.

  1. Log on to your account in the Linux Lab.
  2. Create a rec07 directory somewhere under your cs3733 directory.
  3. Download this tar file and untar it into your rec07 directory.
  4. In that directory, execute runpc. If all goes well you will have started the producer-consumer bounded buffer simulator.
  5. Exit the simulator with the Quit button in the upper right corner.
  6. Edit the file pcconfig and change the username to your name.
  7. Start the simulator again.
  8. This is simulating a single producer and a single consumer. Become familiar with the code used by the producer and consumer as displayed in the simulator window. It should seem familiar. The only critical sections are the incrementing and decrementing of the counter.
    In this simulation the critical sections are not protected and so the program can fail.
  9. Push the Reset button to reinitialize the simulator.
  10. Use the One Cycle and 10 Cycles buttons to run the producer almost two times through its loop.
  11. The above example shows an internal inconsistency in the program. The program has not yet incorrectly produced or consumed anything, but if the program is run long enough, there is the possibility that the consumer will consume an item it has already consumed. The rest of the experiments you will will examine how long it may take for this to happen.
  12. Read the discussion of internal and external inconsistencies in the bounded buffer problem here.
  13. Reset the simulator using the Reset button and look at the second column of buttons under the producer window.
  14. Find the button labeled Failure Type: Internal Inconsistency again and push this button once. It should change to Failure Type: External Inconsistency.
  15. Push the Reset button again and open the log file.
  16. Push the 10 Runs and the simulator will perform 10 runs, each time running until an external inconsistency occurs.
  17. Close the log file and bring up the log file in a browser window. The name of the log file is logfile.html. Look at the two tables at the bottom of the page.
  18. The last table categorizes the types of failures. The simulator keeps track of the first internal failure that occurred and shows the number that occurred in the producer and the number that occurred in the consumer. It also lists the two types of external failures that occurred.
  19. The interesting table is the one above the last one. It gives the number of cycles before a particular type of event occurred. 10 runs were performed. Look at the column of numbers labeled Average.
  20. Compare the average number of cycles needed to produce an external inconsistency to the average number of cycles before the first internal inconsistency. Recall that the program does not produce incorrect output until an external inconsistency has occurred.
  21. Write a short paragraph about what these results tell you about how long it takes an internal inconsistency to manifest itself in the output of a program. Put this at the end of your log file.
  22. Put a copy of the log file in your web directory an put a link to it on your CS 3733 web page.
  23. Show the TA that you have done this.