Starting from:
$35

$29

CS342301: Operating System MP1: System Call

  1. Goal

    1. Understand how to work in Linux environment.

    1. Understand how system calls are implemented by OS.

    1. Understand the difference between user mode and kernel mode.

  1. Assignment

    1. Trace code

  • Working items:

(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


  • Requirements:

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.


  1. Implement four I/O system calls in NachOS

  • Working items

(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)

  • Requirements:

(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.

  • Hint & Reminder:

(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/.

  • Verification:

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


  1. Report

    • Working items

(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.

  1. Set VPN

  1. Login server

    • 10.121.187.197

    • Username: os21team + your teamID (e.g. os21team01)

    • Password: You are required to reset the password once you login

  1. Install NachOS

    • cp -r /home/os2021/share/NachOS-4.0_MP1 .

    • cd NachOS-4.0_MP1/code/build.linux

    • make clean

    • make

  1. Compile/Rebuild NachOS

    • cd NachOS-4.0_MP1/code/build.linux

    • make clean

    • make

  1. Test NachOS

    • cd NachOS-4.0_MP1/code/test

    • make clean

    • make halt

    • ../build.linux/nachos -e halt

IV.Grading

  1. Implementation correctness – 50%

    • Pass the public and hidden test cases.

    • You DO NOT need to upload NachOS code to iLMS, and just put your code to the folder named “NachOS-4.0_MP1” in your home directory.

    • Your working directory will be copied for validation after the deadline.

  1. Report – 30%

    • Name the report “MP1_report_[GroupNumber].pdf”, and upload it to iLMS.

  1. Demo– 20%

    • We will ask several questions about your codes.

    • Demo will take place on our server, so you are responsible to make sure your code works on our server.

More products