国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

The Linux Programming Interface 02 Fundamental Concepts 基本概念

2019-11-06 09:55:06
字體:
供稿:網(wǎng)友

Fundamental Concepts

系統(tǒng)中基本概念的介紹

(01) Although it is possible to run PRograms on a computer without a kernel, the presence of a kernel greatly simplifies the writing and use of other programs, and increases the power and flexibility available to programmers.

linux可執(zhí)行內(nèi)核在/boot/vmlinuz 下面。

(02) kernel的任務

    1. Process scheduling

    2. Memory management

    3. Provision of a file system

    4. Creation and termination of process 創(chuàng)建和終止進程

    The kernel can load a new program into memory, providing it with the resources (e.g., CPU, memory, and access to files) that it needs in order to run. Such an instance of a running program is termed a process. Once a process has completed execution, the kernel ensures that the resources it uses are freed for subsequent reuse by later programs.

    5. Access to devices

    6. Networking

    7. Provision of a system call application programming interface(API)

(03) 內(nèi)核描述

By contrast, a running system has one kernel that knows and controls everything. The kernel facilities the running of all processes on the system. The kernel decides which process will next obtain access to the CPU, when it will do so, and for how long. The kernel maintains data structures containing information about all running processes and updates these structures as processes are created, change state, and terminate. The kernel also maintains data structures all of the low-level data structures that enable the filenames used by programs to be translated into physical location on the disk. The kernel also maintains data structures that map the virtual memory of each process into the physical memory of the computer and the swap area(s) on disk. All communication between processes is done via mechanisms provided by the kernel. In response to requests from processes, the kernel creates new processes and terminates existing processes. Lastly, the kernel (in particular, device drivers) performs all direct communication with input and output devices, transferring information to and from user processes as required.

(04) 目錄

A directory is a special file whose contents take the form of a table of filenames coupled with references to the corresponding files. This filename-plus-reference association is called a link.

(05) 軟鏈接

和windows下的快捷方式的那個文件有很接近的意味。

硬鏈接實際上是為文件建一個別名,鏈接文件和原文件實際上是同一個文件。可以通過ls -i來查看一下,這兩個文件的inode號是同一個,說明它們是同一個文件;而軟鏈接建立的是一個指向,即鏈接文件內(nèi)的內(nèi)容是指向原文件的指針,它們是兩個文件。

(06)相對路徑

A relative pathname specifies the location of a file relative to a process's current working directory, and is distinguished from an absolute pathname by the absence of an initial slash.

(07)文件權(quán)限,用戶被分為三種類型

For the purpose of accessing a file, the system divides users into three categories: the owner of the file (sometimes termed the user of the file), users who are members of group matching the file's group ID (group), and the rest of the world(other).

(08) 統(tǒng)一的I/O接口

The kernel translates the application's I/O requests into appropriate file-system or device-driver Operations that perform I/O on the target file or device.

(09) 文件描述符

A file descriptor is typically obtained by a call to open(), which takes a pathname argument specifying a file upon which I/O is to be performed.

To perform file I/O, C programs typically employ I/O functions contained in the standard C library. This set of functions, referred to as the stdio library, includes fopen(), fclose(), scanf(), printf(), fgets(), fputs(), and so on. The stdio functions are layered on top of the I/O system calls (open(), close(), read(), write(), and so on.

(10) 進程

When a program is executed, the kernel loads the code of program into virtual memory, allocates space for program variables, and sets up kernel bookkeeping data structures to record various information (such as process ID, termination status, user IDs, and group IDs) about the process.

A process can terminate in one of two ways: by requesting its own termination using the _exit() system call (or the related exit() library function), or by being killed the delivery of a signal. In either case, the process yields a termination status, a small nonnegative integer value that is available for inspection by the parent process using the wait() system call.

(11) 映射,主要是mmap()函數(shù)

(12) 動態(tài)庫和靜態(tài)庫

If a program is linked against a shared library, then, instead of copying object modules from the library into the executable, the linker just writes a record into the executable to indicate that at run time the executable needs to use that shared library. When the executable is loaded into memory at run time, a program called the dynamic linker ensures that the shared libraries required by the executable are found and loaded into memory.

(13)進程間通信及同步

signals, pipes, sockets, file locking, massage queues, semaphores, shared memory.

(14) 信號

For example, the kernel may send a signal to a process when one of the following occurs:

the user typed the interrupt character (usually Control-C) on the keyboard;

one of the process's children has terminated;

a timer (alarm clock) set by the process has expired; or

the process attempted to access an invalid memory address.

(15) 線程

One way of envisaging(想象) threads is as a set of processes that share the same virtual memory, as well as a range of other attributes. Each thread is executing the same program code and shares the same data area and heap. However, each thread has it own stack containing local variables and function call linkage information.

(16) sessions, Controlling Terminals, and Controlling Processes

這部分還沒有理解。

A session is a collection of process groups.

Sessions are used mainly by job-control shells.

(17) 偽終端,不理解。

時間分為系統(tǒng)時間和進程時間。

(18) Client - Server 架構(gòu)

A client-server application is one that is broken into two component processes:

a client, which asks the server to carry out some service by sending it a request message; and

a server, which examines the client's request, performs appropriate actions, and then sends a response message back to the client.

(19) proc 文件系統(tǒng)

The /proc file system is a virtual file system that provides an interface to kernel data structures in a form that looks like files and directories on a file system. This provides an easy mechanism for viewing and changing various system attributes.

(20)總結(jié)

In this chapter, we surveyed a range of fundamental concepts related to Linux system programming. An understanding of these concepts should provide readers with limited experience on Linux or UNIX with enough background to begin learning system programming.


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 固镇县| 永登县| 闽侯县| 泾川县| 小金县| 大厂| 盘锦市| 靖江市| 丹巴县| 古蔺县| 洛宁县| 且末县| 黄冈市| 辽阳市| 盘锦市| 新河县| 肃南| 凭祥市| 浏阳市| 枝江市| 兴化市| 监利县| 车致| 长泰县| 广水市| 商洛市| 崇文区| 吴江市| 成都市| 华坪县| 正宁县| 称多县| 皋兰县| 娄底市| 左云县| 日喀则市| 石棉县| 武邑县| 绩溪县| 农安县| 汽车|