$39
(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)
$ ../build.linux/nachos -d + -e add
(d). Trace the Makefile in code/test/Makefile to understand how test files are compiled.
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 handle invalid file open requests, including the non-existent file, exceeding opened file limit (at most 20 files), etc.
(c). All valid file open requests must be accepted if the opened file limit (at most 20 files) is not reached. Duplicate Openfile is allowed
(d). Must handle invalid file read, write, close requests, including invalid id, etc.
(e). DO NOT modify the declaration of OpenFileTable, including the size.
(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
(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
*Late submissions will not be accepted. Refer to the course syllabus for detailed homework rules and policies.