操作系统系统调用_操作系统中的系统调用
操作系統(tǒng)系統(tǒng)調(diào)用
系統(tǒng)調(diào)用簡(jiǎn)介 (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.
操作系統(tǒng)和用戶(hù)程序之間的接口由操作系統(tǒng)提供的一組擴(kuò)展指令定義。 這些擴(kuò)展指令稱(chēng)為系統(tǒng)調(diào)用 。 用戶(hù)程序與操作系統(tǒng)進(jìn)行通信,并通過(guò)進(jìn)行系統(tǒng)調(diào)用來(lái)請(qǐng)求服務(wù)。 存在與用戶(hù)程序可以調(diào)用的每個(gè)系統(tǒng)調(diào)用相對(duì)應(yīng)的庫(kù)過(guò)程。 系統(tǒng)調(diào)用允許用戶(hù)級(jí)進(jìn)程訪問(wèn)操作系統(tǒng)所需的服務(wù)。 此過(guò)程將系統(tǒng)調(diào)用的參數(shù)放在指定的位置(例如,機(jī)器寄存器),然后發(fā)出TRAP指令以啟動(dòng)操作系統(tǒng)。 當(dāng)操作系統(tǒng)在TRAP之后獲得控制權(quán)時(shí),它將檢查參數(shù)以查看它們是否有效,并執(zhí)行所需的工作。 完成后,操作系統(tǒng)將狀態(tài)碼放入寄存器中以告知其成功還是失敗,然后執(zhí)行RETURN FROM TRAP指令將控制權(quán)返回給庫(kù)過(guò)程。 然后,庫(kù)過(guò)程以通常的方式返回到調(diào)用者,將狀態(tài)碼作為函數(shù)值返回。
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.
系統(tǒng)中執(zhí)行的任何操作都需要系統(tǒng),并且如果系統(tǒng)中發(fā)生任何錯(cuò)誤,則需要其他系統(tǒng)調(diào)用來(lái)解決錯(cuò)誤。 假設(shè)有任何程序要打開(kāi)文件,而系統(tǒng)中可能不存在該名稱(chēng)的文件,在這種情況下,該程序會(huì)在控制臺(tái)窗口上打印一條消息,指出該文件不存在系統(tǒng)調(diào)用完成的所有操作。 可以從匯編語(yǔ)言調(diào)用系統(tǒng)調(diào)用 。 我們經(jīng)常遇到諸如“ DOS下的匯編語(yǔ)言”之類(lèi)的短語(yǔ)。 現(xiàn)在,我們應(yīng)該清楚其含義。 匯編語(yǔ)言程序員需要知道該機(jī)器的匯編語(yǔ)言指令集。 另外,他通常需要知道該計(jì)算機(jī)上運(yùn)行的操作系統(tǒng)的系統(tǒng)調(diào)用 。 許多高級(jí)語(yǔ)言(例如C)還使系統(tǒng)調(diào)用可以顯式地嵌入到其他語(yǔ)句中。 某些高級(jí)語(yǔ)言,例如JAVA或C ++,不需要顯式使用嵌入在其他語(yǔ)句中的系統(tǒng)調(diào)用 。 在這些情況下,編譯器將在特定位置替換系統(tǒng)調(diào)用 。
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.
這兩個(gè)參數(shù)將用操作系統(tǒng)調(diào)用的各種集合替換同一源的語(yǔ)句,例如fread,fwrite或execute。 通常,兩個(gè)操作系統(tǒng)的系統(tǒng)調(diào)用之間的映射從來(lái)都不是簡(jiǎn)單的。 通常,在實(shí)際系統(tǒng)調(diào)用之前,編譯器會(huì)生成機(jī)器指令,它們是該系統(tǒng)調(diào)用的準(zhǔn)備指令。
.minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}} .minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}}系統(tǒng)調(diào)用的類(lèi)型 (Types of system calls)
System calls can be grouped into five categories- process control, file management, device management, information management, and communication.
系統(tǒng)調(diào)用可以分為五類(lèi): 過(guò)程控制 , 文件管理 , 設(shè)備管理 , 信息管理和通信 。
1.過(guò)程控制 (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.
當(dāng)前在系統(tǒng)中運(yùn)行的進(jìn)程或作業(yè)總是要加載并執(zhí)行另一個(gè)程序。 例如,當(dāng)用戶(hù)單擊鼠標(biāo)按鈕時(shí),命令解釋器將執(zhí)行程序。 現(xiàn)在出現(xiàn)的問(wèn)題是,當(dāng)加載的程序在控件返回時(shí)終止。 當(dāng)任何新程序在系統(tǒng)中終止時(shí),必須保存當(dāng)前正在運(yùn)行的程序。 因此,通過(guò)這種方式,我們可以有效地創(chuàng)建一個(gè)程序,該程序調(diào)用另一個(gè)程序,并且兩個(gè)程序同時(shí)運(yùn)行。 對(duì)于多程序,我們創(chuàng)建了作業(yè)或過(guò)程。 因此,為此目的而進(jìn)行的系統(tǒng)調(diào)用稱(chēng)為創(chuàng)建流程或提交作業(yè)。 創(chuàng)建新作業(yè),流程或流程組時(shí),我們必須管理這些流程的執(zhí)行。
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.
在文件管理系統(tǒng)中,我們應(yīng)該能夠創(chuàng)建或刪除文件。 為了創(chuàng)建文件,系統(tǒng)調(diào)用需要文件名和文件的某些屬性。 創(chuàng)建文件后,我們應(yīng)該能夠打開(kāi)和使用這些文件。 我們還可以讀寫(xiě)文件或重新放置文件。 完成所有工作后,我們需要關(guān)閉文件,這表明不再需要該文件。 我們也可以將這些操作用于目錄。 在文件管理系統(tǒng)中,我們應(yīng)該能夠確定文件和目錄的各種屬性的值。 有各種文件屬性,例如名稱(chēng),類(lèi)型,大小,位置,記帳信息等。 此功能需要兩個(gè)重要的系統(tǒng)調(diào)用get屬性和file set屬性。
3.設(shè)備管理 (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.
當(dāng)程序在系統(tǒng)中運(yùn)行時(shí),它需要一些資源,例如內(nèi)存,輸入,輸出等。 僅當(dāng)資源可用且不由另一個(gè)進(jìn)程持有時(shí)才授予資源。 如果沒(méi)有釋放資源,則程序必須等待資源。 文件是抽象或虛擬設(shè)備。 因此,文件和設(shè)備都需要許多系統(tǒng)調(diào)用。 如果有多個(gè)用戶(hù),則首先請(qǐng)求設(shè)備,完成這些設(shè)備的工作后,我們應(yīng)該釋放它。 將設(shè)備分配給用戶(hù)后,我們可以執(zhí)行不同的操作,例如讀取,寫(xiě)入和執(zhí)行。
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.
在信息管理中,各種系統(tǒng)調(diào)用用于在操作系統(tǒng)和用戶(hù)程序之間傳遞信息。 例如,某些系統(tǒng)有一個(gè)系統(tǒng)調(diào)用會(huì)忘記當(dāng)前時(shí)間或日期。 還有許多其他系統(tǒng)調(diào)用,例如用戶(hù)數(shù)量,操作系統(tǒng)的不同版本,內(nèi)存中的可用空間等。
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.
主要有兩種通信模型。 首先是消息傳遞模型,其中信息在進(jìn)程之間交換,并且該通信工具由操作系統(tǒng)提供。 當(dāng)該過(guò)程首先要進(jìn)行通信時(shí),應(yīng)該知道其他通信者,以便建立通信并可以進(jìn)行通信。 其次是共享內(nèi)存模型,在此模型中不同進(jìn)程共享內(nèi)存并相互通信。
翻譯自: https://www.includehelp.com/operating-systems/system-calls-in-operating-system.aspx
操作系統(tǒng)系統(tǒng)調(diào)用
總結(jié)
以上是生活随笔為你收集整理的操作系统系统调用_操作系统中的系统调用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: [转载] Python新手写出漂亮的爬虫
- 下一篇: java信息管理系统总结_java实现科