操作系统系统调用

系统调用简介 (Introduction to System calls)

The interface between the operating system and the user program is defined by the set of extended instruction that the operating system provides. These extended instructions are known as system calls. User program communicates with the operating system and request services from if by making system calls. There exist a library procedure corresponding to each system call that the user program can call. System call allows user-level processes to required services of the operating system. This procedure put the parameter of the system call in a specified place, such as the machine registers, and then issue TRAP instructions to start the operating system. When the operating system gets control after TRAP it examines the parameters to see if they are valid and if so perform the work requested. When it is finished the operating system puts a status code in a register telling whether it succeed or failed and execute a RETURN FROM TRAP instructions to return control back to the library procedure. The library procedure then returns to the caller in the usual way, returning the status code as a function value.

操作系统和用户程序之间的接口由操作系统提供的一组扩展指令定义。 这些扩展指令称为系统调用 。 用户程序与操作系统进行通信,并通过进行系统调用来请求服务。 存在与用户程序可以调用的每个系统调用相对应的库过程。 系统调用允许用户级进程访问操作系统所需的服务。 此过程将系统调用的参数放在指定的位置(例如,机器寄存器),然后发出TRAP指令以启动操作系统。 当操作系统在TRAP之后获得控制权时,它将检查参数以查看它们是否有效,并执行所需的工作。 完成后,操作系统将状态码放入寄存器中以告知其成功还是失败,然后执行RETURN FROM TRAP指令将控制权返回给库过程。 然后,库过程以通常的方式返回到调用者,将状态码作为函数值返回。

Any operation perform in the system require the system and if any error occurs in the system it needs additional system calls for solving the errors. Suppose if any program wants to open a file and the file of that name may not exist in the system, in this case, the program print a message on the console window that the file does not exists all these things done by the system calls. System calls are callable from the assembly language. We have often encountered phrase such as “ assembly language under DOS”. We should now be clear about its meaning. The assembly language programmer needs to know the assembly language instructions set for that machine. In addition, he normally needs to aware of the system calls of the operating system running on that machine. Many high-level languages such as C and also enables the system calls to be embedded explicitly in the midst of other statements. Some high-level language such as JAVA or C++ does not need the explicit use of system calls embedded in other statements. In these scenarios the compiler substitutes system calls at specific locations.

系统中执行的任何操作都需要系统,并且如果系统中发生任何错误,则需要其他系统调用来解决错误。 假设有任何程序要打开文件,而系统中可能不存在该名称的文件,在这种情况下,该程序会在控制台窗口上打印一条消息,指出该文件不存在系统调用完成的所有操作。 可以从汇编语言调用系统调用 。 我们经常遇到诸如“ DOS下的汇编语言”之类的短语。 现在,我们应该清楚其含义。 汇编语言程序员需要知道该机器的汇编语言指令集。 另外,他通常需要知道该计算机上运行的操作系统系统调用 。 许多高级语言(例如C)还使系统调用可以显式地嵌入到其他语句中。 某些高级语言,例如JAVA或C ++,不需要显式使用嵌入在其他语句中的系统调用 。 在这些情况下,编译器在特定位置替换系统调用

The two-parameter will be substituting various sets of operations system calls for the same source's statements such a fread, fwrite or execute. Generally, the mapping between the system calls of two operating system is never straightforward. Normally before the real system calls, the compiler produces machine instructions which are preparatory instructions for that system call.

这两个参数将用操作系统调用的各种集合替换同一源的语句,例如fread,fwrite或execute。 通常,两个操作系统的系统调用之间的映射从来都不是简单的。 通常,在实际系统调用之前,编译器会生成机器指令,它们是该系统调用的准备指令。

系统调用的类型 (Types of system calls)

System calls can be grouped into five categories- process control, file management, device management, information management, and communication.

系统调用可以分为五类: 过程控制文件管理设备管理信息管理通信

1.过程控制 (1. Process control)

A process or the job which is currently run in the system always want to load and execute another program. The command interpreter executes a program for example when the user clicks on the mouse button. Now the question arises that when the loaded program terminates when the control return. When any new program terminates in the system the memory the currently running program must be saved. So in this way we can efficiently create a program which calls another program and both are running concurrently. For the multiprogramming, we have created jobs or process. So the system calls for this purpose is called create a process or submit the job. When a new job, process or the group of the process is created then we have to manage the execution of these process.

