xv6 Assignments Flashcards
1
Q
Step by step, what happens in a system call?
A
-
user.h
- Definitions of all the system calls
- Definition of other user libraries
- malloc, memset,strlen, etc..
-
syscall.h
- Here we list the system calls with the preceding SYS_
- Each SYS_<name> </name>refers to a specific number, so the kernel can identifie.
-
sysproc.c
- sys_<name> </name>, used to get the arguments given by the user and call the relevant system call implemenation.
-
syscall.c
- Here we implement an array, where index SYS_<s.c> </s.c>refers to sys_<s.c X>
- In addition, we implement the function syscall(), which gets the value of curproc->trapframe>eax, and then assigned to it the value of the call to the relevant system call.
- num = curproc->tf->eax;
if(num > 0 && num < NELEM(syscalls) && syscalls[num]) {
curproc->tf->eax = syscallsnum;
}
2
Q
What is the job of the kernel stack?
A
To hold necesarry data of the process for kernel sevices. That is, its trapframe, registers, program counter, etc.
3
Q
When we create a new process for a program by calling exec, what is allocated?
A
-
pgdir = setupkvm()
- Set up kernel part of a page table.
- Each process has kernel mappings from virtual to physical.
-
sz = allocuvm
- Allocate enough pages to load the program.
-
loaduvm
- load the program
- again allocuvm
- allocate space for user stack
- push argument string