青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

天行健 君子當自強而不息

Why don't we rewrite the Linux kernel in C++?


    * (ADB) Again, this has to do with practical and theoretical reasons. On the practical side, when Linux got started gcc didn't have an efficient C++ implementation, and some people would argue that even today it doesn't. Also there are many more C programmers than C++ programmers around. On theoretical grounds, examples of OS's implemented in Object Oriented languages are rare (Java-OS and Oberon System 3 come to mind), and the advantages of this approach are not quite clear cut (for OS design, that is; for GUI implementation KDE is a good example that C++ beats plain C any day).

    * (REW) In the dark old days, in the time that most of you hadn't even heard of the word "Linux", the kernel was once modified to be compiled under g++. That lasted for a few revisions. People complained about the performance drop. It turned out that compiling a piece of C code with g++ would give you worse code. It shouldn't have made a difference, but it did. Been there, done that.

    * (REG) Today (Nov-2000), people claim that compiler technology has improved so that g++ is not longer a worse compiler than gcc, and so feel this issue should be revisited. In fact, there are five issues. These are:

          o Should the kernel use object-oriented programming techniques? Actually, it already does. The VFS (Virtual Filesystem Switch) is a prime example of object-oriented programming techniques. There are objects with public and private data, methods and inheritance. This just happens to be written in C. Another example of object-oriented
