The University has specific recommendations on how to deal with students who copy code from other students for assignments, and for the students who allow the code to be copied. And we have automatic tools that detect copying, so you will be caught. Students have gotten F in the course in the past, so DON'T DO IT.
If you have trouble submitting, DO NOT EMAIL CODE TO THE TAs. You MUST wait for your disk partition to be cleared and then use the 402submit program again. This means you should PLAN YOUR WORK ACCORDINGLY - do not work right up until the deadline!
Much more recommended is to use the code browsing facility in Emacs enabled by creating tags as described below.
If you really want to print the code, first, go into the Makefile and find the line that says "LPR = lpr", and change it to read "LPR = lpr -Pxxxx", replacing "xxxx" with the name of the printer you want to use. Then type
cd nachos-csci402/code gmake print
cd nachos-csci402/code etags -t `find . \( -name '*.c' -o -name '*.cc' -o -name '*.h' \)`In Emacs, you can then use M-. to find the highlighted symbol's definitions. This is very cool, since it allows you, while reading the code to jump into the definition of a subroutine from the place where it is used.
ld.so.1: nachos: fatal: libucb.so.1: can't open file: errno=2
#!/bin/csh
#
if ( ${?LD_LIBRARY_PATH} ) then
setenv LD_LIBRARY_PATH /usr/ucblib:$LD_LIBRARY_PATH
else
setenv LD_LIBRARY_PATH /usr/ucblib
endif
It's a known limitation of our configuration. It's actually the
linker that's screwed up.
Have him put the following in his test directory, called nachos.ld and
change -T script to -T ./nachos.ld to his LDFLAGS. Works like a
charm, and took me forever to find. :-) (Most people don't have the
problem, so I didn't put the code in the tarball.)
SEARCH_DIR(/vex/gnu/decstation-ultrix/lib);
ENTRY(__start)
SECTIONS
{
.text : {
_ftext = . ;
*(.init)
*(.text)
etext = .;
_etext = .;
}
.data : {
*(.rdata)
*(.data)
*(.sdata)
*(.scommon)
}
.bss : {
*(.bss)
*(.sbss)
*(COMMON)
}
end = .;
_end = .;
}
Broadcast() signals ALL of the processes waiting on a condition variable.
However, note that in no case should a process actually be allowed to release a lock that it isn't holding!
You should be able to get allocate() and release() to break with appropriate insertions of Yield statements.
That said, here are some suggestions. One is you can have one thread exist for each Missionary or Cannibal that is there -- in other words, if you have 10 missionaries and 5 cannibals waiting for a boat, there would be 15 threads. Another way you can do it is have a Missionary thread and Cannibal thread; and each one keeps track of how many of its kind of people are waiting -- in this case, there would be 2 threads no matter how many missionaries and cannibals there are.
These are just two suggestions. You can do something else if you have a better idea, as long as it inolves multiple threads that are communicating via locks and condition variables. (Well, I should say you can do ALMOST anything else... silly solutions will not get points.)
legal: nachos -x noff_filname // defualt NRU nachos -P LRU -x filename // LRU -- NRU, RAND, FIFO also okay illegal: nachos -P filename // **ILLEGAL** nachos -P LRU noff_filename // **ILLEGAL** nachos -P -x noff_filename // **ILLEGAL
Assuming your memory is larger than 3 physical pages, this should never be a problem with with LRU, will usually not happen with NRU, and should never happen with FIFO. With Random, if you are very unlucky this might keep happening over and over again, leading to "livelock" (starvation), so if you like you may explicitly remove the pages involved in the current instruction from the list of candidate pages for ejection from physical memory. However this check is not required by the assignment.
Most implementations don't have these types of page faults, so this statistic will most likely simply be 0.
Just because you still see it on the disk does not mean that it is not "removed". The pointer to it is deleted, so to really test it, run the "nachos -l" command to list what is in the directory. It should not be listed. Also, you may try copying a new file to the disk and see if it overwrites what you remove.
Once you implement extensible files, your filesystem should work even if 0 is passed as the second argument of Create.
This is explained in Maurice Bach's book The Design of the UNIX Operating System in the following way (note that a Nachos FileHdr is equivalent to a UNIX inode):
When a process invokes the read system call, the kernel locks the inode for the duration of the call. Afterwards, it could go to sleep reading a buffer associated with data or with indirect blocks of the inode. If another process were allowed to change the file while the first process was sleeping, read could return inconsistent data. For example, a process may read several blocks of a file; if it slept while reading the first block and a second process were to write the other blocks, the returned data would contain a mixture of old and new data. Hence, the inode is left locked for the duration of the read call, affording the process a consistent view of the file as it existed at the start of the call.
In other words, when one process is writing to a file, no other processes may read from or write to that file until the first process is finished with the entire write (even if that write modifies more than one disk block).
Similarly, when one process is reading from a file, no other processes may write to that file until the first process is finished. However, you may allow more than one process to perform parallel Reads on the same file; allowing parallel reads is not required, though, because I think it is a little tricky (you'd have to make sure that a long series of reads won't lead to starvation of a writer waiting to write).
Note that you must allow parallel reads and writes that are accessing different files. In other words, Process A writing to File A should never block Process B from writing to File B.
Of course, if a file is Removed and no threads have it open at the time, you can free that file's resources immediately.
I tried to make the question as clear as possible on this point. It says, here are some possible approaches, they can make a design decision to choose one and then implement it.In terms of grading guidelines, what I had in mind was the following. Implementing any one of the approaches correctly gets you 3/4 of the marks. Picking the one right one for the benchmark and explaining why gets you another quarter. (Its a sequential testcase, that runs just once through a file, so the sequential disk block laying appraoch will work best). And we can give a 10% bonus for implementing each additional approach and doing the comparison between them.