zoukankan      html  css  js  c++  java
  • linux系统调用用户态到内核态流程

    地址:https://blog.csdn.net/Agoni_xiao/article/details/79034290?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522158423522319724848343232%2522%252C%2522scm%2522%253A%252220140713.130056874..%2522%257D&request_id=158423522319724848343232&biz_id=0&utm_source=distribute.pc_search_result.none-task

    Linux系统调用流程分析
    一直很好奇系统调用的详细过程,只简单的了解系统调用是用户与内核交互的借口,看了几天的内容,不知道从何下手开始写,今天略有头绪,做以简单总结。
    1,  什么是系统调用。
    系统调用:系统调用是操作系统为用户提供的一系列API;系统调用将用户的请求发给内核,内核执行完以后,将结果返回给用户;
    2, 一个系统调用的流程。



    如上图,是系统调用write()函数的调用过程,不难看出,在用户开始调用系统调用时,触发了软中断Int0X80。到这肯定有人疑问,为什么中断号是0X80,因为代码中把系统调用跟0X80绑定在一起。
    中断向量:一个内存单元,存放中断处理程序入口地址和程序运行时所需处理机状态字。


    这里不再深入讲解向量表的生成,只需要知道每个中断都有对应的中断号并对应处理程序。
    linux的中断向量表:


    a.0X80中断号:


     /* * 我们需要下面这些内嵌语句- 从内核空间创建进程(forking)将导致没有写时复 * 制(COPY ON WRITE)!!!直到一个执行execve 调用。这对堆栈可能带来问题。处 * 理的方法是在fork()调用之后不让main()使用任何堆栈。因此就不能有函数调 * 用- 这意味着fork 也要使用内嵌的代码,否则我们在从fork()退出时就要使用堆栈了。 * * 实际上只有pause 和fork 需要使用内嵌方式,以保证从main()中不会弄乱堆栈, * 但是我们同时还定义了其它一些函数。 */ /*_syscall0 是unistd.h 中的内嵌宏代码。以嵌入汇编的形式调用Linux 的系统调用中断0x80。Linux 的系统调用中断0x80,该中断是所有系统调用的入口。syscall0 名称中最后的0 表示无参数,1 表示1 个参数。*/static _inline _syscall0(int,fork)static _inline _syscall0(int,pause)// int pause()系统调用:暂停进程的执行,直到收到一个信号。static _inline _syscall1(int,setup,void *,BIOS)// int setup(void * BIOS)系统调用,仅用于linux 初始化(仅在这个程序中被调用)。static _inline _syscall0(int,sync)// int sync()系统调用:更新文件系统。 #include <linux/tty.h>// tty 头文件,定义了有关tty_io,串行通信方面的// 参数、常数。#include <linux/sched.h>// 调度程序头文件,定义了任务结构task_struct、第1 个// 初始任务的数据。还有一些以宏的形式定义的有关描述符// 参数设置和获取的嵌入式汇编函数程序。#include <linux/head.h>// head 头文件,定义了段描述符的简单结构,// 和几个选择符常量。#include <asm/system.h>// 系统头文件。以宏的形式定义了许多有关设置或修改// 描述符/中断门等的嵌入式汇编子程序。#include <asm/io.h>// io 头文件。以宏的嵌入汇编程序形式定义对io 端// 口操作的函数。 #include <stddef.h>// 标准定义头文件。定义了NULL, offsetof(TYPE, MEMBER)。#include <stdarg.h>// 标准参数头文件。以宏的形式定义变量参数列表。主要说// 明了-个类型(va_list)和三个宏(va_start, va_arg 和// va_end),vsprintf、vprintf、vfprintf。#include <fcntl.h>// 文件控制头文件。用于文件及其描述符的操作控制常数// 符号的定义。#include <sys/types.h>// 类型头文件。定义了基本的系统数据类型。 #include <linux/fs.h>// 文件系统头文件。定义文件表结构//(file,buffer_head,m_inode 等)。 static char printbuf[1024]; extern int vsprintf();// 送格式化输出到一字符串中(在kernel/vsprintf.c)。extern void init(void);// 函数原形,初始化(在后面)。extern void blk_dev_init(void);// 块设备初始化子程序(kernel/blk_drv/ll_rw_blk.c)extern void chr_dev_init(void);// 字符设备初始化(kernel/chr_drv/tty_io.c)extern void hd_init(void);// 硬盘初始化程序(kernel/blk_drv/hd.c)extern void floppy_init(void);// 软驱初始化程序(kernel/blk_drv/floppy.c)extern void mem_init(long start, long end);// 内存管理初始化(mm/memory.c)extern long rd_init(long mem_start, int length);//虚拟盘初始化(kernel/blk_drv/ramdisk.c)extern long kernel_mktime(struct tm * tm);// 建立内核时间(秒)。extern long startup_time;// 内核启动时间(开机时间)(秒)。 /* * 以下这些数据是由setup.s 程序在引导时间设置的。 */#define EXT_MEM_K (*(unsigned short *)0x90002)// 1M 以后的扩展内存大小(KB)。#define DRIVE_INFO (*(struct drive_info *)0x90080)// 硬盘参数表基址。#define ORIG_ROOT_DEV (*(unsigned short *)0x901FC)// 根文件系统所在设备号。 /* * 是啊,是啊,下面这段程序很差劲,但我不知道如何正确地实现,而且好象 * 它还能运行。如果有关于实时时钟更多的资料,那我很感兴趣。这些都是试 * 探出来的,以及看了一些bios 程序,呵! */ // 这段宏读取CMOS 实时时钟信息。// 0x70 是写端口号,0x80|addr 是要读取的CMOS 内存地址。// 0x71 是读端口号。/*#define CMOS_READ(addr) ({ outb_p(0x80|addr,0x70); inb_p(0x71); })*/_inline unsigned char CMOS_READ(unsigned char addr){outb_p(addr,0x70);return inb_p(0x71);}

    下面是_system_call的汇编代码(asm.S):
    _system_call:cmp eax,nr_system_calls-1 ;// 调用号如果超出范围的话就在eax 中置-1 并退出。ja bad_sys_callpush ds ;// 保存原段寄存器值。push espush fspush edx ;// ebx,ecx,edx 中放着系统调用相应的C 语言函数的调用参数。push ecx ;// push %ebx,%ecx,%edx as parameterspush ebx ;// to the system callmov edx,10h ;// set up ds,es to kernel spacemov ds,dx ;// ds,es 指向内核数据段(全局描述符表中数据段描述符)。mov es,dxmov edx,17h ;// fs points to local data spacemov fs,dx ;// fs 指向局部数据段(局部描述符表中数据段描述符)。;// 下面这句操作数的含义是:调用地址 = _sys_call_table + %eax * 4。参见列表后的说明。;// 对应的C 程序中的sys_call_table 在include/linux/sys.h 中,其中定义了一个包括72 个;// 系统调用C 处理函数的地址数组表。call [_sys_call_table+eax*4]push eax ;// 把系统调用号入栈。mov eax,_current ;// 取当前任务(进程)数据结构地址??eax。;// 下面97-100 行查看当前任务的运行状态。如果不在就绪状态(state 不等于0)就去执行调度程序。;// 如果该任务在就绪状态但counter[??]值等于0,则也去执行调度程序。cmp dword ptr [state+eax],0 ;// statejne reschedulecmp dword ptr [counter+eax],0 ;// counterje rescheduleb.现场保护与恢复
    因为用户态和内核态不共用一个堆栈,所以用户态调用系统调用时,得先保存用户态的信息到寄存器,然后切入到内核态,将寄存器中的信息拷贝到内核栈开始执行,执行结束后,还原之前用户态的状态让用户态继续往下执行。
    用户态程序通过ebx,ecx,edx等寄存器,传递函数参数给系统调用,ebx,ecx,edx等寄存器通过SAVE_ALL宏压到内核栈。
    系统调用结束之后,RESTORE_ALL宏把SAVE_ALL宏压入的寄存器反向弹出,以用于恢复现场。




    c.调用系统调用表
    syscall_handler_t *sys_call_table[] = {[ __NR_restart_syscall ] = (syscall_handler_t *) sys_restart_syscall,[ __NR_exit ] = (syscall_handler_t *) sys_exit,[ __NR_fork ] = (syscall_handler_t *) sys_fork,[ __NR_read ] = (syscall_handler_t *) sys_read,[ __NR_write ] = (syscall_handler_t *) sys_write, /* These three are declared differently in asm/unistd.h */[ __NR_open ] = (syscall_handler_t *) sys_open,[ __NR_close ] = (syscall_handler_t *) sys_close,[ __NR_creat ] = (syscall_handler_t *) sys_creat,[ __NR_link ] = (syscall_handler_t *) sys_link,[ __NR_unlink ] = (syscall_handler_t *) sys_unlink,[ __NR_execve ] = (syscall_handler_t *) sys_execve, /* declared differently in kern_util.h */[ __NR_chdir ] = (syscall_handler_t *) sys_chdir,[ __NR_time ] = um_time,[ __NR_mknod ] = (syscall_handler_t *) sys_mknod,[ __NR_chmod ] = (syscall_handler_t *) sys_chmod,[ __NR_lchown ] = (syscall_handler_t *) sys_lchown16,[ __NR_lseek ] = (syscall_handler_t *) sys_lseek,[ __NR_getpid ] = (syscall_handler_t *) sys_getpid,[ __NR_mount ] = um_mount,[ __NR_setuid ] = (syscall_handler_t *) sys_setuid16,[ __NR_getuid ] = (syscall_handler_t *) sys_getuid16, [ __NR_ptrace ] = (syscall_handler_t *) sys_ptrace,[ __NR_alarm ] = (syscall_handler_t *) sys_alarm,[ __NR_pause ] = (syscall_handler_t *) sys_pause,[ __NR_utime ] = (syscall_handler_t *) sys_utime,[ __NR_access ] = (syscall_handler_t *) sys_access,[ __NR_sync ] = (syscall_handler_t *) sys_sync,[ __NR_kill ] = (syscall_handler_t *) sys_kill,[ __NR_rename ] = (syscall_handler_t *) sys_rename,[ __NR_mkdir ] = (syscall_handler_t *) sys_mkdir,[ __NR_rmdir ] = (syscall_handler_t *) sys_rmdir, /* Declared differently in asm/unistd.h */[ __NR_dup ] = (syscall_handler_t *) sys_dup,[ __NR_pipe ] = (syscall_handler_t *) sys_pipe,[ __NR_times ] = (syscall_handler_t *) sys_times,[ __NR_brk ] = (syscall_handler_t *) sys_brk,[ __NR_setgid ] = (syscall_handler_t *) sys_setgid16,[ __NR_getgid ] = (syscall_handler_t *) sys_getgid16,[ __NR_geteuid ] = (syscall_handler_t *) sys_geteuid16,[ __NR_getegid ] = (syscall_handler_t *) sys_getegid16,[ __NR_acct ] = (syscall_handler_t *) sys_acct,[ __NR_umount2 ] = (syscall_handler_t *) sys_umount,[ __NR_ioctl ] = (syscall_handler_t *) sys_ioctl,[ __NR_fcntl ] = (syscall_handler_t *) sys_fcntl,[ __NR_setpgid ] = (syscall_handler_t *) sys_setpgid,[ __NR_umask ] = (syscall_handler_t *) sys_umask,[ __NR_chroot ] = (syscall_handler_t *) sys_chroot,[ __NR_ustat ] = (syscall_handler_t *) sys_ustat,[ __NR_dup2 ] = (syscall_handler_t *) sys_dup2,[ __NR_getppid ] = (syscall_handler_t *) sys_getppid,[ __NR_getpgrp ] = (syscall_handler_t *) sys_getpgrp,[ __NR_setsid ] = (syscall_handler_t *) sys_setsid,[ __NR_setreuid ] = (syscall_handler_t *) sys_setreuid16,[ __NR_setregid ] = (syscall_handler_t *) sys_setregid16,[ __NR_sethostname ] = (syscall_handler_t *) sys_sethostname,[ __NR_setrlimit ] = (syscall_handler_t *) sys_setrlimit,[ __NR_getrlimit ] = (syscall_handler_t *) sys_old_getrlimit,[ __NR_getrusage ] = (syscall_handler_t *) sys_getrusage,[ __NR_gettimeofday ] = (syscall_handler_t *) sys_gettimeofday,[ __NR_settimeofday ] = (syscall_handler_t *) sys_settimeofday,[ __NR_getgroups ] = (syscall_handler_t *) sys_getgroups16,[ __NR_setgroups ] = (syscall_handler_t *) sys_setgroups16,[ __NR_symlink ] = (syscall_handler_t *) sys_symlink,[ __NR_readlink ] = (syscall_handler_t *) sys_readlink,[ __NR_uselib ] = (syscall_handler_t *) sys_uselib,[ __NR_swapon ] = (syscall_handler_t *) sys_swapon,[ __NR_reboot ] = (syscall_handler_t *) sys_reboot,[ __NR_munmap ] = (syscall_handler_t *) sys_munmap,[ __NR_truncate ] = (syscall_handler_t *) sys_truncate,[ __NR_ftruncate ] = (syscall_handler_t *) sys_ftruncate,[ __NR_fchmod ] = (syscall_handler_t *) sys_fchmod,[ __NR_fchown ] = (syscall_handler_t *) sys_fchown16,[ __NR_getpriority ] = (syscall_handler_t *) sys_getpriority,[ __NR_setpriority ] = (syscall_handler_t *) sys_setpriority,[ __NR_statfs ] = (syscall_handler_t *) sys_statfs,[ __NR_fstatfs ] = (syscall_handler_t *) sys_fstatfs,[ __NR_ioperm ] = (syscall_handler_t *) sys_ni_syscall,[ __NR_syslog ] = (syscall_handler_t *) sys_syslog,[ __NR_setitimer ] = (syscall_handler_t *) sys_setitimer,[ __NR_getitimer ] = (syscall_handler_t *) sys_getitimer,[ __NR_stat ] = (syscall_handler_t *) sys_newstat,[ __NR_lstat ] = (syscall_handler_t *) sys_newlstat,[ __NR_fstat ] = (syscall_handler_t *) sys_newfstat,[ __NR_vhangup ] = (syscall_handler_t *) sys_vhangup,[ __NR_wait4 ] = (syscall_handler_t *) sys_wait4,[ __NR_swapoff ] = (syscall_handler_t *) sys_swapoff,[ __NR_sysinfo ] = (syscall_handler_t *) sys_sysinfo,[ __NR_fsync ] = (syscall_handler_t *) sys_fsync,[ __NR_clone ] = (syscall_handler_t *) sys_clone,[ __NR_setdomainname ] = (syscall_handler_t *) sys_setdomainname,[ __NR_uname ] = (syscall_handler_t *) sys_newuname,[ __NR_adjtimex ] = (syscall_handler_t *) sys_adjtimex,[ __NR_mprotect ] = (syscall_handler_t *) sys_mprotect,[ __NR_create_module ] = (syscall_handler_t *) sys_ni_syscall,[ __NR_init_module ] = (syscall_handler_t *) sys_init_module,[ __NR_delete_module ] = (syscall_handler_t *) sys_delete_module,[ __NR_get_kernel_syms ] = (syscall_handler_t *) sys_ni_syscall,[ __NR_quotactl ] = (syscall_handler_t *) sys_quotactl,[ __NR_getpgid ] = (syscall_handler_t *) sys_getpgid,[ __NR_fchdir ] = (syscall_handler_t *) sys_fchdir,[ __NR_sysfs ] = (syscall_handler_t *) sys_sysfs,[ __NR_personality ] = (syscall_handler_t *) sys_personality,[ __NR_afs_syscall ] = (syscall_handler_t *) sys_ni_syscall,[ __NR_setfsuid ] = (syscall_handler_t *) sys_setfsuid16,[ __NR_setfsgid ] = (syscall_handler_t *) sys_setfsgid16,[ __NR_getdents ] = (syscall_handler_t *) sys_getdents,[ __NR_flock ] = (syscall_handler_t *) sys_flock,[ __NR_msync ] = (syscall_handler_t *) sys_msync,[ __NR_readv ] = (syscall_handler_t *) sys_readv,[ __NR_writev ] = (syscall_handler_t *) sys_writev,[ __NR_getsid ] = (syscall_handler_t *) sys_getsid,[ __NR_fdatasync ] = (syscall_handler_t *) sys_fdatasync,[ __NR__sysctl ] = (syscall_handler_t *) sys_sysctl,[ __NR_mlock ] = (syscall_handler_t *) sys_mlock,[ __NR_munlock ] = (syscall_handler_t *) sys_munlock,[ __NR_mlockall ] = (syscall_handler_t *) sys_mlockall,[ __NR_munlockall ] = (syscall_handler_t *) sys_munlockall,[ __NR_sched_setparam ] = (syscall_handler_t *) sys_sched_setparam,[ __NR_sched_getparam ] = (syscall_handler_t *) sys_sched_getparam,[ __NR_sched_setscheduler ] = (syscall_handler_t *) sys_sched_setscheduler,[ __NR_sched_getscheduler ] = (syscall_handler_t *) sys_sched_getscheduler,[ __NR_sched_yield ] = (syscall_handler_t *) yield,[ __NR_sched_get_priority_max ] = (syscall_handler_t *) sys_sched_get_priority_max,[ __NR_sched_get_priority_min ] = (syscall_handler_t *) sys_sched_get_priority_min,[ __NR_sched_rr_get_interval ] = (syscall_handler_t *) sys_sched_rr_get_interval,[ __NR_nanosleep ] = (syscall_handler_t *) sys_nanosleep,[ __NR_mremap ] = (syscall_handler_t *) sys_mremap,[ __NR_setresuid ] = (syscall_handler_t *) sys_setresuid16,[ __NR_getresuid ] = (syscall_handler_t *) sys_getresuid16,[ __NR_query_module ] = (syscall_handler_t *) sys_ni_syscall,[ __NR_poll ] = (syscall_handler_t *) sys_poll,[ __NR_nfsservctl ] = (syscall_handler_t *) NFSSERVCTL,[ __NR_setresgid ] = (syscall_handler_t *) sys_setresgid16,[ __NR_getresgid ] = (syscall_handler_t *) sys_getresgid16,[ __NR_prctl ] = (syscall_handler_t *) sys_prctl,[ __NR_rt_sigreturn ] = (syscall_handler_t *) sys_rt_sigreturn,[ __NR_rt_sigaction ] = (syscall_handler_t *) sys_rt_sigaction,[ __NR_rt_sigprocmask ] = (syscall_handler_t *) sys_rt_sigprocmask,[ __NR_rt_sigpending ] = (syscall_handler_t *) sys_rt_sigpending,[ __NR_rt_sigtimedwait ] = (syscall_handler_t *) sys_rt_sigtimedwait,[ __NR_rt_sigqueueinfo ] = (syscall_handler_t *) sys_rt_sigqueueinfo,[ __NR_rt_sigsuspend ] = (syscall_handler_t *) sys_rt_sigsuspend,[ __NR_pread64 ] = (syscall_handler_t *) sys_pread64,[ __NR_pwrite64 ] = (syscall_handler_t *) sys_pwrite64,[ __NR_chown ] = (syscall_handler_t *) sys_chown16,[ __NR_getcwd ] = (syscall_handler_t *) sys_getcwd,[ __NR_capget ] = (syscall_handler_t *) sys_capget,[ __NR_capset ] = (syscall_handler_t *) sys_capset,[ __NR_sigaltstack ] = (syscall_handler_t *) sys_sigaltstack,[ __NR_sendfile ] = (syscall_handler_t *) sys_sendfile,[ __NR_getpmsg ] = (syscall_handler_t *) sys_ni_syscall,[ __NR_putpmsg ] = (syscall_handler_t *) sys_ni_syscall,[ __NR_vfork ] = (syscall_handler_t *) sys_vfork,[ __NR_getdents64 ] = (syscall_handler_t *) sys_getdents64,[ __NR_gettid ] = (syscall_handler_t *) sys_gettid,[ __NR_readahead ] = (syscall_handler_t *) sys_readahead,[ __NR_setxattr ] = (syscall_handler_t *) sys_setxattr,[ __NR_lsetxattr ] = (syscall_handler_t *) sys_lsetxattr,[ __NR_fsetxattr ] = (syscall_handler_t *) sys_fsetxattr,[ __NR_getxattr ] = (syscall_handler_t *) sys_getxattr,[ __NR_lgetxattr ] = (syscall_handler_t *) sys_lgetxattr,[ __NR_fgetxattr ] = (syscall_handler_t *) sys_fgetxattr,[ __NR_listxattr ] = (syscall_handler_t *) sys_listxattr,[ __NR_llistxattr ] = (syscall_handler_t *) sys_llistxattr,[ __NR_flistxattr ] = (syscall_handler_t *) sys_flistxattr,[ __NR_removexattr ] = (syscall_handler_t *) sys_removexattr,[ __NR_lremovexattr ] = (syscall_handler_t *) sys_lremovexattr,[ __NR_fremovexattr ] = (syscall_handler_t *) sys_fremovexattr,[ __NR_tkill ] = (syscall_handler_t *) sys_tkill,[ __NR_futex ] = (syscall_handler_t *) sys_futex,[ __NR_sched_setaffinity ] = (syscall_handler_t *) sys_sched_setaffinity,[ __NR_sched_getaffinity ] = (syscall_handler_t *) sys_sched_getaffinity,[ __NR_io_setup ] = (syscall_handler_t *) sys_io_setup,[ __NR_io_destroy ] = (syscall_handler_t *) sys_io_destroy,[ __NR_io_getevents ] = (syscall_handler_t *) sys_io_getevents,[ __NR_io_submit ] = (syscall_handler_t *) sys_io_submit,[ __NR_io_cancel ] = (syscall_handler_t *) sys_io_cancel,[ __NR_exit_group ] = (syscall_handler_t *) sys_exit_group,[ __NR_lookup_dcookie ] = (syscall_handler_t *) sys_lookup_dcookie,[ __NR_epoll_create ] = (syscall_handler_t *) sys_epoll_create,[ __NR_epoll_ctl ] = (syscall_handler_t *) sys_epoll_ctl,[ __NR_epoll_wait ] = (syscall_handler_t *) sys_epoll_wait,        [ __NR_set_tid_address ] = (syscall_handler_t *) sys_set_tid_address,[ __NR_timer_create ] = (syscall_handler_t *) sys_timer_create,[ __NR_timer_settime ] = (syscall_handler_t *) sys_timer_settime,[ __NR_timer_gettime ] = (syscall_handler_t *) sys_timer_gettime,[ __NR_timer_getoverrun ] = (syscall_handler_t *) sys_timer_getoverrun,[ __NR_timer_delete ] = (syscall_handler_t *) sys_timer_delete,[ __NR_clock_settime ] = (syscall_handler_t *) sys_clock_settime,[ __NR_clock_gettime ] = (syscall_handler_t *) sys_clock_gettime,[ __NR_clock_getres ] = (syscall_handler_t *) sys_clock_getres,[ __NR_clock_nanosleep ] = (syscall_handler_t *) sys_clock_nanosleep,[ __NR_statfs64 ] = (syscall_handler_t *) sys_statfs64,[ __NR_fstatfs64 ] = (syscall_handler_t *) sys_fstatfs64,[ __NR_tgkill ] = (syscall_handler_t *) sys_tgkill,[ __NR_utimes ] = (syscall_handler_t *) sys_utimes,[ __NR_fadvise64_64 ] = (syscall_handler_t *) sys_fadvise64_64,[ __NR_vserver ] = (syscall_handler_t *) sys_vserver,[ __NR_mbind ] = (syscall_handler_t *) sys_mbind,[ __NR_get_mempolicy ] = (syscall_handler_t *) sys_get_mempolicy,[ __NR_set_mempolicy ] = (syscall_handler_t *) sys_set_mempolicy,[ __NR_mq_open ] = (syscall_handler_t *) sys_mq_open,[ __NR_mq_unlink ] = (syscall_handler_t *) sys_mq_unlink,[ __NR_mq_timedsend ] = (syscall_handler_t *) sys_mq_timedsend,[ __NR_mq_timedreceive ] = (syscall_handler_t *) sys_mq_timedreceive,[ __NR_mq_notify ] = (syscall_handler_t *) sys_mq_notify,[ __NR_mq_getsetattr ] = (syscall_handler_t *) sys_mq_getsetattr,[ __NR_sys_kexec_load ] = (syscall_handler_t *) sys_ni_syscall,[ __NR_waitid ] = (syscall_handler_t *) sys_waitid,[ 285 ] = (syscall_handler_t *) sys_ni_syscall,[ __NR_add_key ] = (syscall_handler_t *) sys_add_key,[ __NR_request_key ] = (syscall_handler_t *) sys_request_key,[ __NR_keyctl ] = (syscall_handler_t *) sys_keyctl, ARCH_SYSCALLS[ LAST_SYSCALL + 1 ... NR_syscalls ] =         (syscall_handler_t *) sys_ni_syscall};从这里会跳转到具体的系统调用。
    每个系统调用对应一个调用号(unistd.h)
    #ifndef _ALPHA_UNISTD_H#define _ALPHA_UNISTD_H #define __NR_osf_syscall  0/* not implemented */#define __NR_exit  1#define __NR_fork  2#define __NR_read  3#define __NR_write  4#define __NR_osf_old_open  5/* not implemented */#define __NR_close  6#define __NR_osf_wait4  7#define __NR_osf_old_creat  8/* not implemented */#define __NR_link  9#define __NR_unlink 10#define __NR_osf_execve 11/* not implemented */#define __NR_chdir 12#define __NR_fchdir 13#define __NR_mknod 14#define __NR_chmod 15#define __NR_chown 16#define __NR_brk 17#define __NR_osf_getfsstat 18/* not implemented */#define __NR_lseek 19#define __NR_getxpid 20#define __NR_osf_mount 21#define __NR_umount 22#define __NR_setuid 23#define __NR_getxuid 24#define __NR_exec_with_loader 25/* not implemented */#define __NR_ptrace 26#define __NR_osf_nrecvmsg 27/* not implemented */#define __NR_osf_nsendmsg 28/* not implemented */#define __NR_osf_nrecvfrom 29/* not implemented */#define __NR_osf_naccept 30/* not implemented */#define __NR_osf_ngetpeername 31/* not implemented */#define __NR_osf_ngetsockname 32/* not implemented */#define __NR_access 33#define __NR_osf_chflags 34/* not implemented */#define __NR_osf_fchflags 35/* not implemented */#define __NR_sync 36#define __NR_kill 37#define __NR_osf_old_stat 38/* not implemented */#define __NR_setpgid 39#define __NR_osf_old_lstat 40/* not implemented */#define __NR_dup 41#define __NR_pipe 42#define __NR_osf_set_program_attributes43#define __NR_osf_profil 44/* not implemented */#define __NR_open 45#define __NR_osf_old_sigaction 46/* not implemented */#define __NR_getxgid 47#define __NR_osf_sigprocmask 48#define __NR_osf_getlogin 49/* not implemented */#define __NR_osf_setlogin 50/* not implemented */#define __NR_acct 51#define __NR_sigpending 52 #define __NR_ioctl 54#define __NR_osf_reboot 55/* not implemented */#define __NR_osf_revoke 56/* not implemented */#define __NR_symlink 57#define __NR_readlink 58#define __NR_execve 59#define __NR_umask 60#define __NR_chroot 61#define __NR_osf_old_fstat 62/* not implemented */#define __NR_getpgrp 63#define __NR_getpagesize 64#define __NR_osf_mremap 65/* not implemented */#define __NR_vfork 66#define __NR_stat 67#define __NR_lstat 68#define __NR_osf_sbrk 69/* not implemented */#define __NR_osf_sstk 70/* not implemented */#define __NR_mmap 71/* OSF/1 mmap is superset of Linux */#define __NR_osf_old_vadvise 72/* not implemented */#define __NR_munmap 73#define __NR_mprotect 74#define __NR_madvise 75#define __NR_vhangup 76#define __NR_osf_kmodcall 77/* not implemented */#define __NR_osf_mincore 78/* not implemented */#define __NR_getgroups 79#define __NR_setgroups 80#define __NR_osf_old_getpgrp 81/* not implemented */#define __NR_setpgrp 82/* BSD alias for setpgid */#define __NR_osf_setitimer 83#define __NR_osf_old_wait 84/* not implemented */#define __NR_osf_table 85/* not implemented */#define __NR_osf_getitimer 86#define __NR_gethostname 87#define __NR_sethostname 88#define __NR_getdtablesize 89#define __NR_dup2 90#define __NR_fstat 91#define __NR_fcntl 92#define __NR_osf_select 93#define __NR_poll 94#define __NR_fsync 95#define __NR_setpriority 96#define __NR_socket 97#define __NR_connect 98#define __NR_accept 99#define __NR_getpriority100..........————————————————版权声明:本文为CSDN博主「Agoni_xiao」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。原文链接:https://blog.csdn.net/Agoni_xiao/article/details/79034290

    Always Believe Something Beauitful Will Be Happen
  • 相关阅读:
    java 调用Python
    RestController 能不能通过配置关闭
    java jdb
    Curator zookeeper
    「ASCII 流程图」工具——Graph Easy
    Python String Formatting Best Practices
    idea java9以及以上 出现找不到class的情况
    时间序列分析 异常分析 stl
    pip install whl
    t-SNE 层次聚类
  • 原文地址:https://www.cnblogs.com/Oude/p/12496022.html
Copyright © 2011-2022 走看看