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

天行健 君子當自強而不息

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 閱讀(875) 評論(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视频精品在线| 牛人盗摄一区二区三区视频| 性色av一区二区三区红粉影视| 亚洲视频综合| 亚洲校园激情| 一级成人国产| 亚洲男女毛片无遮挡| 性欧美xxxx大乳国产app| 久久精品官网| 欧美成人a∨高清免费观看| 亚洲福利视频在线| 一本大道久久a久久精二百| 一区二区精品| 久久精品一本| 欧美午夜精品伦理| 国模套图日韩精品一区二区| 亚洲激情成人| 亚洲欧美大片| 免费观看欧美在线视频的网站| 亚洲黄色在线看| 午夜亚洲福利在线老司机| 久久国产成人| 欧美日韩免费在线视频| 国产一级揄自揄精品视频| 亚洲精品自在在线观看| 欧美在线免费观看| 亚洲精美视频| 久久久久久久999| 国产精品国产自产拍高清av王其| 国内揄拍国内精品少妇国语| 亚洲视频综合在线| 欧美成人免费全部观看天天性色| 亚洲天堂免费观看| 欧美精品日韩三级| 亚洲国产精品一区在线观看不卡| 亚洲欧美日韩中文在线制服| 欧美国产免费| 香蕉久久夜色精品| 国产精品成av人在线视午夜片| 在线国产欧美| 久久精品国产一区二区电影| 一本久久a久久免费精品不卡| 久久婷婷人人澡人人喊人人爽| 国产精品国产三级欧美二区| 亚洲福利视频免费观看| 久久精品毛片| 亚洲欧美日韩电影| 国产精品久久久久免费a∨大胸| 亚洲精品一区二区在线观看| 久久视频一区二区| 蜜桃av一区二区| 亚洲一区网站| 亚洲国产精品传媒在线观看| 香蕉久久夜色精品| 国产欧美一区二区精品性色| 亚洲自拍偷拍视频| 一区二区三区免费在线观看| 欧美精品色综合| 亚洲伦理网站| 亚洲国产一区二区三区a毛片| 另类专区欧美制服同性| 樱桃视频在线观看一区| 久久国产精品99国产| 亚洲综合日韩在线| 国产精品免费一区豆花| 亚洲综合电影一区二区三区| 99视频热这里只有精品免费| 欧美色大人视频| 亚洲欧美日韩国产一区二区三区 | 亚洲视频专区在线| 国产精品美女一区二区在线观看| 亚洲欧美区自拍先锋| 亚洲一级在线观看| 国产亚洲激情视频在线| 巨乳诱惑日韩免费av| 美女视频黄 久久| av不卡在线| 亚洲一区免费观看| 海角社区69精品视频| 欧美承认网站| 国产精品hd| 久久综合导航| 欧美另类专区| 欧美一区国产二区| 免费国产一区二区| 亚洲香蕉成视频在线观看| 午夜国产不卡在线观看视频| 在线日韩av片| 99re国产精品| 韩国女主播一区二区三区| 亚洲黄色成人| 国产精品日韩高清| 欧美福利在线观看| 国产精品扒开腿做爽爽爽视频| 久久久国产午夜精品| 欧美精品成人一区二区在线观看 | 日韩亚洲欧美一区二区三区| 国产精品你懂的在线欣赏| 蜜桃av一区二区| 欧美日韩亚洲一区二区| 久久偷看各类wc女厕嘘嘘偷窃| 欧美精品激情blacked18| 欧美在线高清| 欧美激情亚洲一区| 99精品国产在热久久婷婷| 国产精品大片| 久色成人在线| 国产精品豆花视频| 欧美成人免费在线观看| 国产精品久久久久久久久久三级| 欧美成人69av| 国产在线精品自拍| 一区二区三区成人| 亚洲人在线视频| 午夜宅男欧美| 亚洲主播在线| 欧美日韩情趣电影| 亚洲国产美女精品久久久久∴| 国产综合18久久久久久| 亚洲一区二区三区中文字幕在线 | 亚洲综合色网站| 欧美激情第4页| 免费91麻豆精品国产自产在线观看| 国产精品久久九九| 亚洲免费成人av电影| 亚洲国产精品成人| 久久精品中文| 久久久精品欧美丰满| 国产精品视频免费| 亚洲天堂网站在线观看视频| 在线视频一区观看| 欧美日韩精品免费观看| 亚洲精品久久在线| 一级日韩一区在线观看| 欧美精品免费观看二区| 亚洲激情在线播放| 日韩视频免费看| 欧美国产精品va在线观看| 欧美福利视频网站| 亚洲日本免费| 欧美日韩成人一区二区| 亚洲精品一二三| 亚洲一级影院| 国产毛片精品视频| 先锋影音国产精品| 国产精品日韩在线| 欧美一区日韩一区| 裸体歌舞表演一区二区| 在线视频成人| 欧美激情综合网| av成人免费| 久久国产日韩| 亚洲第一毛片| 欧美日本韩国一区二区三区| 99re66热这里只有精品3直播| 在线视频一区二区| 国产欧美不卡| 久久久人成影片一区二区三区| 免费成人黄色| 夜夜嗨av一区二区三区| 国产精品日本一区二区| 久久久美女艺术照精彩视频福利播放| 欧美成人精品| 亚洲深夜福利网站| 国产一区日韩二区欧美三区| 久久综合婷婷| 在线中文字幕日韩| 麻豆精品91| 99re66热这里只有精品4| 亚洲电影有码| 国产日韩视频| 免费h精品视频在线播放| 亚洲精品乱码久久久久久蜜桃91 | 亚洲欧美经典视频| 欧美成人久久| 午夜精品美女自拍福到在线 | 性做久久久久久| 亚洲国产成人久久| 国产欧美日韩高清| 欧美精品一区三区| 久久电影一区| 在线亚洲高清视频| 欧美黄色免费| 久久久久久久波多野高潮日日| 一区二区三区四区蜜桃| 国产一区在线观看视频| 欧美日韩精品免费观看视一区二区 | 麻豆精品传媒视频| 亚洲午夜精品一区二区| 一区二区在线视频观看| 国产精品久久久久久久久久久久| 久久亚洲高清| 欧美一区二区女人| 99视频在线观看一区三区| 欧美成人网在线| 久久视频在线视频| 久久se精品一区二区| 午夜精品亚洲一区二区三区嫩草| 亚洲国产精品高清久久久|