![Page 1: Nachos Assignment#1 System calls implementation. What are system calls? Enable you to interact with OS kernel. A switch from User Mode to Kernel Mode](https://reader036.vdocument.in/reader036/viewer/2022083008/56649e9e5503460f94ba09fd/html5/thumbnails/1.jpg)
Nachos Assignment#1
System calls implementation
![Page 2: Nachos Assignment#1 System calls implementation. What are system calls? Enable you to interact with OS kernel. A switch from User Mode to Kernel Mode](https://reader036.vdocument.in/reader036/viewer/2022083008/56649e9e5503460f94ba09fd/html5/thumbnails/2.jpg)
What are system calls?
Enable you to interact with OS kernel. A switch from User Mode to Kernel Mode
![Page 3: Nachos Assignment#1 System calls implementation. What are system calls? Enable you to interact with OS kernel. A switch from User Mode to Kernel Mode](https://reader036.vdocument.in/reader036/viewer/2022083008/56649e9e5503460f94ba09fd/html5/thumbnails/3.jpg)
How does it work?(1)
![Page 4: Nachos Assignment#1 System calls implementation. What are system calls? Enable you to interact with OS kernel. A switch from User Mode to Kernel Mode](https://reader036.vdocument.in/reader036/viewer/2022083008/56649e9e5503460f94ba09fd/html5/thumbnails/4.jpg)
How does it work?(2)
![Page 5: Nachos Assignment#1 System calls implementation. What are system calls? Enable you to interact with OS kernel. A switch from User Mode to Kernel Mode](https://reader036.vdocument.in/reader036/viewer/2022083008/56649e9e5503460f94ba09fd/html5/thumbnails/5.jpg)
How does it work?(3)
![Page 6: Nachos Assignment#1 System calls implementation. What are system calls? Enable you to interact with OS kernel. A switch from User Mode to Kernel Mode](https://reader036.vdocument.in/reader036/viewer/2022083008/56649e9e5503460f94ba09fd/html5/thumbnails/6.jpg)
test/start.s MIPS dependend assembler code for userle
vel bindings Do not modify! How does it work:
gets parameter via registers (C-calling convention) loads syscall number into first register does a syscall exception (enter the kernel) jump back
![Page 7: Nachos Assignment#1 System calls implementation. What are system calls? Enable you to interact with OS kernel. A switch from User Mode to Kernel Mode](https://reader036.vdocument.in/reader036/viewer/2022083008/56649e9e5503460f94ba09fd/html5/thumbnails/7.jpg)
What are you going to do? Implement following system calls.
Create : Create a file with the “filename”
Open : Open a file with the “filename”
Read : Read from the file or console
Write : Write to the file or console
Close : Close the opened file with the”fid”
![Page 8: Nachos Assignment#1 System calls implementation. What are system calls? Enable you to interact with OS kernel. A switch from User Mode to Kernel Mode](https://reader036.vdocument.in/reader036/viewer/2022083008/56649e9e5503460f94ba09fd/html5/thumbnails/8.jpg)
Related Nachos codes (1) syscall.h
Definitions of the system call prototypes You have to implement it.
exception.cc The handler for system calls and other exceptions is he
re.
![Page 9: Nachos Assignment#1 System calls implementation. What are system calls? Enable you to interact with OS kernel. A switch from User Mode to Kernel Mode](https://reader036.vdocument.in/reader036/viewer/2022083008/56649e9e5503460f94ba09fd/html5/thumbnails/9.jpg)
Related Nachos codes (2) test/start.s
Assembly startup code of every user program of nachos.
To see how a user program does a system call and enters the kernel.
![Page 10: Nachos Assignment#1 System calls implementation. What are system calls? Enable you to interact with OS kernel. A switch from User Mode to Kernel Mode](https://reader036.vdocument.in/reader036/viewer/2022083008/56649e9e5503460f94ba09fd/html5/thumbnails/10.jpg)
What are Stubs for ?(1) Each system call has a stub associated with it.
Assembly codes used to : assist user programs to understand system calls.
Make system calls to kernels.
![Page 11: Nachos Assignment#1 System calls implementation. What are system calls? Enable you to interact with OS kernel. A switch from User Mode to Kernel Mode](https://reader036.vdocument.in/reader036/viewer/2022083008/56649e9e5503460f94ba09fd/html5/thumbnails/11.jpg)
What are Stubs for ?(2) Register r2 stores the system call number. Other arguments in r4,r5,r6,r7,respectly. New system call need a new stub to be added in
“start.s”. (No need to do it in this project)
![Page 12: Nachos Assignment#1 System calls implementation. What are system calls? Enable you to interact with OS kernel. A switch from User Mode to Kernel Mode](https://reader036.vdocument.in/reader036/viewer/2022083008/56649e9e5503460f94ba09fd/html5/thumbnails/12.jpg)
Implementation example: void Create(char* filename)
Crates a file with the name”filename” given as the parameter.
![Page 13: Nachos Assignment#1 System calls implementation. What are system calls? Enable you to interact with OS kernel. A switch from User Mode to Kernel Mode](https://reader036.vdocument.in/reader036/viewer/2022083008/56649e9e5503460f94ba09fd/html5/thumbnails/13.jpg)
![Page 14: Nachos Assignment#1 System calls implementation. What are system calls? Enable you to interact with OS kernel. A switch from User Mode to Kernel Mode](https://reader036.vdocument.in/reader036/viewer/2022083008/56649e9e5503460f94ba09fd/html5/thumbnails/14.jpg)
Implementation example: Add your code in exception.cc. ReadRegister -> machine.cc
To get the starting virtual address. ReadMem -> translate.cc
Translate virtual address to real address
![Page 15: Nachos Assignment#1 System calls implementation. What are system calls? Enable you to interact with OS kernel. A switch from User Mode to Kernel Mode](https://reader036.vdocument.in/reader036/viewer/2022083008/56649e9e5503460f94ba09fd/html5/thumbnails/15.jpg)
Setup your tool On your PC
Get the tar ball from our site and untar it under “/”.
Go to [Install Dir]/NachOS-4.0/coff2noff/ compile it with makefile.
On IM workstation Go to [Install Dir]/NachOS-4.0/coff2noff/ compile it with makefile.
![Page 16: Nachos Assignment#1 System calls implementation. What are system calls? Enable you to interact with OS kernel. A switch from User Mode to Kernel Mode](https://reader036.vdocument.in/reader036/viewer/2022083008/56649e9e5503460f94ba09fd/html5/thumbnails/16.jpg)
Compiling step Add the file in the “MakefileMakefile” under “
build.linux” Add the test file in the “Makefile” under
“nachos/code/test”. Complile test file under “test”,others un
der “nachos/code/build.linux”
![Page 17: Nachos Assignment#1 System calls implementation. What are system calls? Enable you to interact with OS kernel. A switch from User Mode to Kernel Mode](https://reader036.vdocument.in/reader036/viewer/2022083008/56649e9e5503460f94ba09fd/html5/thumbnails/17.jpg)
Project grading policy Primary requirement
System call implementation :70% Documentation :15% How to verify your work?:15%
Demo: About 5 groups will be chosen to
demo.
![Page 18: Nachos Assignment#1 System calls implementation. What are system calls? Enable you to interact with OS kernel. A switch from User Mode to Kernel Mode](https://reader036.vdocument.in/reader036/viewer/2022083008/56649e9e5503460f94ba09fd/html5/thumbnails/18.jpg)
Project Deadline 4/30 24:00 E-mail your project to [email protected] Use student id as file name.(one of th
e two group member) Ex:R91725050
![Page 19: Nachos Assignment#1 System calls implementation. What are system calls? Enable you to interact with OS kernel. A switch from User Mode to Kernel Mode](https://reader036.vdocument.in/reader036/viewer/2022083008/56649e9e5503460f94ba09fd/html5/thumbnails/19.jpg)
Your files SHOULD include: Modified files and test files 5 page-report
Do not put source code in your report. Explain why you chose to modify
these files. Problems encountered and your
solution Anything else.