Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- So, we look for the close function at usys.S where all system calls are defined.
- We look at the function 'name': where name is replaced by the function name, in this case 'close'. and later the value corresponding to SYS_name in this case SYS_close is assign to %eax (7 for this case as we can see defined in syscall.h).
- Now that the arguments have been set, we can initiate the system call.
- So, now it's done after int $T_SYSCALL so we go to another file where the interrupt to the system call happens (vectors.S:318) so first it pushes the type of interrupt (64) and then goes to alltraps.
- Now, at trapasm.S we go to alltraps. First it builds the trap frame for the format of type tf, then, it sets up the data and the per-cpu segments and then finally it calls trap in (trap.c) with argument %esp as *tf.
- Now, we moved to trap.c:35 where we the function trap(struct trapframe *tf) is executed, as we going in there we stop at the first condition where is checking if its a system call.
- Inside the condition checks if the proc is finished but (supposedly it's not suppose to be closed) but if so then it will exit the method.
- Now it links the argument variable to the frame and makes the syscall().
- Now, at syscall.c:127 (where the syscall method is) we get the %eax value (the system call id, which should be 7) the assigns eax the returning value of the function at syscalls[num](), which is the same as sys_close().
- Then back at trap()@trap.c we finish the method and we're back at the assembly part at trapasm.S where we do addl $4, %esp where esp has the result of trap which is sys_close.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement