Using an existing kernel

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
G3bE
Posts: 3
Joined: Sat Jan 25, 2020 5:28 am

Using an existing kernel

Post by G3bE »

After creating a simple kernel (memory management, interrupts, keyboard, VGA) I've decided to follow this articles advice and use an existing kernel and 'just' create userspace programs. Obviously I need to settle for kernel which turns out to be quiet hard; making a Linux distro is really complicated due to the kernel being complex, MITs xv6 is rather old/the version actively developed is for RISC-V and it as well as a lot of projects on GitHub just don't give enough documentation on how to make userspace apps.

So: Do you guys have any recommendation for a monolithic kernel with easy userland app creation?
ajxs
Member
Member
Posts: 27
Joined: Mon Jun 13, 2016 2:25 am
Libera.chat IRC: ajxs
Location: Sydney

Re: Using an existing kernel

Post by ajxs »

When you say 'userspace programs' you must understand that this is an enormously broad category that is well beyond the scope of this forum.
If you actually mean contributing to the core development of an existing kernel, then you have plenty of good options. Linux and the various BSD's are a good place to start. These OS's are widely used in all areas of computing, and you would have the opportunity to make worthwhile contributions to a product that is used and enjoyed by real people. You don't need to create a new Linux distribution either. Depending on where your interests lie, you can contribute to core parts of Linux's userspace, such as GNU Coreutils or Binutils. Alternatively, there is plenty of work to be done on the kernel as well.
Alternatively, there are hobby operating systems that are receiving enormous amounts of community contribution such as Redox-OS. These developers seem to be looking for help developing their userspace.
There are almost endless possibilities for contributing developers.
mmdmine
Member
Member
Posts: 47
Joined: Sat Dec 28, 2019 5:19 am
Location: Iran
Contact:

Re: Using an existing kernel

Post by mmdmine »

I asked for it, the answer I got was "using syscalls". Alternatively you can write your init program on top of existing C Libraries like glibc or musl or fork them for your OS Project.
viewtopic.php?f=1&t=36399
G3bE
Posts: 3
Joined: Sat Jan 25, 2020 5:28 am

Re: Using an existing kernel

Post by G3bE »

@ajxs By saying 'userspace programs' I mean the whole userspace from the first program to be executed to the window manager. I mainly want to focus on the filesystem structure, but as a lot of programs rely on a certain structure, a lot of them have to be ported or rewritten. Basically I want a plain kernel that starts some program (e.g. /sbin/init) and that doesn't rely on any or just on a minimal filesystem structure.

@mmdmine Yea I've seen that, but the whole thread focuses on Linux, which I don't want to use since, like explained there, needs existing minimal userspace and as explained in my original post, is a really complex project.

Probably a good example of what I am looking for is https://github.com/16Bitt/virtix. It has a single directory for initial programs which are easy to edit but isn't an option since it has a lot of bugs and is quite incomplete.
Korona
Member
Member
Posts: 1000
Joined: Thu May 17, 2007 1:27 pm
Contact:

Re: Using an existing kernel

Post by Korona »

Linux is a complex kernel but it doesn't need a lot of complex userspace to work. Any complexity its userspace is offset by the vast amount of documentation for Linux. On the other hand, hobby OSes will almost (?) always lack extensive documentation.

For hobby OSes, you will always:
- Need to build cross compilers that target the OS
- Understand their syscall API and support libraries (which are usually undocumented)
- Understand how to integrate your programs into their build systems
- Deal with bugs and incomplete features that you encounter

If that doesn't discourage you, go ahead and pick any reasonably complete hobby OS -- but I wouldn't claim that its easier than understanding the minimal userspace that Linux needs.
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].
User avatar
eekee
Member
Member
Posts: 892
Joined: Mon May 22, 2017 5:56 am
Location: Kerbin
Discord: eekee
Contact:

Re: Using an existing kernel

Post by eekee »

I went part-way to this goal once, setting up existing but non-standard userspace for the Linux kernel. I had a problem with Linux refusing to remount / read-only, but everything else worked as far as it went. Don't know about designing for it. The list of Linux syscalls is very long, but I don't know how many a project like this would need.
G3bE wrote:So: Do you guys have any recommendation for a monolithic kernel with easy userland app creation?
OpenBSD is a mature kernel with very good documentation and a reputation for simplicity, but I don't know how its focus on security would impact your plans. Bitrig is a more relaxed fork, but development has stopped.

FreeBSD is also mature and very well-documented and its list of syscalls must be shorter than Linux's, but I don't have deep knowledge. I found UFS easy to set up for daily snapshotting and other features. ZFS is nicely documented too; much more so than anything half its complexity in Linux, in my experience.

Plan 9 from Bell Labs has a very short list of syscalls, but its documentation is a bit flakey; sometimes good, sometimes missing details. If you're comfortable reading its source code, which is somewhat obscure but very small, I'd say it's a good choice. Its authors strongly believed in simple interfaces. It's extraordinarily flexible about file location thanks to private namespaces and unrestricted mount and bind. You wouldn't need to start with an empty filesystem; you could write a short script to reorganize the tree to your taste. Your window system could nest within Plan 9's existing window system with little or no change to its kernel calls. All this could make early development easy, which is one reason I'm recommending it despite the documentation issue and its userspace filesystems. The disk filesystems only expect one file in a fixed place (and they could be patched): /adm/users for user & group data. It's only read & written by the filesystem programs themselves. Simple source but flakey documentation applies to CWFS. I think the Fossil+Venti filesystem setup is better documented, but has more complex source. You'll probably be best off running as "hostowner" to ease security issues; that's the worst-documented area. You'll want either 9legacy or 9front. 9front has received more maintenance but lacks Fossil. 9legacy is probably mature enough. For an example of an already-modified Plan 9, (although not modified as much as you intend,) see ANTS.
Kaph — a modular OS intended to be easy and fun to administer and code for.
"May wisdom, fun, and the greater good shine forth in all your work." — Leo Brodie
G3bE
Posts: 3
Joined: Sat Jan 25, 2020 5:28 am

Re: Using an existing kernel

Post by G3bE »

@eekee I took a look at all the kernels and I think 9front is just right for me. Thanks very much for the help.
User avatar
eekee
Member
Member
Posts: 892
Joined: Mon May 22, 2017 5:56 am
Location: Kerbin
Discord: eekee
Contact:

Re: Using an existing kernel

Post by eekee »

G3bE wrote:@eekee I took a look at all the kernels and I think 9front is just right for me. Thanks very much for the help.
Awesome! Have fun. :)
Kaph — a modular OS intended to be easy and fun to administer and code for.
"May wisdom, fun, and the greater good shine forth in all your work." — Leo Brodie
Post Reply