$29
(a). Trace the SC_Halt system call to understand the implementation of a system call. (Sample code: halt.c)
(b). Trace the SC_Create system call to understand the basic operations and data structure in a file system. (Sample code: createFile.c)
(c). Trace the SC_PrintInt system call to understand how NachOS implements asynchronized I/O using CallBack functions and register schedule events. (Sample code: add.c and LotsOfAdd)
$ ../build.linux/nachos -d + -e add 0 -e LotsOfAdd 50
Include the following answers in your writing report:
(a). Explain the purposes and details of each function call listed in the code path above.
(b). Explain how the arguments of system calls are passed from user program to kernel in each of the above use cases.
(a). OpenFileId Open(char *name);
Open a file with the name, and return its corresponding OpenFileId.
Return -1 if fail to open the file.
(b). int Write(char *buffer, int size, OpenFileId id);
Write “size” characters from the buffer into the file, and return the number of characters actually written to the file.
Return -1, if fail to write the file.
(c). int Read(char *buffer, int size, OpenFileId id);
Read “size” characters from the file to the buffer, and return the number of characters actually read from the file.
Return -1, if fail to read the file.
(d). int Close(OpenFileId id);
Close the file with id.
Return 1 if successfully close the file. Otherwise, return -1. Need to delete the OpenFile after you close the file (Can’t only set the table content to NULL)
(a). Must maintain OpenFileTable and use the table entry number of OpenFileTable as the OpenFileId.
(b). Must use OpenFile object to access file. Do Not directly use the function in “sysdep.h” to access file.
(c). Must handle invalid file open requests, including the non-existent file, exceeding opened file limit (at most 20 files), etc.
(d). All valid file open requests must be accepted if the opened file limit (at most 20 files) is not reached.
(e). Must handle invalid file read, write, close requests, including invalid id, etc.
(f). DO NOT use any IO functions from standard libraries (e.g. printf(), cout, fopen(), fwrite(), write(), etc.).
(g). DO NOT change any code under “machine/” folder
(h). DO NOT modify the content of OpenFileTable outside “filesystem/” folder
(i). DO NOT modify the declaration of OpenFileTable, including the size.
(a). We use the stub file system for this homework, so DO NOT change or remove the flag -DFILESYS_STUB in the Makefile under build.linux/.
First use the command “../build.linux/nachos -e fileIO_test1” to write a file. Then use the command “../build.linux/nachos -e fileIO_test2” to read the file
(a). Cover page, including team member list, team member contributions
(b). Explain how system calls work in NachOS as requested in Part II-1.
(c). Explain your implementation as requested in Part II-2.
(d). What difficulties did you encounter when implementing this assignment?
(e). Any feedback you would like to let us know.
II. Instructions
Below are the basic instructions. More information can be found in the NachOS tutorial slides.
IV.Grading