《Linux Kernel Development》chapter 1 Introduction to Linux Kernel

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 process creation time, enable the creation of simple programs that  do one thing and do it well .


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


Well, okay, not everything—but much is represented as a file. Sockets are a notable exception. Some 
recent efforts, such as Unix’s successor at Bell Labs, Plan9, implement nearly all aspects of the system 
as 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 be executing 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 can generalize that each processor is doing exactly one of three things at any given moment:

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



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 classic Unix systems:

1.Linux supports the dynamic loading of kernel modules. Although the Linux kernel is 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 Unix implementations, Solaris and IRIX have preemptive kernels, but most Unix kernels are not preemptive.


4.Linux takes an interesting approach to thread support: It does not differentiate between 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-pluggable events, and a user-space device filesystem (sysfs).


6.Linux ignores some common Unix features that the kernel developers consider poorly designed, such as STREAMS, or standards that are impossible to cleanly implement.


7.Linux is free in every sense of the word.The feature set Linux implements is the result of the freedom of Linux’s open development model. If a feature is without merit 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, and have a solid implementation. Consequently, features of some other modern Unix variants that are more marketing bullet or one-off requests, such as pageable kernel memory, 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, represent Linux 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 minor release also determines whether the kernel is a stable or development kernel; an even number is stable, whereas an odd number is development




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







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值