Linux核心學習

來源:互聯網
上載者:User

1:vim csope ctags

Linux核心設計與實現

深入理解linux核心 elk

Linux裝置驅動程式

深入理解linux虛擬記憶體管理

深入理解linux網路內幕

Chapter 1. Overview

1:同步和臨界區 Synchronization and Critical Regions

2: shared memory

Shared memory provides the fastest way for processes to exchange and share data. A process starts
by issuing a shmget( ) system call to create a new shared memory having a required size. After
obtaining the IPC resource identifier, the process invokes the shmat( ) system call, which returns
the starting address of the new region within the process address space. When the process wishes to
detach the shared memory from its address space, it invokes the shmdt( ) system call. The
implementation of shared memory depends on how the kernel implements process address spaces

3:Process Management

Unix makes a neat distinction between the process and the program it is executing. To that end, the
fork( ) and _exit( ) system calls are used respectively to create a new process and to terminate it,
while an exec( )-like system call is invoked to load a new program. After such a system call is
executed, the process resumes execution with a brand new address space containing the loaded
program.

4:Zombie processes

How can a parent process inquire about termination of its children? The wait4( ) system call allows
a process to wait until one of its children terminates; it returns the process ID (PID) of the
terminated child.

The solution lies in a special system process called init, which is created during system initialization.When a process terminates, the kernel changes the appropriate process descriptor pointers of all the

existing children of the terminated process to make them become children of init. This process
monitors the execution of all its children and routinely issues wait4( ) system calls, whose side
effect is to get rid of all orphaned zombies.

5:Virtual address spaces
Virtual address spaces also allow other efficient strategies, such as the Copy On Write strategy
mentioned earlier. For example, when a new process is created, the kernel just assigns the parent's
page frames to the child address space, but marks them read-only. An exception is raised as soon
the parent or the child tries to modify the contents of a page. The exception handler assigns a new
page frame to the affected process and initializes it with the contents of the original page.

Chapter 2. Memory Addressing

  • Logical address

Included in the machine language instructions to specify the address of an operand or of an
instruction. This type of address embodies the well-known 80 x 86 segmented architecture
that forces MS-DOS and Windows programmers to divide their programs into segments . Each
logical address consists of a segment and an offset (or displacement) that denotes the distance
from the start of the segment to the actual address.

  • Linear address (also known as virtual address)

A single 32-bit unsigned integer that can be used to address up to 4 GB that is, up to
4,294,967,296 memory cells. Linear addresses are usually represented in hexadecimal
notation; their values range from 0x00000000 to 0xffffffff.

  • Physical address

Used to address memory cells in memory chips. They correspond to the electrical signals sent
along the address pins of the microprocessor to the memory bus. Physical addresses are
represented as 32-bit or 36-bit unsigned integers.

The Memory Management Unit (MMU) transforms a logical address into a linear address by means of
a hardware circuit called a segmentation unit ; subsequently, a second hardware circuit called a
paging unit transforms the linear address into a physical address

 

---- Segment Selectors and Segmentation Registers 

A logical address consists of two parts: a segment identifier and an offset that specifies the relative  address within the segment.The segment identifier is a 16-bit field called the Segment Selector

To make it easy to retrieve segment selectors quickly, the processor provides segmentation registerswhose only purpose is to hold Segment Selectors; these registers are called cs, ss, ds, es, fs, and  gs. Although there are only six of them, a program can reuse the same segmentation register for different purposes by saving its content in memory and then restoring it later. Three of the six segmentation registers have specific purposes:

cs

The code segment register, which points to a segment containing program instructions
ss
The stack segment register, which points to a segment containing the current program stack
ds
The data segment register, which points to a segment containing global and static data

The remaining three segmentation registers are general purpose and may refer to arbitrary data segments.

The cs register has another important function: it includes a 2-bit field that specifies the Current
Privilege Level (CPL) of the CPU. The value 0 denotes the highest privilege level, while the value 3
denotes the lowest one. Linux uses only levels 0 and 3, which are respectively called Kernel Modeand User Mode.

  • Segment Descriptors

Each segment is represented by an 8-byte Segment Descriptor that describes the segment
characteristics. Segment Descriptors are stored either in the Global Descriptor Table (GDT ) or in the
Local Descriptor Table(LDT).

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.