Linus为什么不用C++写Linux内核?
在最近的一个关于LKML的讨论中,Linus给出了为什么不用C++来写Linux内核的理由:
"In fact, in Linux we did try C++ once already, back in 1992. It sucks. Trust me - writing kernel code in C++ is a BLOODY STUPID IDEA.
“事实上,我们曾经尝试过用C++来写,是在1992年的时候。很糟糕。相信我--用C++来写内核代码是一个非常愚蠢的想法。”
"The fact is, C++ compilers are not trustworthy. They were even worse in 1992, but some fundamental facts haven't changed: 1) the whole C++ exception handling thing is fundamentally broken. It's _especially_ broken for kernels. 2) any compiler or language that likes to hide things like memory allocations behind your back just isn't a good choice for a kernel. 3) you can write object-oriented code (useful for filesystems etc) in C, _without_ the crap that is C++."
“实际上,C++编译器是很不可靠的。在1992年的时候情况就很差了,而且一些基础的东西到现在还没有改变:(1)整个C++对Exception的处理根本就是不完整的,特别是在写内核的时候。(2)任何喜欢把跟内存分配有关的功能匿藏起来的编译器或者程序语言对于编写内核来说都是错误的选择。(3)在C里面你也可以写面向对象的代码(写文件系统的时候很有用),是不需要C++的。
相关文档:
本书全面介绍了Ubuntu Linux的相关知识,内容详实,论述清晰。主要内容包括Ubuntu介绍、文件系统管理、进程管理、压缩与查询系统、Shell应用、TCP/IP基础、网络管理、网络硬盘以及加密安全通信等内容。
本书是一本理论与实践并重的书籍,可作为专业人员的参考书籍,也适合于对Ubuntu ......
fork函数学习:
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
main ()
{
pid_t pid; pid=fork();
if (pid < 0)
printf("error in fork!");
else if (pid == 0)
printf("i ......
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
int main()
{
pid_t pid;
static int n = 0;
printf("fork!\n"); /*printf("fork!")*/
switch (pid = fork())
{
&nbs ......
1. man 对你熟悉或不熟悉的命令提供帮助解释 eg:man ls 就可以查看ls相关的用法 注:按q键或者ctrl+c退出,在linux下可以使用ctrl+c终止当前程序运行。 2. ls 查看目录或者文件的属*,列举出任一目录下面的文件 eg: ls /usr/man ls -l a.d表示目录(directory),如果是一个"-"表示是文件,如果是l则表示 ......