ThreadMentor is a system designed to help students learn and instructors teach threaded programming and the use of synchronization primitives. The system has two components: a class library and a visualization system. The class library supports thread managements (e.g., thread creation, join and termination) and all popular synchronization primitives (e.g., mutex locks, semaphores, monitors, barriers, reader-writer locks, and synchronous and asynchronous channels). These features are encapsulated into a number of classes. The visualization system can display the execution behavior and the control information of each synchronization primitive on-the-fly.
A user writes his threaded program using the class library and does not have to worry about the visualization system. If the program is compiled with the library that includes the visualization system, the visualization system is activated when the program runs. On the other hand, if a user program is compiled with the library without the visualization system, this is simply a threaded program and no visualization is available. Therefore, whether you want to use the visualization system is controlled by which library you will be using.
Why two separate libraries? We believe that it is very useful to have the visualization system activated in early stage of program development. With the visualization system activated, a student can easily build a sense that the threads created by a threaded program are run concurrently, and can monitor the progress of the threaded program and the behavior of the synchronization primitives. With one of two clicks, a student can bring up various windows to see the internals of synchronization primitives. In this way, debugging would be easier because a student could reconstruct all events of a threaded program and the involved synchronization primitives with minimal effort. After a program is fully debugged, it can be recompiled with the library without the visualization system, and, as a result, the user program is run in full speed.
ThreadMentor runs on Sun Solaris, Linux and Windows 95/98/2000. Essentially, it is platform independent. In doing so, we have to make some compromises as will be discussed later in this tutorial. If you are interested, click here for the ThreadMentor home page and here to learn more about this project.