C/C++教程

系统调用SystemCalls-1-总述

本文主要是介绍系统调用SystemCalls-1-总述,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

(Owed by: 春夜喜雨 http://blog.csdn.net/chunyexiyu)
参考:https://en.wikipedia.org/wiki/System_call

总述内容主要来自于wikepedia中的介绍,主要回答三个问题:

  1. 什么是系统调用?
  2. 系统调用的数目有多少?
  3. 系统调用函数的通常分类是什么?

关于系统调用

计算机中系统调用,指计算机程序执行时请求操作系统内核提供的服务。调用通常可能涉及硬件相关服务(例如涉及硬盘驱动)、或创建和执行一个新进程、或与基础内核服务通信(比如进程调度)。系统调用在进程与操作系统之间提供了一个必要的接口。
在大多数系统中,系统调用仅在用户空间进程中使用;但在一些系统如IBM的OS/360和它的继承者系统中,特权系统代码也启用了系统调用。

from wikepdia ---
In computing, a system call (commonly abbreviated to syscall) is the programmatic way in which a computer program requests a service from the kernel of the operating system on which it is executed. This may include hardware-related services (for example, accessing a hard disk drive), creation and execution of new processes, and communication with integral kernel services such as process scheduling. System calls provide an essential interface between a process and the operating system.
In most systems, system calls can only be made from userspace processes, while in some systems, OS/360 and successors for example, privileged system code also issues system calls.

系统调用数量

在Unix、类Unix和其它POSIX兼容操作系统中,通用系统调用有open, read, write, close, wait, exec, for, exit, kill。许多现代操作系统有数百个系统调用。例如Linux和OpenBSD分别有超过300个不同的调用,NetBSD有接近500个,FreeBSD有超过500个,Win7有接近700个,而早期Plan9只有51个系统调用,MINIX只有53个系统调用。

from wikepedia ---
On Unix, Unix-like and other POSIX-compliant operating systems, popular system calls are open, read, write, close, wait, exec, fork, exit, and kill. Many modern operating systems have hundreds of system calls. For example, Linux and OpenBSD each have over 300 different calls, NetBSD has close to 500,FreeBSD has over 500,Windows 7 has close to 700, while Plan 9 has 51.

系统调用分类

在wikepedia中系统调用划分了6个大类,分别为:ProcessControl进程控制,FileManagement文件管理,DeviceManagement设备管理, InformationMaintenance信息维护,Communication通信,Protection保护 共计6个大类。

进程控制

分成6个小类

  1. create process 进程创建 (fork in unix-like os,NTCreateProcess in windows)
  2. terminal process 终止进程 (kill in unix-like os)
  3. load, execute 加载程序文件、执行程序(execve, exec in unix)
  4. get/set process attribute 获取/设置进程属性
  5. wait for time, wait event, signal event 等待时间、事件、信号
  6. allocate and free memory 分配和释放内存

文件管理

分成4个小类

  1. create file/delete file 创建/删除文件
  2. open, close 打开/关闭文件
  3. read, write, reposition 读/写/重定位
  4. get/set file attribute 获取/设置文件属性

设备管理

分成4个小类

  1. request device,release device请求设备,释放设备
  2. read, write, reposition 读/写/重定位
  3. get/set device attribute 获取/设置设备属性
  4. logically attach/detach devices 逻辑附加/去除设备

信息维护

分成2个小类

  1. get/set total system information(including time, date, computer name, enterprise etc.)获取/设置完整的系统信息。
  2. get/set process, file, or device metadata(include author, opener, creation time and date etc.) 获取/设置进程、文件、设备的元数据(描述数据的数据)。

通信

分成4个小类

  1. create, delete communication connection 创建/删除通信连接
  2. send, receive message 发送/接收信息
  3. transfer status information 转移状态信息
  4. attach/detach remote device 附加/去除远程设备

保护

1个小类:获取/设置文件权限

(Owed by: 春夜喜雨 http://blog.csdn.net/chunyexiyu)

这篇关于系统调用SystemCalls-1-总述的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!