1 / 29
文档名称:

Linux实用教程 linux系统调用.ppt

格式:ppt   页数:29页
下载后只包含 1 个 PPT 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

Linux实用教程 linux系统调用.ppt

上传人:wzt520728 2016/1/2 文件大小:0 KB

下载得到文件列表

Linux实用教程 linux系统调用.ppt

相关文档

文档介绍

文档介绍:中英文日报导航站——Linux内核指导Chapter 5: 系统调用n为什么需要系统调用n相关数据和代码n例:系统调用getuid()的实现n添加一个系统调用mysyscalln再实现一个稍复杂的系统调用中英文日报导航站——Linux内核指导为什么需要系统调用(1)中英文日报导航站——Linux内核指导为什么需要系统调用(2)中英文日报导航站——Linux内核指导相关数据和代码narch/i386/kernel/arch/i386/kernel/ glibc展开系统调用INLINE_SYSCALL(getuid, 0);中英文日报导航站——Linux内核指导系统调用时的内核栈用户空间ss用户空间espEFLAGS用户空间cs用户空间eip系统调用号可用空间可用空间eip函数返回地址局部变量用户栈内核栈中断后(SAVE_ALL前)及iret前(RESTORE_ALL后)的esp内核ss向外返回向内中断中断前及iret(系统调用返回)后的esp用户sstask_struct陷入内核时,系统自动从当前进程的TSS(任务状态段)中获得内核栈的SS和ESP,并完成栈切换中英文日报导航站——Linux内核指导系统调用时的内核栈18* Stack layout in 'ret_from_system_call':19* ptrace needs to have all regs on the * if the order here is changed, it needs to be21* updated in :copy_process, :do_signal,22* and *24* 0(%esp) - %ebx25* 4(%esp) - %ecx26* 8(%esp) - %edx27* C(%esp) - %esi28* 10(%esp) - %edi29* 14(%esp) - %ebp30* 18(%esp) - %eax31* 1C(%esp) - %ds32* 20(%esp) - %es33* 24(%esp) - orig_eax34* 28(%esp) - %eip35* 2C(%esp) - %cs36* 30(%esp) - %eflags37* 34(%esp) - %oldesp38* 38(%esp) - %oldss39*40* "current" is in register %ebx during any slow ——Linux内核指导系统调用时的内核栈#define SAVE_ALL \cld; \pushl %es; \pushl %ds; \pushl %eax; \pushl %ebp; \pushl %edi; \pushl %esi; \pushl %edx; \pushl %ecx; \pushl %ebx; \movl $(__KERNEL_DS),%edx; \movl %edx,%ds; \movl %edx,%es;中英文日报导航站——Linux内核指导系统调用时的内核栈#define RESTORE_ALL\popl %ebx;\popl %ecx;\popl %edx;\popl %esi;\popl %edi;\popl %ebp;\popl %eax;\1:popl %ds;\2:popl %es;\addl $4,%esp;\3:iret;\中英文日报导航站——Linux内核指导sys_call_table398 ENTRY(sys_call_table)399 .long SYMBOL_NAME(sys_ni_syscall) 400 .long SYMBOL_NAME(sys_exit)401 .long SYMBOL_NAME(sys_fork)402 .long SYMBOL_NAME(sys_read)403 .long SYMBOL_NAME(sys_write)404 .long SYMBOL_NAME(sys_open) /*