当前在系统中运行的进程或作业总是要加载并执行另一个程序。 例如,当用户单击鼠标按钮时,命令解释器将执行程序。 现在出现的问题是,当加载的程序在控件返回时终止。 当任何新程序在系统中终止时,必须保存当前正在运行的程序。 因此,通过这种方式,我们可以有效地创建一个程序,该程序调用另一个程序,并且两个程序同时运行。 对于多程序,我们创建了作业或过程。 因此,为此目的而进行的系统调用称为创建流程或提交作业。 创建新作业,流程或流程组时,我们必须管理这些流程的执行。

2.文件管理 (2. File management)

In the file management system, we should be able to create or delete the files. For creating a file the system call requires the names of the file and some attribute of the files. When the file is created we should be able to open and use these files. We can also read-write or reposition the files. After all the work is done we need to close the file which indicates that the file is no longer need. We can also use these operations for directories also. In the file management system, we should be able to determine the values of various attributes for the file and directories. There are various file attributes like name, types, size, location, accounting information and so on. The two important system calls get attribute and file set attribute is required for this function.

在文件管理系统中,我们应该能够创建或删除文件。 为了创建文件,系统调用需要文件名和文件的某些属性。 创建文件后,我们应该能够打开和使用这些文件。 我们还可以读写文件或重新放置文件。 完成所有工作后,我们需要关闭文件,这表明不再需要该文件。 我们也可以将这些操作用于目录。 在文件管理系统中,我们应该能够确定文件和目录的各种属性的值。 有各种文件属性,例如名称,类型,大小,位置,记帐信息等。 此功能需要两个重要的系统调用get属性和file set属性。

3.设备管理 (3. Device management)

When the program is running in the system it needs some resources such as memory, input, output, and so on. The resources are only granted when they are available and not held by another process. If the resources are not free the program has to wait for the resources. Files are the abstract or virtual devices. So there are many system calls which are needed for the files and also for the devices. If there are multiple users then first it requests for the devices and after finishing the work with these devices we should release it. When the devices are allocated to the user then we can perform different operations like reading, write and execute.

当程序在系统中运行时,它需要一些资源,例如内存,输入,输出等。 仅当资源可用且不由另一个进程持有时才授予资源。 如果没有释放资源,则程序必须等待资源。 文件是抽象或虚拟设备。 因此,文件和设备都需要许多系统调用。 如果有多个用户,则首先请求设备,完成这些设备的工作后,我们应该释放它。 将设备分配给用户后,我们可以执行不同的操作,例如读取,写入和执行。

4.信息管理 (4. Information management)

In information management, various system calls are used to communicate the information between the operating system and user program. For example, some system has a system call forget the current time or date. There are many another system call like for the number of the user, different versions of operating system., free space in memory etc.

在信息管理中,各种系统调用用于在操作系统和用户程序之间传递信息。 例如,某些系统有一个系统调用会忘记当前时间或日期。 还有许多其他系统调用,例如用户数量,操作系统的不同版本,内存中的可用空间等。

5.沟通 (5. Communication)

There are mainly two models for communication. First is the message passing model in this the information is exchanged between the process and this communication facility is provided by the operating system. When the process wants to communicate first the other communicator should be know so that the communication is established and they can communicate. Second is the shared memory model in this model different process shared memory and communicate with each other.

主要有两种通信模型。 首先是消息传递模型,其中信息在进程之间交换,并且该通信工具由操作系统提供。 当该过程首先要进行通信时,应该知道其他通信者,以便建立通信并可以进行通信。 其次是共享内存模型,在此模型中不同进程共享内存并相互通信。

翻译自: https://www.includehelp.com/operating-systems/system-calls-in-operating-system.aspx

操作系统系统调用

