100 likes | 363 Vues
제 28 강 : trap(). trap(). Interrupt or Trap(or Exception) Assembler first HW interrupt address 0511 Assembler calls kernel C function trap() Parameters in stack 2673 (dev sp … pc ps). trap vector. savu retu call trap(). sysent[ ]. count call. count call. count call.
E N D
제28강 : trap() trap() • Interrupt or Trap(or Exception) • Assembler first • HW interrupt address • 0511 • Assembler calls kernel C function trap() • Parameters in stack • 2673 (dev sp … pc ps)
sysent[ ] count call count call count call count call
sysent[ ] count call count call count call count call
sysent[ ] count call exit() 1 count call fork() 2 count call read() 3 count call
2754 [fetch data from user space] • fuiword() asm function, (fuword() for d-space) • fetch a word from user space • This is instruction (PC) that caused trap mask it to access sysent[] • callp is pointer to sysent structure • 2762 [fetch system call arguments from user space] • 2762 for (callpcount) fuword( ) into u.u_arg[ ] • Get system call argument into u -> u.u_arg[] • (“count” is # of sys call arg) • 2770 u -> u.u_dirp = u -> u.u_arg[0] : • value of 1st argument • 2771 trap1(address of system call function) user a.out /* next is system call */ PC – 2 chmodk sys call # PC Sys call parameters /* return from sys call */ PC + 2
input argument is pointer to function • 2847 calls this function • 2848 • On normal return, u.u_intflg == 0; • If this step is not taken, u.u_intflg == 1; • (see 2845) • 2772 tests u_intflg & sets u_error • 2824 return from trap (system call) • Back to user mode