Information Technology Reference
In-Depth Information
Kernel
User Program
main () {
...
syscall(arg1, arg2);
...
}
syscall(arg1, arg2) {
do operation
}
(4)
(1)
(3)
(6)
Kernel Stub
User Stub
(2)
handler() {
copy arguments
from user memory
check arguments
syscall(arg1, arg2);
copy return value
into user memory
return
}
syscall (arg1, arg2) {
trap
return
}
Hardware Trap
Trap Return
(5)
Figure2.12: Stubs mediate between the user-level caller and the kernel im-
plementation of system calls.
open:
//weassumethecallerputthefilenameontothestackalready,
//accordingtothestandardcallingconventionforthex86
movl#SysCall_Open,%eax //tellthekernelwhichsystemcallroutinewewant
int32 //trapintothekernel
ret
//returnbacktocaller,assumeskernelleftreturnvaluein%eax
Figure2.13: User level library stub to invoke the file system open system call.
 
Search WWH ::




Custom Search