programming is Xt (the X Intrinsics Toolkit), also written in C. What's important about object-oriented programming is the techniques, not the languages used.

          o Should the kernel be rewritten in C++? This is likely to be a very bad idea. It would require a very large amount of work to rewrite the kernel (it's a large piece of code). There is no point in just compiling the kernel with g++ and writing the odd function in C++, this would just result in a confusing mix of C and C++ code. Either the kernel is left in C, or it's all moved to C++.

            To justify the enormous effort in rewriting the kernel in C++, significant gains would need to be demonstrated. The onus is clearly on whoever wants to push the rewrite to C++ to show such gains.

          o Is it a good idea to write a new driver in C++? The short answer is no, because there isn't any support for C++ drivers in the kernel.

          o Why not add a C++ interface layer to the kernel to support C++ drivers? The short answer is why bother, since there aren't any C++ drivers for Linux. However, if you are bold enough to consider writing a driver in C++ and a support layer, be aware that this is unlikely to be well received in the community. Most of the kernel developers
are unconvinced of the merits of C++ in general, and consider C++ to generate bloated code. Also, it would result in a confusing mix of C and C++ code in the kernel. Any C++ code in the kernel would be a second-class citizen, as it would be ignored by most kernel developers when changes to internal interfaces are made. A C++ support layer would be frequently be broken by such changes (as whoever is making the changes would probably not bother fixing the C++ code to match), and thus would require a strong commitment from someone to regularly maintain it.

          o Can we make the kernel headers C++-friendly? This is the first step required for supporting C++ drivers, and on the face seems quite reasonable (it is not a C++ support layer). This has the problem that C++ reserves keywords which are valid variable or field names in C (such as private and new). Thus, C++ is not 100% backwards compatible with C. In effect, the C++ standards bodies would be dictating what variable names we're allowed to have. From past behaviour, the C++ standards people have not shown a commitment to 100% backwards compatibility. The fear is that C++ will continue to expand its claim on the namespace. This would generate an ongoing maintenance burden on the kernel developers.

            Note that someone once submitted a patch which performed this "cleaning up". It was ~250 kB in size, and was quite invasive. The patch did not generate much enthusiasm.

            Apparently, someone has had the temerity to label the above paragraph as "a bit fuddy". So Erik Mouw did a short back-of-the-envelope calculation to show that searching the kernel sources for possible C++ keywords is a nightmare. Here is his calculation and comments (dates April, 2002):

            % find /usr/src/linux-2.4.19-pre3-rmap12h -name "*.[chS]" |\
                xargs cat | wc -l
              4078662

            So there's over 4 million lines of kernel source. Let's assume 10% is
            comments, so there's about 3.6 million lines left. Each of those lines
            has to be checked for C++ keywords. Assume that you can do about 5
            seconds per line (very optimistic), work 24 hours per day, and 7 days
            a week:

                              5 s          1 hour     1 day          1 week
            3600000 lines * ------ * -------- * ---------- * -------- = 29.8 weeks
                             line     3600 s     24 hours     7 days

            Sounds like a nightmare to me. You can automate large parts of this,
            but you'll need to write a *very* intelligent search-and-replace tool
            for that. Better use that time in a more efficient way by learning C.

            Note that this is the time required to do a proper manual audit of the code. You could cheat and forgo the auditing process, and instead just compile with C++ and fix all compiler errors, figuring that the compiler can do most of the work. This would still be a major effort, and has the problem that there may be uses of some C++ keywords which don't generate a compiler error, but do generate unintended code. In other words, introduced bugs. That is not a risk the kernel development community is prepared to take.

      My personal view is that C++ has its merits, and makes object-oriented programming easier. However, it is a more complex language and is less mature than C. The greatest danger with C++ is in fact its power. It seduces the programmer, making it much easier to write bloatware. The kernel is a critical piece of code, and must be lean and fast. We cannot afford bloat. I think it is fair to say that it takes more skill to write efficient C++ code than C code. Not every contributer to the linux kernel is an uber-guru, and thus will not know the various tricks and traps for producing efficient C++ code.

    * (REG) Finally, while Linus maintains the development kernel, he is the one who makes the final call. In case there are any doubts on what his opinion is, here is what he said in 2004:

      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.

      The fact is, C++ compilers are not trustworthy. They were even worse in 1992, but some fundamental facts haven't changed:

          o the whole C++ exception handling thing is fundamentally broken. It's _especially_ broken for kernels.
          o any compiler or language that likes to hide things like memory allocations behind your back just isn't a good choice for a kernel.
          o you can write object-oriented code (useful for filesystems etc) in C, _without_ the crap that is C++.

      In general, I'd say that anybody who designs his kernel modules for C++ is either

          o (a) looking for problems
          o (b) a C++ bigot that can't see what he is writing is really just C anyway
          o (c) was given an assignment in CS class to do so.

      Feel free to make up (d).

posted on 2007-10-30 15:20 lovedday 閱讀(879) 評論(0)  編輯 收藏 引用 所屬分類: ▲ C++ Program

公告

導航

統計

常用鏈接

隨筆分類(178)

3D游戲編程相關鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美精品一区在线播放| 欧美影院午夜播放| 欧美日韩八区| 欧美精品午夜| 欧美特黄一级| 国产精品白丝黑袜喷水久久久| 欧美日韩精品一区二区| 欧美日韩精品免费观看| 国产精品久久一卡二卡| 国产精品永久免费在线| 国产综合亚洲精品一区二| 黄色国产精品| 亚洲毛片一区二区| 午夜激情一区| 麻豆亚洲精品| 99国产精品99久久久久久粉嫩| 一区二区三区四区五区在线 | 亚洲福利在线观看| 欧美成人四级电影| 日韩亚洲欧美中文三级| 欧美一级专区免费大片| 欧美成人免费播放| 亚洲黄色在线| 国产中文一区| 日韩视频专区| 欧美在线播放一区| 欧美国产视频在线| 亚洲一线二线三线久久久| 欧美精品成人| 国产亚洲精品bv在线观看| 91久久久精品| 久久国产欧美精品| 国产精品视频观看| 欧美日本高清一区| 亚洲在线免费| 亚洲第一色中文字幕| 一本在线高清不卡dvd| 久久国产精品网站| 国产精品网站在线观看| 欧美经典一区二区三区| 欧美一区午夜精品| 99re6热在线精品视频播放速度| 亚洲国产天堂网精品网站| 日韩一级在线观看| 玖玖视频精品| 国产一区二区黄色| 亚洲欧美日韩精品久久| 亚洲精品乱码久久久久久蜜桃麻豆| 欧美一区二区三区在线免费观看| 欧美日韩视频第一区| 在线日韩中文字幕| 久久久噜噜噜久久中文字幕色伊伊| 99视频一区二区| 欧美激情中文字幕乱码免费| 精品成人a区在线观看| 欧美一区视频| 亚洲资源在线观看| 国产精品久久国产精品99gif| 日韩视频精品| 亚洲国产精品成人va在线观看| 久久精品国产免费| 黑人巨大精品欧美一区二区小视频| 亚洲欧美日本另类| 亚洲一二三区精品| 国产精品一国产精品k频道56| 亚洲一区二区三区四区中文 | 国产一区在线免费观看| 亚洲一区二区少妇| 中国亚洲黄色| 国产精品免费电影| 欧美伊人久久| 欧美在线免费看| 136国产福利精品导航| 欧美mv日韩mv国产网站app| 久久久青草婷婷精品综合日韩| 在线观看欧美亚洲| 亚洲欧洲一区二区在线观看| 欧美日韩成人综合天天影院| 亚洲午夜精品网| 亚洲欧美日韩爽爽影院| 激情成人av在线| 亚洲国产日韩欧美一区二区三区| 欧美日韩久久不卡| 欧美在线网站| 免费成人在线观看视频| 一区二区三区高清不卡| 午夜激情综合网| 亚洲国产一区二区三区高清| 亚洲精品少妇网址| 国产女主播视频一区二区| 噜噜噜噜噜久久久久久91| 欧美精品尤物在线| 久久国产精品久久久久久| 麻豆91精品| 亚洲欧美日韩一区在线观看| 久久精品国产欧美激情| 这里是久久伊人| 久久国产欧美日韩精品| 亚洲精选视频免费看| 亚洲欧洲日韩综合二区| 久久综合九色综合欧美狠狠| 欧美激情综合五月色丁香| 午夜精品婷婷| 鲁大师影院一区二区三区| 亚洲综合国产| 免费在线观看日韩欧美| 欧美一级片在线播放| 欧美国产激情| 久久综合久久美利坚合众国| 欧美视频在线一区| 亚洲高清一区二| 国产午夜精品在线| 99亚洲视频| 亚洲人人精品| 久久青草久久| 欧美在线观看一区二区三区| 欧美 日韩 国产一区二区在线视频 | 欧美华人在线视频| 国产亚洲精品一区二区| 最新日韩精品| 亚洲国产日韩欧美在线99| 亚洲欧洲99久久| 亚洲系列中文字幕| 欧美激情综合网| 亚洲成色777777女色窝| 伊人久久av导航| 久久精品综合| 久久免费视频观看| 国产一区二区三区高清在线观看| 一区二区三区产品免费精品久久75 | 亚洲精品欧美| 蜜桃av综合| 欧美电影在线免费观看网站| 伊人狠狠色j香婷婷综合| 久久国产精品久久w女人spa| 欧美一区国产二区| 国产美女搞久久| 性久久久久久久| 久久久久久一区二区| 国产午夜亚洲精品理论片色戒| 亚洲一区二区三区影院| 亚久久调教视频| 国产噜噜噜噜噜久久久久久久久| 制服丝袜激情欧洲亚洲| 亚洲免费网址| 国产日韩欧美一区在线 | 国产乱码精品一区二区三区忘忧草| 亚洲最新视频在线| 亚洲欧美在线一区| 国产噜噜噜噜噜久久久久久久久| 亚洲欧美成人| 亚洲免费观看视频| av成人免费观看| 欧美一级视频| 激情欧美国产欧美| 欧美不卡视频| aa成人免费视频| 久久成人av少妇免费| 韩国美女久久| 欧美精品一区二区三区高清aⅴ| 亚洲欧洲日产国码二区| 亚洲一区二区三区欧美| 国产视频一区二区三区在线观看| 久久大逼视频| 亚洲三级视频| 久久不射中文字幕| 最新亚洲一区| 国产麻豆日韩| 欧美激情亚洲另类| 亚洲欧美日韩另类精品一区二区三区| 久久一区视频| 这里只有精品电影| 加勒比av一区二区| 欧美日韩亚洲在线| 欧美伊人久久大香线蕉综合69| 欧美国产日本韩| 欧美一区二区日韩| 日韩视频在线一区二区三区| 国产精品视频一二三| 欧美a级在线| 午夜精品美女久久久久av福利| 欧美a级大片| 午夜久久久久久| 亚洲区在线播放| 国产一区二区三区四区老人| 欧美高清在线一区| 久久精品国产一区二区三区免费看| 亚洲日本欧美| 欧美成年人视频网站| 欧美亚洲视频在线观看| 亚洲另类春色国产| 雨宫琴音一区二区在线| 国产精品视频网站| 国产精品高清在线观看| 女人天堂亚洲aⅴ在线观看| 欧美在线不卡| 亚洲欧美日韩另类| 亚洲一区二区黄色| 一区二区三区四区在线| 亚洲精品偷拍|