Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. So, we look for the close function at usys.S where all system calls are defined.
  2.  
  3. 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).
  4.  
  5. Now that the arguments have been set, we can initiate the system call.
  6.  
  7. 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.
  8.  
  9. 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.
  10.  
  11. 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.
  12.  
  13. 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.
  14.  
  15. Now it links the argument variable to the frame and makes the syscall().
  16.  
  17. 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().
  18.  
  19. 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