Live data from Hacker News

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

github.com

51–60 of 88 posts

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

#51
post #11

It's not C/C++. C/C++ is not a language. The project'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++.

You are correct. Usually I see this in CVs. It usually means that the person is proficient in C++ but knows a little C as well. But C/C++ can be a language. It could be a code written in C++ but looks more like C than C++. Some people e.g. use character arrays instead of string class, avoid STL as much as possible, don't use object-oriented aspects of the language, etc. The end result uses some C++ libraries, compile…

I was looking at an analysis of id Tech's Doom3:BFG engine yesterday, and it's best described as this. The author described it as "C, with classes". Quite interesting, so I went and asked some game devs I know, apparently this is pretty standard!

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

#52
post #9
post #7

I just wish more people dealt with ARM instead of x86. It's a far better architecture for people to learn system design.

I've been looking for good OS dev tutorials for ARM. Does anyone know of any besides Baking Pi?

My research about 12months ago didn't give much, sadly.

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

#53
post #28
post #7

I just wish more people dealt with ARM instead of x86. It's a far better architecture for people to learn system design.

Why? (I'm curious as I know little of these kinds of things, and because citing sources or giving arguments is always a good thing)

For example, look at all of the legacy stuff in an x86 system. You have the strange structure of the interrupt descriptor table/global descriptor table. You have the good old Intel 8042 keyboard controller, Intel 8259 programmable interrupt controller, old-style programmable interval timer, A20 gate and so much more.

There's so much legacy baggage inherent in the x86 architecture, all because of software compatibility. (ROM-BASIC will still run on a modern PC!)

ARM on the other hand has less to really worry about, sure there's some legacy infrastructure, such as the ARM vector table. Modern ARM architectures such as ARMv8-A remove old legacy baggage in favor of completely renovating it. (Look at the old coprocessor interface for instance. In A64 mode, it is completely gone. You must use 'mrs/msr' instructions compared to 'mrc/mcr'). There's also far less legacy software to worry about.

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

#54
post #11

It's not C/C++. C/C++ is not a language. The project'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++.

I thought it was a reference to this* when I read the title, but after reading them both I'm not sure there is any connection. * http://i.imgur.com/fQ1ST8w.jpg

please tell me it was some kind of joke

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

#55
post #45

Earlier quoted context omitted.

I still don't understand why std::list is bad. Could you explain please?

std::list can be used in 2 ways: * With an std::list::iterator in each of your data nodes that represents its own position in the list (this is called the "intrusive style") * Without an std::list::iterator in each of your data nodes If you use the (more common) latter form: whenever you have a reference to your own object, you cannot do any of the linked list operations without an O(N) penalty to go and re-find your…

Thanks for your excellent and detailed response! This makes complete sense.

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

#56
post #45

Earlier quoted context omitted.

I still don't understand why std::list is bad. Could you explain please?

std::list can be used in 2 ways: * With an std::list::iterator in each of your data nodes that represents its own position in the list (this is called the "intrusive style") * Without an std::list::iterator in each of your data nodes If you use the (more common) latter form: whenever you have a reference to your own object, you cannot do any of the linked list operations without an O(N) penalty to go and re-find your…

> whenever you have a reference to your own object, you cannot do any of the linked list operations without an O(N) penalty to go and re-find your element in the list!

Can you show an example of when you actually need to do this? Because when I need to do something like this it usually means that some container other than list is more fitting for the problem.

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

#57
post #40

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 seem more understandable than an os that embeds a c++ runtime... As a side note, when looking up [1] I also ran across [2]. [1] http://piumarta.com/software/cola/ [2] http://www.acm.uiuc.edu/sigops/roll_your_own/1.helloworld.ht..…

BeOS was primarily written in C++, although the kernel was dominantly C. For actual parts that require user interaction, C++ and the object model makes a whole lot of sense, although there are probably more mature languages out that would be better candidates now.

Haiku (BeOS' descendant) is written in C++ as well

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

#58
post #50
post #22

Earlier quoted context omitted.

Building OS' is fun. I wish I could spend all day doing it but I've been pushed so far up the stack that I spend most of the time arguing with analysts and preparing documentation... I've built two so far which were (and I think still were until recently) used in production equipment. One Forth system (all 8k of it) that ran a PLC system and a tiny (16k) kernel for an M68k system that was a router for a modbus-like p…

I've been a web developer my entire professional career, and for some ungodly reason I have this need to go work in the embedded sector instead. Am I nuts? ;)

Not at all!

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

#59
post #56
post #45

Earlier quoted context omitted.

std::list can be used in 2 ways: * With an std::list::iterator in each of your data nodes that represents its own position in the list (this is called the "intrusive style") * Without an std::list::iterator in each of your data nodes If you use the (more common) latter form: whenever you have a reference to your own object, you cannot do any of the linked list operations without an O(N) penalty to go and re-find your…

> whenever you have a reference to your own object, you cannot do any of the linked list operations without an O(N) penalty to go and re-find your element in the list! Can you show an example of when you actually need to do this? Because when I need to do something like this it usually means that some container other than list is more fitting for the problem.

Indeed, coming from Prolog/Erlang-style "most everything can be represented as a tail-call with a linked-list accumulator" programming, I'm very confused about what operations the GP is talking about. Adding/removing nodes at a position other than the head? Lookup by value? If you need these, you should be using a different data structure.
Post reply on HN