BASIC CONCEPTS =================== THREAD ========= Thread is basically a program which is sequentially executed. It is a lightweight process and it has an execution stack associated with it. example thread A { int i=0; int k=9; k= i+1; } HOW NACHOS SIMULATES THREAD FOR TEST CASES ======================================== Nachos simulates forked threads in the form of function called simpleThread which is executed in a loop. Nachos "main" thread will be the main program running as a unix process. This Function resides in the threads directory in file threadtest.cc SYNCHRONIZATION ================ Synchronization is a mechanism through which you can enforce that shared data must be accessed by a single thread at a time or that operations across threads occur in a particular order, regardless of the execution order from the CPU scheduler. HOW SYNCHRONIZATION IS ACHIEVED (NACHOS) ======================================== You can enforce synchronization by implementing higher level atomic operations . Synchronization is achieved by using locks, condition variables and semaphores. Semaphore are already implemented in the threads directory in file synch.h/synch.cc You have to implement the locks and condition variables. The classes are defined in synch.h. you can add new member variables and member functions to that classes. INSTALLING AND RUNNING NACHOS ======================================== Follow the instructions on the "Nachos" link on the course web site. RUNNING DDD ============================= Follow the instructions/tutorial on the assignments web page - near the bottom. The link is entitled "All about ddd". WHAT YOU HAVE TO DO FOR PROJECT 1 ====================================== NOTE: You are not allowed to change any of the file in the machine directory. Project 1 only require changes in the threads directory. What You have to do is to implement the synchronization among the threads being provided to you in a testsuite . For Part 1: We have provided you with the Test suite . Copy and paste that into the threadtest.cc file. You can call TestSuite() function from the command line by implementing the command line argument -T . This is given in the guidelines on class websuite. For Implementation , In synch.h classes for Lock and condition variables are already defined. You have to implement those in the synch.cc. while Implementing Locks make sure that ----------------------------------------- --- The thread trying to release the lock should be the one who had acquired that lock. Hint: You can do it by storing the thread pointer associated with the particular lock and checking it in isHeldBycurrentThread() function. While implementing Condition variables make sure that ----------------------------------------------------- ---The current thread has acquired the lock before calling any of the Signal, Wait or Broadcast. ---The thread signalling or broadcasting should have acquired the lock which is associated with that condition. In general ------------ ---Any of the wrong behavior should result in the debug message or print message showing what the error is and the program should terminate gracefully. ----No assertion failures are allowed. In testSuite various test cases use Locks and condition variables for synchronization. After implementing the lock and condition classes, follow the debug path and check how it works. WHAT IS "-rs" OPTION ============================ "-rs" stands for random seed . Basically , this option is given at the command line followed by any random number. This is used to check the correctness of your implementation of locks and condition classes(synchronization). for example the command may be . nachos -T -rs 456 Internally , in the Initialize function implemented in system.cc, -rs option invokes the timer object to be initialized . when timer object is initialized, it calles TimerInterruptHandler(int dummy) ,in system.cc, function at random amount of time . so this timerinterrupt function causes current thread to yield . As a consequence of this random context switching , the output/result should not be effected and the bahevior should not lead towards the race condition. So, check your code with several of -rs values.