深入理解Linux内核 Chapter1 introduction

本章节以Linux基础知识为主,本文包括如下内容:Linux相对于其他类Unix操作系统的特点和优势基础的操作系统概念Unix文件系统的大概介绍(如文件类型,硬软链接,文件的访问权限等等)Unix内核的大概介绍(包括Linux采取的结构模型,信号等等)内存管理中比较重要的部分,如:虚拟内存,RAM的使用,设备驱动等等
摘要由CSDN通过智能技术生成

1.1 Linux versus Other Unix-like kernels

Linux是庞大的类unix操作系统家族的一员,最初始的作者是Linus Torvalds.一开始Linux是在intel80386 个人PC上的操作系统。现在Linus还一直和世界各地的开发者进行着Linux系统的维护与版本更新。

Linux 2.6版本符合IEEE POSIX标准,这就意味着大部分现存的Unix程序可以在Linux上编译和执行,系统仅仅需要对源代码进行一点点改变或者完全不用改变。
此外,Linux也包含了所有现代Unix操作系统的特性,包括:

  • virtual memory
  • a virtual filesystem
  • lightweight processes(暂译为轻量进程,之前从来没遇到过,后续学习应该会学到)

    (Thread有三种:kernel threads, lightweight processes, user threads.)

  • Unix signals

  • SVR4 interprocess communications(进程间通信)

    SVR4(UNIX System V Release4)是内核标准,具有极高的标准性,那意味着你学好了SVR4可以在所有SVR4内核的操作系统上进行统一的操作.

  • Support for Symmetric Multiprocessor (SMP) systems(对称多处理器系统)(没学过,后续补充学习)

下列就例举了Linux如何和很多知名的商业Unix内核竞争的特点:

Features
Monolithic(整体的) kernel It is a large, complex do-it-yourself program, composed of several logically different components. In this, it is quite conventional; most commercial Unix variants are monolithic. (Notable(著名的,显著的) exceptions are the Apple Mac OS X and the GNU Hurd operating systems, both derived from the Carnegie-Mellon’s Mach, which follow a microkernel(微内核) approach.)
Compiled and statically linked traditional Unix kernels Most modern kernels can dynamically load and unload some portions of the kernel code (typically, device drivers), which are usually called modules(模块) . Linux’s support for modules is very good, because it is able to automatically load and unload modules on demand. Among the main commercial Unix variants, only the SVR4.2 and Solaris kernels have a similar feature.
Kernel threading Some Unix kernels, such as Solaris and SVR4.2/MP, are organized as a set of kernel threads(内核线程) . A kernel thread is an execution context that can be independently scheduled(安排); it may be associated with a user program, or it may run only some kernel functions. Context switches between kernel threads(内核线程之间的内容转换) are usually much less expensive than context switches between ordinary processes, because the former usually operate on a common address space(共同地址空间). Linux uses kernel threads in a very limited way to execute a few kernel functions periodically; however, they do not represent the basic execution context abstraction. (That’s the topic of the next item.)
Multithreaded application support Most modern operating systems have some kind of support for multithreaded applications(多线程应用程序) that is, user programs that are designed in terms of many relatively independent execution flows that share a large portion of the application data structures. A multithreaded user application could be composed of many lightweight processes (LWP)(多线程应用程序由许多LWP组成),which are processes that can operate on a common address space, common physical memory pages, common opened files, and so on.Linux defines its own version of lightweight processes, which is different from the types used on other systems such as SVR4 and Solaris(Linux中的LWP和其他系统不同). While all the commercial Unix variants of LWP are based on kernel threads, Linux regards lightweight processes as the basic execution context and handles them via the nonstandard clone( ) system call(Linux将LWP看做基础的内容执行,并使用非标准的系统调用clone来处理LWP).
Preemptive kernel(优先权内核) When compiled with the “Preemptible Kernel” option, Linux 2.6 can arbitrarily interleave(交错) execution flows(交错执行流) while they are in privileged mode(特权模式). Besides Linux 2.6, a few other conventional(常规的), general-purpose Unix systems, such as Solaris and Mach 3.0 , are fully preemptive kernels. SVR4.2/MP introduces some fixed preemption points as a method to get limited preemption capability(获得限制性的优先能力).
Multiprocessor support Several Unix kernel variants take advantage of multiprocessor systems. Linux 2.6 supports symmetric multiprocessing (SMP )(对称多处理器系统) for different memory models, including NUMA: the system can use multiple processors and each processor can handle any task there is no discrimination(歧视,差别) among them. Although a few parts of the kernel code are still serialized(序列化) by means of a single “big kernel lock ,” it is fair to say that Linux 2.6 makes a near optimal(最佳的) use of SMP.
Filesystem Linux’s standard filesystems come in many flavors. You can use the plain old Ext2 filesystem if you don’t have specific needs. You might switch to Ext3if you want to avoid lengthy(啰嗦的) filesystem checks after a system crash. If you’ll have to deal with many small files, the ReiserFS filesystem is likely to be the best choice. Besides Ext3 and ReiserFS, several other journaling filesystems can be used in Linux; they include IBM AIX’s Journaling File System (JFS )and Silicon Graphics IRIX ‘s XFS filesystem. Thanks to a powerful object-oriented(目标导向) Virtual File System technology (inspired by Solaris and SVR4), porting a foreign filesystem to Linux is generally easier than porting to other kernels.(虚拟文件系统技术是的引入文件系统到Linux比引入到其他内核中要更容易)
STREAMS Linux has no analog(模拟的) to the STREAMS I/O subsystem introduced in SVR4, although it is included now in most Unix kernels and has become the preferred(首选的) interface for writing device drivers, terminal drivers, and network protocols.(进场STREAMS已经成为写设备驱动,终端驱动和网络协议的首先接口)

Linux advantages

Advantages
1.Linux is cost-free You can install a complete Unix system at no expense other than the hardware (of course).
2.Linux is fully customizable in all its components Thanks to the compilation options, you can customize the kernel by selecting only the features really needed. Moreover, thanks to the GPL, you are allowed to freely read and modify the source code of the kernel and of all system programs. (但是许多公司软件不开源)
3.Linux runs on low-end, inexpensive hardware platforms You are able to build a network server using an old Intel 80386 system with 4 MB of RAM.
4.Linux is powerful Linux systems are very fast, because they fully exploit the features of the hardware components. The main Linux goal is efficiency, and indeed many design choices of commercial variants, like the STREAMS I/O subsystem, have been rejected by Linus because of their implied performance penalty.
5.Linux developers are excellent programmers Linux systems are very stable; they have a very low failure rate and system maintenance time.
6.The Linux kernel can be very small and compact It is possible to fit a kernel image, including a few system programs, on just one 1.44 MB floppy disk. As far as we know, none of the commercial Unix variants is able to boot from a single floppy disk.
7.Linux is highly compatible with many common operating systems Linux lets you directly mount filesystems for all versions of MS-DOS and Microsoft Windows, SVR4, OS/2 , Mac OS X , Solaris , SunOS , NEXTSTEP , many BSD variants, and so on.Linux also is able to oper
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

猎羽

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值