BEST代写-线上编程学术专家

Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

C语言代写|CSE 486 PA-5: Nachos System Calls for File I/O

C语言代写|CSE 486 PA-5: Nachos System Calls for File I/O

本次美国代写是一个C语言操作系统的assignment

 

Task 0 Prerequisites (Must be done)

1. Obtain student-pa5.tar.gz from Blackboard. student-pa5.tar.gz is a compressed archive file, similar to
a zip file. It’s also called a tar package. The package contains the skeleton code required for PA-5.

2. Log in to lcs-vc-cis486.syr.edu and create a new directory for this lab (say, my-pa5/).

3. Upload student-pa5.tar.gz to your newly created directory in the Linux server. [­ Hint: Use a tool like
FileZilla, sp, scp that you have learned in lab-1.]

4. Using the terminal of the Linux server, go to the directory where you have uploaded student-pa5.tar.gz.
Now, unpack the package on the Linux server as follows
prompt> tar xzf student-pa5.tar.gz

5. The extracted directory is named student/, which contains the nachos/ directory.
 student/nachos/code/ will be considered the Nachos base directory. Unless otherwise stated, all
nachos related paths are relative to this base directory.

Task 1 Implement System Calls for File I/O (40 pts)

You may want to revisit PA-4 and your solution to refresh memory on how to implement a system call.
For this task, you have to implement the following system calls that the Nachos user programs can utilize for file I/O
operations.

1. int Create(char *name): This system call creates a Unix file with the name given by the parameter “name”,
and returns 1 on success, and -1 on failure, to the user program.

¨ Implement another function that extracts the file name from the user program memory so that you can
re-use the name extraction function for other Nachos system calls, if necessary.

­ It is recommended that you utilize the Unix/Linux open() system call to implement this Nachos system call in
exception.cc. (See the documentation of Unix/Linux open() syscall)

[Hint: Implement this system call first. The Nachos Open() system call implementation is very similar. ]

2. OpenFileId Open(char *name): This system call opens the Unix file with the name given by the parame
ter“name” and returns an “OpenFileId” (aka, a file descriptor) if the file exists. This OpenFileId can be used
to read from and write to the file. If the file doesn’t exist, Open() returns -1 to the user program to indicate an
error.

It is recommended that you utilize the Unix/Linux open() system call to implement this Nachos system call in
exception.cc. (See the documentation of Unix/Linux open() syscall)

You don’t have to maintain a separate mapping between a Nachos OpenFileId and a Unix file
descriptor. Instead you can simple return the same file descriptor that the Unix open(…) syscall
returns.

3. int Write(char *buffer, int size, OpenFileId id): Utilize your implementation of Write() from
PA-4 and extend it so that it can now write to an already open Unix file (specified by id) as well as print out to
the screen. This function returns the number of bytes actually written or -1 on failure.

It is recommended that you utilize the Unix/Linux write() system call to implement this Nachos system call in
exception.cc. (See the documentation of Unix/Linux write() syscall)

4. int Read(char *buffer, int size, OpenFileId id): This system call reads size bytes from the open
file (specified by id) and stores them into buffer. On success, it returns the number of bytes actually read from
the file (note: it can be 0 too), and on failure, it returns -1.

For this task, implement only the case for reading from a file; you don’t have to implement the case for
reading from ConsoleInput (i.e., keyboard input).

It is recommended that you utilize the Unix/Linux read() system call to implement this Nachos system call in
exception.cc. (See the documentation of Unix/Linux read() syscall)

5. int Close(OpenFileId id): Close the file specified by id. It returns 1 on success and -1 on failure.
­ It is recommended that you utilize the Unix/Linux close() system call to implement this Nachos system call in
exception.cc. (See the documentation of Unix/Linux close() syscall)

What to report for Task 1?

Try the list of tasks below in the order and provide answer/screenshot as stated.

Do not forget to re-build nachos if required and run it from build.linux/
J [R-1] (4 × 5 = 20 pts) For each system call mentioned above, provide at least one screenshot of your implemen
tation. Your screenshots should be legible. Therefore, if the implementation of a system call requires more
than one screenshots, please provide them and mark them appropriately. [Hint: There should be at least 5
screenshots.]

J [R-2] ((2 + 1.5 + 2) × 4 = 22 pts) Build the test programs in test-pa/ if needed. Build nachos in build.linux/.
test-pa/ includes four user programs for testing your implementation of the above systems calls:
file-test0.c, file-test1.c, file-test2.c and file-test3.c.

bestdaixie

评论已关闭。