1

My goal is to learn more about operating system concepts by poking around some simpler OS's and possibly writing one from scratch.

The Raspberry Pi seems attractive as an entry level system to develop on. However, I am worried that this system may not be a good enough approximation to a modern computer. For example, the processor is single-core.

Can anyone speak from experience about whether the Raspberry Pi (B+) has adequate hardware support to be a good enough approximation to a modern PC? For example (though I know this is not the case), I would be disappointed if, after buying one, I learned that the Raspberry Pi lacked hardware support for implementing virtual memory. I'm not much of a HW guy right now - so I don't know all the right HW features I should be looking for?

1
1

I would think developing an OS kernel would be most convenient on a simulator (see last paragraph) rather than a real computer. That said, this page seems like a nice brief introduction to the BCM2835 SoC that drives the pi.

The Raspberry Pi seems attractive as an entry level system to develop on. However, I am worried that this system may not be a good enough approximation to a modern computer.

I don't think it would be particularly different than a regular x86 machine (it is a "modern computer"), except, as you point out, it is single core. Although it is not so long ago most desktops were too.

The linux kernel predominantly used on the pi does not appear to be significantly modified beyond adaptation to the hardware, and the userland is completely standard. So that's a modern, multi-tasking, multi-user, multi-executing (except, again, there's actually only one core in this case), general purpose OS, the source code for which is freely available.

In short, I don't think there's anything special about the pi with regard to this purpose, either in the sense that it would be especially good or especially bad.

However, one thing to keep in mind is that if you want to compile on the pi, it's slow. Way, way slower than a decent desktop. Cross-compiling is not a problem, but if for some reason you want to use a simulator, your choices are going to be limited because it is an uncommon architecture (although a lot of older android devices, including the original Samsung Galaxy, are armv6). On the other hand, "limited" doesn't mean non-existent, since QEMU apparently has a -cpu arm1176 option.

hardware support for implementing virtual memory

You could probably implement virtual memory with or without hardware support, but in any case, the processor has an integrated MMU, etc. to make things easier and/or more efficient.

I think the major advantage to using the pi here would be that it is small and cheap. If you wanted to do the work on one machine (a desktop or laptop) and apply it on another, which would probably make things easier, not using a full size system for the latter would be convenient. You could take this project to a coffee shop easily, etc. Of course, it's probably even more practical to just use a simulator in the first place, in which case you might as well write for x86.

0

Yes, creating your own OS on the Pi would be very similar to a real computer. In university I took two courses which involved creating an OS, one one a simulated MIPS-based environment, and another on an ARM-based product not very different from a Pi. In my spare time, I'm actually working on creating my own real-time kernel for the Pi (I have a B+ myself).

Some great benefits to Pi that will actually make life easier for creating an OS from scratch:

If you've never made an OS before, you'll be thankful for all these things. In terms of much of the high-level design, the difference between single-core and multi-core is small, however there are plenty of gotchas that would be painful for beginners and experts alike. In no way is developing on a single-core a drawback to learning.

As far as your question about the hardware itself, the B+ model has graphics, audio, 4 USB ports, Ethernet, physical storage, and of course a bunch of GPIO pins. What more could you want?

One drawback to the Pi in terms of being close to a typical desktop computer is the processor. The Pi is ARM-based, which most desktops are x86. Realistically, this only matters for the hand-written assembly bits of the kernel, such as the context switch. The rest you will likely write in C, which is portable to other architectures.

By the way, I would personally recommend against using a simulator for OS development. They are slow as slow can be. The other answer here that discusses this points out that compiling on the Pi is slow. This is also true. You are best suited to cross-compile on a fast desktop machine, and copy your kernel.img over to the SSD.

Good luck, and have fun.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.