Project 1 will involve learning about Nachos, the emulated machine, and threads in Nachos. To get an early start on the first project, you might want to copy the source code to your directory, make sure it compiles, and skimming through the following resources. Read the general overviews, and start skimming the parts that pertain to the emulated machine and threads. You can ignore most of the rest of the code for now. o Read Appendix A in the 4th edition of Silberschatz & Galvin, or "Overview Paper", on the class web page o Skim the material on threads in Kalra's "Salso -- An Operating System Tutorial", on the class web page o Skim Section 2 "Nachos Machine" and Section 3 "Nachos Thread" in Narten's "A Road Map Through Nachos", on the class web page o Start looking at the code in the theads and machine directories If you are not familiar with C++, see the material referenced on the class web page You might find it convenient to proint out the code in the threads and machine directories. I like printing files using "a2ps" and "lp" to get a nice two-column output, but "a2ps" doesn't appear to exist on trident, although it is on aegis: "a2ps -nL -kc++ filename | lp" In the past, copies of all the code were avaiable from the departmental office, but unfortunately that service is no longer available. Before compiling Nachos, you must copy the Nachos source code to your account. The full Nachos distribution from UC Berkeley is huge, but you don't need a copy of everything. If you do want to see everything that's included in the original distribution, read the file ~walker/pub/README and look at the files in the directory ~walker/pub/nachos-3.4-orig. To copy only the minimum to your account, copy the Makefiles, the files having to do with threads, and some of the files having to do with the emulated machine, as shown below. Note that even this subset of the files takes up a fair amount of space, so you may have to clean up your account. If you're having trouble fitting them in, check the size of your Netscape cache -- an account with a 5MB disk quota fills up pretty quickly with a 3MB Netscape cache! This version of Nachos works on intrepid.mcs.kent.edu, but not on the other machines in the department. To compile it, log onto intrepid and compile as follows: intrepid 101: mkdir nachos intrepid 102: mkdir nachos/threads intrepid 103: mkdir nachos/machine intrepid 104: cp ~walker/pub/nachos-3.4-hp/code/Make* nachos intrepid 105: cp ~walker/pub/nachos-3.4-hp/code/threads/* nachos/threads intrepid 106: cp ~walker/pub/nachos-3.4-hp/code/machine/* nachos/machine intrepid 110: cd nachos Assuming you had room in your account, and copied the files successfully, you can compile Nachos so as to produce an executable file named "nachos" in the threads directory. Again, it's possible that you could run out of space here also. Note that most of what's printed below is the output of the compilation process. intrepid 111: make cd threads; /local/opt/gcc/bin/make depend g++ -I../threads -I../machine -DTHREADS -DHOST_SNAKE -DHOST_IS_BIG_ENDIAN -DCHANGED -M ../threads/main.cc ../threads/list.cc ../threads/scheduler.cc ../threads/synch.cc ../threads/synchlist.cc ../threads/system.cc ../threads/thread.cc ../threads/utility.cc ../threads/threadtest.cc ../machine/interrupt.cc ../machine/sysdep.cc ../machine/stats.cc ../machine/timer.cc > makedep echo '/^# DO NOT DELETE THIS LINE/+2,$d' >eddep echo '$r makedep' >>eddep echo 'w' >>eddep ed - Makefile < eddep rm eddep makedep echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile echo '# see make depend above' >> Makefile cd threads; /local/opt/gcc/bin/make nachos g++ -g -Wall -Wshadow -fwritable-strings -I../threads -I../machine -DTHREADS -DHOST_SNAKE -DHOST_IS_BIG_ENDIAN -DCHANGED -c ../threads/main.cc g++ -g -Wall -Wshadow -fwritable-strings -I../threads -I../machine -DTHREADS -DHOST_SNAKE -DHOST_IS_BIG_ENDIAN -DCHANGED -c ../threads/list.cc g++ -g -Wall -Wshadow -fwritable-strings -I../threads -I../machine -DTHREADS -DHOST_SNAKE -DHOST_IS_BIG_ENDIAN -DCHANGED -c ../threads/scheduler.cc g++ -g -Wall -Wshadow -fwritable-strings -I../threads -I../machine -DTHREADS -DHOST_SNAKE -DHOST_IS_BIG_ENDIAN -DCHANGED -c ../threads/synch.cc g++ -g -Wall -Wshadow -fwritable-strings -I../threads -I../machine -DTHREADS -DHOST_SNAKE -DHOST_IS_BIG_ENDIAN -DCHANGED -c ../threads/synchlist.cc g++ -g -Wall -Wshadow -fwritable-strings -I../threads -I../machine -DTHREADS -DHOST_SNAKE -DHOST_IS_BIG_ENDIAN -DCHANGED -c ../threads/system.cc g++ -g -Wall -Wshadow -fwritable-strings -I../threads -I../machine -DTHREADS -DHOST_SNAKE -DHOST_IS_BIG_ENDIAN -DCHANGED -c ../threads/thread.cc ../threads/thread.cc: In method `void Thread::CheckOverflow()': ../threads/thread.cc:121: warning: comparison between signed and unsigned g++ -g -Wall -Wshadow -fwritable-strings -I../threads -I../machine -DTHREADS -DHOST_SNAKE -DHOST_IS_BIG_ENDIAN -DCHANGED -c ../threads/utility.cc g++ -g -Wall -Wshadow -fwritable-strings -I../threads -I../machine -DTHREADS -DHOST_SNAKE -DHOST_IS_BIG_ENDIAN -DCHANGED -c ../threads/threadtest.cc g++ -g -Wall -Wshadow -fwritable-strings -I../threads -I../machine -DTHREADS -DHOST_SNAKE -DHOST_IS_BIG_ENDIAN -DCHANGED -c ../machine/interrupt.cc g++ -g -Wall -Wshadow -fwritable-strings -I../threads -I../machine -DTHREADS -DHOST_SNAKE -DHOST_IS_BIG_ENDIAN -DCHANGED -c ../machine/stats.cc g++ -g -Wall -Wshadow -fwritable-strings -I../threads -I../machine -DTHREADS -DHOST_SNAKE -DHOST_IS_BIG_ENDIAN -DCHANGED -c ../machine/sysdep.cc g++ -g -Wall -Wshadow -fwritable-strings -I../threads -I../machine -DTHREADS -DHOST_SNAKE -DHOST_IS_BIG_ENDIAN -DCHANGED -c ../machine/timer.cc /lib/cpp -P -I../threads -I../machine -DHOST_SNAKE -DHOST_IS_BIG_ENDIAN ../threads/switch.s > swtch.s as -o switch.o swtch.s as: "swtch.s", line 150: warning 44: Value for ACCESS was not specified for this new .SUBSPA directive. g++ main.o list.o scheduler.o synch.o synchlist.o system.o thread.o utility.o threadtest.o interrupt.o stats.o sysdep.o timer.o switch.o -o nachos If you get the output shown above, a "nachos" executable file has been compiled successfully into the threads directory (later on, there will be other directories for the other projects). To check, go to the threads directory and look for an executable file named "nachos" ("ls -F" adds a "*" to the end of the filename for executable files, and a "/" to the end of the filename for directories). intrepid 112: cd threads intrepid 113: ls -F Makefile scheduler.cc synch.h thread.cc.orig bool.h scheduler.h synch.o thread.h copyright.h scheduler.o synchlist.cc thread.o interrupt.o stats.o synchlist.h threadtest.cc list.cc switch.h synchlist.o threadtest.o list.h switch.o sysdep.o timer.o list.o switch.s system.cc utility.cc main.cc switch.s.orig system.h utility.h main.o swtch.s system.o utility.o nachos* synch.cc thread.cc Now try running Nachos. As distributed, function main() calls function ThreadTest(), which forks a new thread, and then the two threads take turns running one iteration of a loop that eventually iterates 5 times. As part of the first project, you'll replace this with something more interesting. intrepid 114: nachos *** thread 0 looped 0 times *** thread 1 looped 0 times *** thread 0 looped 1 times *** thread 1 looped 1 times *** thread 0 looped 2 times *** thread 1 looped 2 times *** thread 0 looped 3 times *** thread 1 looped 3 times *** thread 0 looped 4 times *** thread 1 looped 4 times No threads ready or runnable, and no pending interrupts. Assuming the program completed. Machine halting! Ticks: total 130, idle 0, system 130, user 0 Disk I/O: reads 0, writes 0 Console I/O: reads 0, writes 0 Paging: faults 0 Network I/O: packets received 0, sent 0 Cleaning up... intrepid 115: