UML equivalent for one of the BSDs? - virtualization

On Linux there exists a thing called a User Mode Linux kernel, which is a kernel built in such a way that it will run as an ordinary, unprivileged user process (not even needing root). It's a cheap and easy virtualisation method that'll even run on non-Linux platforms (e.g. CoPilot is based around UML built for Windows).
Does such a thing exist for the BSD world? I don't mind which OS.
I've had a look myself but 'user mode bsd' is a completely ungoogleable term. I've discovered NetBSD rump kernels, but they seem to be solving a different problem --- it looks like it's not possible to run arbitrary process trees on them.

I think DragonFly BSD's vkernel is what you are looking for.

NetBSD has usermode too. I don't know how to configure/build it.
Look :
http://mail-index.netbsd.org/current-users/2015/02/06/msg026632.html

The best true virtualisation tool in the NetBSD world is Xen.
It's not all that difficult to set up any more either. Don't get put off by the length and volume of information in the "how-to" -- the basics boil down to a few simple steps.
NetBSD/xen HowTo
In the FreeBSD world I've heard good things about The BSD Hypervisor
DragonFly BSD's vkernel is indeed similar to User-Mode-Linux, but from what I've heard it wouldn't be very suitable as a "cheap and easy" virtualisation method. It is actually intended for the same types of uses as NetBSD's rump kernels, though it does seem to go so far as supporting a full virtual OS environment. The performance will likely be pitiful though.
It probably wouldn't hurt to pester the VirtualBox folks about supporting VBox as an application on the BSDs too, but don't hold your breath waiting for it to happen.

On FreeBSD you have jails. They basically are a (almost) no-overhead virtual machine running on the same kernel as the host.

Related

is freedos is better than windows?

I would like to know if freedos is better than windows or not, and why, I mean in terms of operability and development capacity using one or the other.
And finally which onw would you use and why.
Thanks for your support,
John.
This mainly would depend on what you're goal is for your operating system. If you're goal is to play some classic games or run legacy software, sure you would probably appreciate FreeDOS, as for anything else... Windows definitely wins out. In terms of development, Windows has a lot more active community and you will likely find more tools and resources on it. If you are looking for an similar open source OS, consider looking into Linux or even Kali Linux if you are familiar with that. The command line utility with those type of operating systems have a lot more flexibility and isn't as limited as FreeDOS.
So overall, Windows definitely wins out in terms of ease-of-use and development capacity.

What is the best way to start programming with Real Time Linux?

