TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How to Make a Computer Operating System in C/C++

235 pointsby SamyPesseover 11 years ago

17 comments

Jagatover 11 years ago
I am a graduate student, currently working on building a x86_64 unix like preemptive kernel from scratch, as part of a course. Most of the OS dev guides and books focus on 32 bit arch and I haven&#x27;t found a single guide so far that is based on 64 bit arch. Since this this guide seems to be in its inception, I hope someone (hopefully me) will send a pull request for a 64 bit tutorial.<p>Building an OS has been in my bucket list for long and it has been one heck of an experience so far.<p>Here are some good step-by-step OS-from-scratch programming guides<p><a href="http://jamesmolloy.co.uk/tutorial_html/index.html" rel="nofollow">http:&#x2F;&#x2F;jamesmolloy.co.uk&#x2F;tutorial_html&#x2F;index.html</a><p><a href="http://www.osdever.net/bkerndev/Docs/title.htm" rel="nofollow">http:&#x2F;&#x2F;www.osdever.net&#x2F;bkerndev&#x2F;Docs&#x2F;title.htm</a><p><a href="http://www.ijack.org.uk/" rel="nofollow">http:&#x2F;&#x2F;www.ijack.org.uk&#x2F;</a><p><a href="http://www.brokenthorn.com/Resources/OSDevIndex.html" rel="nofollow">http:&#x2F;&#x2F;www.brokenthorn.com&#x2F;Resources&#x2F;OSDevIndex.html</a><p><a href="http://viralpatel.net/taj/operating-system-tutorial.php" rel="nofollow">http:&#x2F;&#x2F;viralpatel.net&#x2F;taj&#x2F;operating-system-tutorial.php</a><p>and here&#x27;s a good wiki for reference<p><a href="http://wiki.osdev.org/Expanded_Main_Page" rel="nofollow">http:&#x2F;&#x2F;wiki.osdev.org&#x2F;Expanded_Main_Page</a>
评论 #6828996 未加载
评论 #6830424 未加载
评论 #6829257 未加载
评论 #6830835 未加载
clarryover 11 years ago
It&#x27;s not C&#x2F;C++. C&#x2F;C++ is not a language. The project&#x27;s goal is to write a very simple UNIX-based operating system in C++ (does anyone else smell a contradiction?). The code is predominantly C++.
评论 #6828921 未加载
评论 #6828904 未加载
评论 #6829056 未加载
评论 #6828820 未加载
评论 #6828855 未加载
exDM69over 11 years ago
A hobby operating system project - everyone&#x27;s gotta have one, right?<p>There are many like it but this one is mine: <a href="https://github.com/rikusalminen/danjeros" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rikusalminen&#x2F;danjeros</a><p>It&#x27;s an x86_64 bare bones kernel project, doesn&#x27;t do much except for boot and handle some interrupts. There&#x27;s a little multitasking and some related stuff.<p>Unfortunately there&#x27;s only a finite amount of time in the world, and not too much of it is available for me to dedicate to this project.
waterside81over 11 years ago
Who remembers Nachos?<p><a href="https://en.wikipedia.org/wiki/Not_Another_Completely_Heuristic_Operating_System" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Not_Another_Completely_Heurist...</a><p>3rd year OS class we had to use Nachos as our base OS and build your usual file management, pipes etc. functionality on top of it.<p>Really taught you how an OS works.
评论 #6830031 未加载
slunkover 11 years ago
Fyi, at least at first, this looks like it will be very similar to a few wonderful tutorials and projects I have been going through lately:<p>* <a href="http://www.jamesmolloy.co.uk/tutorial_html/index.html" rel="nofollow">http:&#x2F;&#x2F;www.jamesmolloy.co.uk&#x2F;tutorial_html&#x2F;index.html</a><p>* <a href="http://www.osdever.net/tutorials/view/brans-kernel-development-tutorial" rel="nofollow">http:&#x2F;&#x2F;www.osdever.net&#x2F;tutorials&#x2F;view&#x2F;brans-kernel-developme...</a><p>* <a href="https://github.com/klange/toaruos" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;klange&#x2F;toaruos</a><p>...and just in case anyone is curious, my own project (about half way through James M&#x27;s tutorial - working on virtual memory management):<p><a href="https://github.com/slunk/Hobbyos" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;slunk&#x2F;Hobbyos</a><p>Oh, and btw, this looks AWESOME. I am looking through the finished chapters right now!
rstover 11 years ago
Might also be worth looking at xv6, which is a rewrite of Unix v6 in modern C, and comes with an exegesis modelled on the classic Lions book:<p><a href="http://pdos.csail.mit.edu/6.828/2012/xv6.html" rel="nofollow">http:&#x2F;&#x2F;pdos.csail.mit.edu&#x2F;6.828&#x2F;2012&#x2F;xv6.html</a><p>(Although if you want to run the original Unix v6, written in a now-archaic proto-C --- unsigned integer variables are declared as pointers because &quot;unsigned&quot; itself wasn&#x27;t directly supported in the language yet --- PDP-11 emulators and system images are readily available.)
winocmover 11 years ago
I just wish more people dealt with ARM instead of x86. It&#x27;s a far better architecture for people to learn system design.
评论 #6829830 未加载
评论 #6828660 未加载
djvu9over 11 years ago
For those who are interested in developing a realistically useful small OS in C++ (or even C++ 11), you may probably want to check out OSv <a href="https://github.com/cloudius-systems/osv/" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;cloudius-systems&#x2F;osv&#x2F;</a> developed by previous KVM guys.
agumonkeyover 11 years ago
Been reading Massalin&#x27;s Thesis on Synthesis OS (partially evaluated, dynamically generated kernel code), it&#x27;s a refreshing and very inspiring read:<p><a href="http://valerieaurora.org/synthesis/SynthesisOS/" rel="nofollow">http:&#x2F;&#x2F;valerieaurora.org&#x2F;synthesis&#x2F;SynthesisOS&#x2F;</a>
e12eover 11 years ago
Maybe a little irationally, the idea of programming an os in c++ strikes me as very opaque. I think the vipri[1] approach of layering dsls, or the smalltalk idea of a relatively simple vm to <i>seem</i> more understandable than an os that embeds a c++ runtime...<p>As a side note, when looking up [1] I also ran across [2].<p>[1] <a href="http://piumarta.com/software/cola/" rel="nofollow">http:&#x2F;&#x2F;piumarta.com&#x2F;software&#x2F;cola&#x2F;</a> [2] <a href="http://www.acm.uiuc.edu/sigops/roll_your_own/1.helloworld.html" rel="nofollow">http:&#x2F;&#x2F;www.acm.uiuc.edu&#x2F;sigops&#x2F;roll_your_own&#x2F;1.helloworld.ht...</a>
评论 #6830257 未加载
xradionutover 11 years ago
How about making a language, compiler, OS and applications and not use C or C++ ?<p><a href="https://news.ycombinator.com/item?id=6829464" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=6829464</a>
评论 #6833392 未加载
Spl3enover 11 years ago
Another very complete tutorial : <a href="http://www.brokenthorn.com/Resources/OSDevIndex.html" rel="nofollow">http:&#x2F;&#x2F;www.brokenthorn.com&#x2F;Resources&#x2F;OSDevIndex.html</a>
devhintonover 11 years ago
This is great. I am just jumping into open source from an academic background. I had assumed that open source was great for directly practical website creating and hosting (back-end, client side etc...) but weaker in terms of learning for OS &#x2F; compilers. This post and its comments (with linked resources) are making me unsure about this assumption. What do you think?
zplesivcakover 11 years ago
Here [1] you can find another example of writing OS from scratch. Going through chapters progress is made iteratively by making limited changes in each step. This OS is intended to be (RT)OS for embedded computers, but example arch-level is implemented for x86.<p>[1] <a href="https://github.com/l30nard0/Benu" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;l30nard0&#x2F;Benu</a>
vezzy-fnordover 11 years ago
Obviously this is still in its very early stages, but I can see this becoming a very informative and practical course.<p>I&#x27;ll definitely be keeping an eye on this. Do you intend on turning this into a book and perhaps publishing physical copies?
评论 #6828588 未加载
stonewhiteover 11 years ago
&quot;It was written several years ago as one of my first projects when I was in High School&quot; High school? Really? Are there any proper highschools like these? I am jealous now.
tejasmover 11 years ago
Very interesting. A friend and I tried creating our own OS back in 2002 using interrupts to write the boot program. I wish I had this tutorial back then.