操作系统系统调用_操作系统中的系统调用相关推荐

  1. Golang标准库-syscall(什么是系统调用/Go 语言中的系统调用)

    文章目录 一.什么是系统调用 二.Golang标准库-syscall 1. syscall无处不在 2. syscall demo举例: go版本的strace Strace go版本的strace ...

  2. 【Android 逆向】Android 进程注入工具开发 ( 系统调用 | Android NDK 中的系统调用示例 )

    文章目录 一.系统调用 二.Android NDK 中的系统调用示例 一.系统调用 在 " 用户层 " , 运行的都是用户应用程序 ; 用户层 下面 是 驱动层 , 驱动层 下面是 ...

  3. java线程和操作系统线程_操作系统中的线程

    java线程和操作系统线程 线程数 (Threads) A thread is a unit of CPU utilization, which comprises the following par ...

  4. python 操作系统学习_操作系统学习

    一.操作系统 庄园主--奴隶,找一个管家来传达命令. 计算机的世界中叫做操作系统,这个管家就相当于少掉的内存. 操作系统帮我们把内容保存到硬盘,帮我们解析指令. 二.操作系统都干了什么? 接收外部指令 ...

  5. execve系统调用_进程调度之 4:系统调用execve

    date: 2014-10-24 12:09 1 用户空间的编程接口 这部分详情请参考APUE(第2版)第8章. 1.1 六种exec函数 有6种不同的exec函数可供使用,这些函数最终都是通过系统调 ...

  6. python适用的操作系统是_操作系统先来先服务python

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 #coding=utf-8 impor ...

  7. windows如何调用Linux的API,Windows和Native API中的系统调用?

    最近,我在* NIX操作系统中使用了很多汇编语言.我想知道Windows域. Linux中的调用约定: mov $SYS_Call_NUM, %eax mov $param1 , %ebx mov $ ...

  8. execve系统调用_《操作系统》知识结构

    作者:陈凌灏 单位:西安电子科技大学 注:转载请注明出处~~ 写在前面:<操作系统>这门课几乎可以说是计算机专业最重要的课程了.本文主要是在学习完这门课后,参照TANENBAUM的< ...

  9. 王道操作系统考研笔记——1.1.6 系统调用

    如果这篇博客对您有用的话,可以给我点个赞吗,这对我很重要,谢谢!❤️ 文章目录 1.1.6 系统调用 1.1.6.1 系统调用和作用 1.1.6.2 系统调用和库函数 1.1.6.3 系统调用背后的过 ...

最新文章

  1. 自动驾驶车辆在结构化场景中基于HD-Map由粗到精语义定位
  2. 什么是URL?协议头,路径和端口是什么意思?
  3. apk可以解压再复制到手机吗_不行了,这个打通手机和电脑的神器,必须得安利给你们...
  4. SAP Spartacus AuthService.getUserToken的实现
  5. Spring集成和Web服务
  6. 北大师兄告诉你,怎样顺利完成自己的博士生涯
  7. 第二十九篇、UICollectionView瀑布流
  8. 数论入门符号_大o符号快速入门
  9. libyuv的编译使用
  10. 调试笔记:BSOD 0xA
  11. jwplayer 初始化设置项
  12. 1000以内的素数(质数)
  13. mac php fpm.pid,php-fpm的常用配置和优化
  14. 高分辨透射电镜(HRTEM)样品怎么制?看这一篇就够了
  15. Ubuntu编辑文档和查看文档
  16. Artifactory的搭建与使用简介
  17. sqli-labs 1~4 多命通关攻略
  18. nyoj-1273 宣传墙
  19. 戴尔电脑如何设置快速开机
  20. 《大学“电路分析基础”课程实验合集.实验五》丨线性有源二端网络等效电路的研究

热门文章

  1. 计算机设置从u盘启动怎么办,电脑设置从u盘启动盘启动出现蓝屏该怎么解决?
  2. Python 装饰器详解(上)
  3. php sql取数据生成数组中,php中实现数组生成要执行的sql语句
  4. mysql实体监听器_GitHub - langjiangit/spring-boot-starter-mysql-binlog: mysql的binlog监听器
  5. linux数据库实例开机启动,linux下数据库实例开机自启动设置
  6. Python-import导入上级 本级 目录文件
  7. bash --config command not found 报错
  8. shell自动化巡检
  9. POJ3984 迷宫问题【BFS】
  10. javaSE知识点汇总