Although I have implemented many projects in C, I am completely new to operating systems. I tried real time linux on Discovery board (STM32) and got the correct results for blinking LED but I didn't really understand the whole process since I just followed the steps and could not find whole description for each step on the internet.
I want to implement scheduling on real time linux. What is the best way to start? Any sites, books, tutorials available?
Complete RTLinux process description will be appreciated.
Thanks in adv.
The transition from "bare metal" to OS based programming is something that I experienced in reverse. I started out a complete software guy, totally into the OS side of things and over time I have moved to the opposite of that (even designing circuits in VHDL!). My advice would be to start simple. Linux is pretty complex, and everywhere you look there are many layers of things all working together to deliver the final product. If you are dead set on a real time linux extension, I'd be happy to suggest https://xenomai.org/ which is a real time extension for linux.
However, to more specifically address your question about implementing scheduling in Linux, you can, but it will be a large amount of work and can be very complicated. The OS uses a completely fair scheduling process ( http://en.wikipedia.org/wiki/Completely_Fair_Scheduler ) and whenever you spin up a thread, it simply gets added to the list to run. This can differ slightly if you implement your code in kernel space as a driver, rely on hardware interrupts, etc., but in general, this is how Linux works. Real time generally means that it has the ability to assign threads one of several different priorities and utilize thread preemption fully at any given time which are concepts that aren't really a part of vanilla Linux. It has some notion of this, but it has limitations that can cause problems when you are looking for real time behavior from Linux.
What may be helpful to you is an RTOS. If you are looking for a full on Real Time Operating System, check out FreeRTOS http://www.freertos.org/ . It has a large community and supports a lot of different devices out of the box with a large amount of example code. They even support your specific board with an example package, so you can give it a shot with nothing to lose! http://www.freertos.org/FreeRTOS-for-Cortex-M3-STM32-STM32F100-Discovery.html . It gives you access to many OS ish constructs like network APIs, memory management, and threading without the overhead and latency of a huge OS. With an RTOS, you create tasks and assign them priorities so you become the scheduler and are no longer at the mercy of the OS. You run the OS, not the OS runs you (if that makes sense). Plus, the constructs offered within an RTOS will feel much like bare metal code and thus will be much easier to follow, understand, and fully learn. It is a more simple world to learn the base building blocks of a full blown OS such as Linux or Windows. If this option sounds good, I would suggest looking through the supported devices on FreeRTOS website and picking one you would like to experiment with and then go for it. I would highly recommend this as a way to learn about scheduling and OS constructs in general as it is as simple as you can get and open source. Once you have the basics of an RTOS down, buying a book about Linux specifically wouldn't be a bad idea. Although there are many free resources on the web related to learning about Linux, they are commonly contradictory, and can be misleading. Pile on learning Linux specific knowledge along with OS in general, and it can feel overwhelming. Starting simpler will help keep you from getting burnt out and minimize the amount of time you spend feeling lost. Linux is definitely a learning process, but like with any learning process, start simple, keep your ultimate goal in mind, make a plan, and take small, manageable steps along that plan until you look up and find yourself exactly where you want to be. Then go tackle the next mountain!
The real-time Linux landscape is quite confusing. 99.99% of the information out there is just plain obsolete.
First, there are lots of "microkernels" that run Linux as one task. (Such as the defunct RTLinux). The problem is that you must write your real-time task to a different API, and can't depend on anything in Linux, because Linux will be frozen in the background while your task runs. So unless your task is dead-simple ("stop the motors when I press this button"), this approach will cause more pain than gain.
Next, there is the realtime Linux patch set. This hasn't been doing so well. because of the next item:
Lastly, the current Linux kernel has gotten rid of the problems that caused people to need realtime in the past. You can even turn off Linux on one of your processors to have full control of the CPU. See also this paper.
To answer your question: I see two different paths you could take:
1) Start with a normal 3.xx Linux kernel and explore the various APIs and realtime techniques (i.e. realtime priorities, memory pinning, etc.) This can get you "close enough" for 99% of what people want "realtime" for. If it's good enough for high frequency trading, it's probably good enough for you.
2) If you have a hard realtime requirement and you are worried that Linux won't cut it, then (as Nick mentioned above), just go buy a processor and write your realtime code with no OS. By splitting up your "realtime" and "non-realtime" code onto different CPUs, you will make the whole system simpler and much more robust.
If you want to learn real-time operating systems then I suggest that you get an FPGA, for example the Altera DE2, and experiment with your own operating system and ucos. You can read a good text about embedded RTOS here.
You could also get a Linux Raspberry and write your own operating system for that.

what should i study to get an indepth understanding of operating systems

