《Linux Kernel Development》chapter 1 Introduction to Linux

Introduction to Linux Kernel

谈Linux基本上都会先扯一扯Unix,都懂的。。。

第一章主要是很基础的铺垫。。。但是还是留点什么吧,所谓笔记

Unix is simple:

Whereas some operating systems implement thousands of system calls and have unclear design goals, Unix systems implement only hundreds of system calls and have a straightforward, even basic, design.

Second, in Unix, everything is a file .This simpliy-fies the manipulation of data and devices into a set of core system calls: open() , read() ,write(), lseek(), and close().

Third, the Unix kernel and related system utilities arewritten in C—a property that gives Unix its amazing portability to diverse hardware architectures and accessibility to a wide range of developers.

Fourth, Unix has fast process creation time and the unique fork() system call.

Finally, Unix provides simple yet robust interprocess communication (IPC) primitives that, when coupled with the fast processcreation time, enable the creation of simple programs that do one thing and do it well .

Thesesingle-purpose programs can be strung together to accomplish tasks of increasing complexity. Unix systems thus exhibit clean layering, with a strong separation between policyand mechanism.

Well, okay, not everything—but much is represented as a file. Sockets are a notable exception. Somerecent efforts, such as Unix’s successor at Bell Labs, Plan9, implement nearly all aspects of the systemas a file.

书上有上面这么一段话,socket在Unix里面是不是文件我不知道,但是在linux里面一定是了。。。

http://www.cnblogs.com/skynet/archive/2010/12/12/1903949.html

同样可以看

http://blog.csdn.net/cinmyheart/article/details/21740279

文件类型的那一小节

Applications running on the system communicate with the kernel via system calls

When an application executes a system call, we say that the kernel is executing on behalf of the application. Furthermore, the application is said to beexecuting a system call in kernel-space, and the kernel is running inprocess context.

These contexts represent the breadth of the kernel’s activities. In fact, in Linux, we cangeneralize that each processor is doing exactly one of three things at any given moment:

In user-space, executing user code in a processIn kernel-space, in process context, executing on behalf of a specific processIn kernel-space, in interrupt context, not associated with a process, handling aninterrupt

Unix 是要求硬件要有MMU的,但是某些linux上面是可以不需要MMU就可以跑linux的

由于Unix和linux都遵循POSIX,以至于我看APUE的感觉linux和Unix到底有区别么(傻傻很天真。。)

Linux is not Unix !

A handful of notable differences exist between the Linux kernel and classicUnix systems:

1.Linux supports the dynamic loading of kernel modules. Although the Linux kernelis monolithic, it can dynamically load and unload kernel code on demand.

2.Linux has symmetrical multiprocessor (SMP) support. Although most commercial variants of Unix now support SMP, most traditional Unix implementations did not.

3.The Linux kernel is preemptive. Unlike traditional Unix variants, the Linux kernel can preempt a task even as it executes in the kernel. Of the other commercial Uniximplementations, Solaris and IRIX have preemptive kernels, but most Unix kernelsare not preemptive.

4.Linux takes an interesting approach to thread support: It does not differentiatebetween threads and normal processes.To the kernel, all processes are the same—some just happen to share resources.

5.Linux provides an object-oriented device model with device classes, hot-pluggableevents, and a user-space device filesystem (sysfs).

6.Linux ignores some common Unix features that the kernel developers considerpoorly designed, such as STREAMS, or standards that are impossible to cleanlyimplement.

7.Linux is free in every sense of the word.The feature set Linux implements is theresult of the freedom of Linux’s open development model. If a feature is withoutmerit or poorly thought out, Linux developers are under no obligation to implement it.To the contrary, Linux has adopted an elitist attitude toward changes: Modifications must solve a specific real-world problem, derive from a clean design, andhave a solid implementation. Consequently, features of some other modern Unixvariants that are more marketing bullet or one-off requests, such as pageable kernelmemory, have received no consideration.

操作系统的内核基本上就两大阵营:单核和微核

这里要理解一下这个概念,单核是内核以单一的一个二进制文件存放在内存的静态储存区。而微核是把内核分成多个进程的形式存放在内存个的不同区域中。

Monolithic Kernel Versus Microkernel Designs

We can divide kernels into two main schools of design: the monolithic kernel and the micro-kernel. (A third camp, exokernel, is found primarily in research systems.)

Monolithic kernels are the simpler design of the two。

Monolithic kernels are implemented entirely as a single process running in a single address space. Consequently, such kernels typically exist on disk as sin -gle static binaries. All kernel services exist and execute in the large kernel address space.

The Windows NT kernel (on which Windows XP, Vista, and 7 are based) and Mach (on which part of Mac OS X is based) are examples of microkernels. Neither Windows NT nor Mac OS X run any micro-kernel servers in user-space in their latest iteration, defeating the primary purpose of micro-kernel design altogether.

Linux is a monolithic kernel; that is, the Linux kernel executes in a single address space entirely in kernel mode. Linux, however, borrows much of the good from microkernels: Linux boasts a modular design, the capability to preempt itself (called kernel preemption ), support for kernel threads, and the capability to dynamically load separate binaries (kernel modules) into the kernel image. Conversely, Linux has none of the performance-sapping features that curse microkernel design: Everything runs in kernel mode, with direct function invocation— not message passing—the modus of communication. Nonetheless, Linux is modular,threaded, and the kernel itself is schedulable. Pragmatism wins again。

最后一点就是kernel的版本号了

Linux kernels come in two flavors: stable and development.

Three or four numbers, delineated with a dot, representLinux kernel versions.

The first value is the major release,

the second is the minor release,

the third is the revision.

An optional fourth value is the stable version.

The minorrelease also determines whether the kernel is a stable or development kernel; an evennumber is stable, whereas an odd number is development

From this moment, I start my study life of linux kernel. Come on .Man!

勇敢的冷静的理智的去接受失败,有时不但是必要的,而且是很有必要的。

《Linux Kernel  Development》chapter 1 Introduction to Linux

相关文章:

你感兴趣的文章:

标签云: