Upload
yael-fitzgerald
View
46
Download
1
Tags:
Embed Size (px)
DESCRIPTION
제 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. - PowerPoint PPT Presentation
Citation preview
1
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)
제 28 강 : trap()
2
trap vector
3
savu retu call trap()
4
5
6
sysent[ ]
countcall
countcall
countcall
countcall
7
sysent[ ]
countcall
countcall
countcall
countcall
8
sysent[ ]
countcall
countcall
countcall
countcall
exit() 1
fork() 2
read() 3
9
2754 [fetch data from user space]fuiword() asm function, (fuword() for d-
space) fetch a word from user spaceThis 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)
sys call #chmodk
/* next is system call */
/* return from sys call */
Sys call parameters PC + 2
PC
PC – 2
user a.out
10
input argument is pointer to function
2847 calls this function2848
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