I have been programming in java for 3 years but I have no experience with other languages. I want to know what I need to study in order to be able to make an operating system. Am most likely going to make my operating system based on Linux kernel. What programming languages should I be familiar with and what aspects of the pc hardware should I study. if you know any online tutorials or good books please mention them.
The answer depends on how far you want to go and how much you want to write yourself vs using existing code.
The most straightforward way is to have a look at Arch Linux or Gentoo and build your own, custom Linux setup. Approximate time needed to create a minimal working system: ~2 hours
You could, otherwise, compile the Linux kernel, build some software packages and put it all together yourself and create your own Linux distro - i.e your own operating system in a sense. Linux From Scratch will be an invaluable resource if this is what you decide to do. Approximate time needed to create a minimal working system: ~2-5 days
Say that's too easy for you but you're not ready to delve into the nitty-gritty of kernel development. You can write your own applications that run on top of the Linux kernel. Typically, you'd need to know C/C++ but any language that supports running on Linux/compiling to a Linux executable will work. Heck, you could chuck a (or write your own) Java runtime on and write your whole 'operating system'/user-space in Java. Approximate time needed to create a minimal working system: ~6-12 months
What about if you want to get down to programming your own kernel from scratch? Heck, Linux is overrated and you want to write your own kernel and it's going to be the next best thing! You would want to learn a bit about the platform you're developing on. At the very least, you'll need to know the assembly instructions of some special operations for your platform that can't be done natively in C like switching CPU modes. You'll definitely need to read up on the OS dev wiki for this and you should have a fair decent computer science background.
At this point, you shouldn't need too much other than a good tutorial, C, a little assembly, reference manuals for the hardware you're hoping to support and 3+ years of computer science background to get you started. Your boot loader that's booting your kernel should handle most of the hardware initialisation. Bootloaders like GRUB (I'm assuming you're developing on a x86 system) does so much for you that it can probably just jump to your kernel main function straight away without you having to do too much. Again, if you wanted, you could port or write your own Java runtime in C and write the rest of your kernel in Java! Approximate time needed to create a minimal working system: ~3-5 years
But, let's just say you're screaming for more pain and you want to write an operating system really from scratch and you don't want no bootloader doing a lot of the legwork. What do you need? Firstly, you'll need a lot more reference manuals. And you'll need to read up on a lot more assembly. Especially for Intel processors, there's a lot of work involved bringing the system up from 16bit mode to 32/64bit protected mode with paging (which is what I assume you want). You'll also want to know about every tiny quirk and weirdness of your platform that will affect your OS (these are often not documented; hooray!). Plus, all of the above. In short, you will need to study everything. Approximate time needed to create a minimal working system: 5+ years
Of course, this post is just scraping the surface of what is needed to even bring up a basic operating system capable of say, opening a web browser. The approximates roughly assumes a minimal working system is something capable of running a graphical web browser and will vary depending on how much you want to write.
I don't mean to be condescending but this is the kind of reality you'll be facing if you decide to write your own operating system. Nevertheless, it is a valuable learning experience if you can break the initial barrier or even just trying to set up your own Linux system.
First, I would say that you install any Linux OS on your system and get accustomed with it.
Second, for OS development you have to know C language. As for the Assembly language, it depends from where you start the OS development. If you will be using available bootloaders, then I don't think that you will be requiring to learn assembly language.
This is a website on OS development: http://wiki.osdev.org/Main_Page
There you will find all the stuff you need to know for the OS development. And also how to develop OS step-by-step.
Now-a-days, a "Eudyptula Challenge" is going on. It is a series of programming exercise for the linux kernel. You can find more info here: http://eudyptula-challenge.org/

What does it take to write a virtualization host?

I'm not planning on doing this right now, as I don't have the experience in this area to even attempt it at the moment, but I'm curious about something.
If implementing an operating system from scratch, what would it take to build an application like VirtualBox? Not necessarily as user friendly with a nice GUI or anything, but something that is capable of launching other operating systems and allowing you to interact with them?
I've got an idea rolling around in my head about an operating system that uses virtualization for a few key things (probably ideas out there like this already), and I'm just curious what it would take to build it.
There is a version of VirtualBox that is open source. If you want to know what it would take, checking out their source would be a very good start. Also, check out Xen (open source as well).

PostgreSQL OS suggestion

Hi guys we are on the way to start developing a big web platform. For db server we choosen postgresql. Would you suggest an OS for the postgresql server (we are looking for the maximum performance)?
Thanks
P.S. sorry for the bad english
I would suggest a platform that you feel comfortable with. As Jeff suggested, it is usually easier to throw faster hardware at a problem than human time.
This reasoning is based on theses main ideas :
Usually the database is only marginally faster given different OS.
The high order optimisations are usually in tuning the database or the requests. Not really in switching OS.
If you have more knowledge on a OS, you can take usually more juice out from it. Whereas if you take an OS that you are not really familiar with, but that is supposed to be faster, it might kick your back in unexpected ways.
That said, as answered before an *NIX-based OS would be better right now, since PostgreSQL has still deep roots in a *NIX world. But this is becoming less and less an issue with the 8.x line.
I would suggest *nix based, Linux would be great if it is possible because you can get the package easier with the built-in package manager (e.g apt for debian, yum for fedora, etc). Because Postgres is originally made for *nix based OS. The port to windows is only recently and as you can see on several threads here on Stackoverflow, Postgres does not perform as good on Windows as it is on *nix based OS.