10
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()

trap()

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

Page 1: trap()

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()

Page 2: trap()

2

trap vector

Page 3: trap()

3

savu retu call trap()

Page 4: trap()

4

Page 5: trap()

5

Page 6: trap()

6

sysent[ ]

countcall

countcall

countcall

countcall

Page 7: trap()

7

sysent[ ]

countcall

countcall

countcall

countcall

Page 8: trap()

8

sysent[ ]

countcall

countcall

countcall

countcall

exit() 1

fork() 2

read() 3

Page 9: trap()

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

Page 10: trap()

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