Linux内核学习(2)-系统调用

1. 概念

系统调用是内核空间和用户空间的中间层。有如下作用:
在这里插入图片描述

  • 为用户空间程序提供一层硬件抽象接口
  • 保证系统稳定和安全
  • 可移植性

2.系统调用表

  • Linux的每一个系统调用都存在一个系统调用号,一旦分配不可更改。
  • 对于ARM32定义在arch/arm/include/uapi/asm/unistd.h文件中:
/*
 * This file contains the system call numbers.
 */

#define __NR_restart_syscall            (__NR_SYSCALL_BASE+  0)
#define __NR_exit                       (__NR_SYSCALL_BASE+  1)
#define __NR_fork                       (__NR_SYSCALL_BASE+  2)
#define __NR_read                       (__NR_SYSCALL_BASE+  3)
#define __NR_write                      (__NR_SYSCALL_BASE+  4)
#define __NR_open                       (__NR_SYSCALL_BASE+  5)
#define __NR_close                      (__NR_SYSCALL_BASE+  6)
                                        /* 7 was sys_waitpid */
#define __NR_creat                      (__NR_SYSCALL_BASE+  8)
#define __NR_link                       (__NR_SYSCALL_BASE+  9)
#define __NR_unlink                     (__NR_SYSCALL_BASE+ 10)
#define __NR_execve                     (__NR_SYSCALL_BASE+ 11)
#define __NR_chdir                      (__NR_SYSCALL_BASE+ 12)
#define __NR_time                       (__NR_SYSCALL_BASE+ 13)
#define __NR_mknod                      (__NR_SYSCALL_BASE+ 14)
#define __NR_chmod                      (__NR_SYSCALL_BASE+ 15)
#define __NR_lchown                     (__NR_SYSCALL_BASE+ 16)

3.用程序访问系统调用和新增系统调用

  • 通常应用程序不会直接访问系统调用,而是通过C标准库来访问系统调用
  • 不提倡新增系统调用,会降低可移植性,且需要在linux和glibc社区进行讨论和沟通
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值