Hacker Newsnew | past | comments | ask | show | jobs | submit | ffwff's commentslogin

With enough macros you can even bring high-level programming to C a la libcello: http://libcello.org/


Love the fact that people are developing kernels in new languages!


Sorry for the late reply (being rate limited)

Thanks! Originally it only started as an experiment to see how far I could go making an OS in a high-level (higher than C at least) language, I was only planning to build a monotasking DOS system. Around this time, Andreas Kling started to show us his SerenityOS, which was one of the factors propelling me to reach this point. So shout outs to AK!

Yeah! It's pretty fun to develop an OS, albeit time consuming. You should check out the osdev wiki and the Intel/Seagate manuals, they should hopefully get you to the point where your OS can read/write/execute files, you should also take a look at how other kernels do things as a reference and actually implement them in your OS in a way that fits.


Sorry that your account was being rate-limited. It's software filters that do that, based on past activity by trolls. Unfortunately it also sometimes prevents project creators from showing up to discuss their work. I hate that!

We've marked your account legit so this won't happen again.


Oh, I have dabbled in OS dev a tad already actually, although not in a long time. I think if I went for OS dev nowadays, I’d prefer to try and start as an EFI binary because I believe that way you get to start directly in long mode, and have some filesystem drivers to bootstrap with at least. Still, I don’t know if I will ever have the drive (and spare time) to push it as far as you have gotten Lilith.


When does GC kick in during the boot sequence? And how are you managing memory? Is the whole OS mark and sweeped?


Right after the global descriptor table is setup and paging is enabled, the GC is then enabled. On every allocation, and whenever the os has no task available to switch to, a gc cycle is performed.

Not really, the kernel and any process written in crystal has a garbage collector, any other userspace process can manage memory however they want to.


Hey ffwff, amazing work and pace on Lilith so far! I'm honored to have inspired you :)


How much experience do you have in OS dev before you jumped into this project?


I wonder what a D OS would be like.



Latest commit bcb6cf9 on Mar 2


The plot thickens.


Out of the box, Crystal does garbage collection through the boehmgc library, however if you pass in some compiler flags you can get application to not use GC.

As for my OS, I wasn't gonna port libgc, and since I have prior knowledge of building a GC in rust (very badly!) I decided to make a tri-color concurrent, mostly precise (through compiler patches), garbage collector, in Crystal.


Have you read Mike Pall's proposal for a quad-color collector in LuaJIT?[0] That you took this approach leads me to think you'd find it interesting.

[0]: http://wiki.luajit.org/New-Garbage-Collector


I've read up on how luajit does garbage collection (in fact the current gc/allocator with allocation/marking bitmaps is inspired by his tri-color gc. Apart from specifying when the GC should run, I won't be changing anything about the core gc algorithm used in the project anytime soon.


Cool coincidence but nah. Maybe its a reference to the first angel in Evangelion? Maybe its a reference to Adam's wife? Maybe its best girl from Machikado Mazoku?

Hint: asuka best girl.


POSIX-like, not entirely POSIX! There are basic IO syscalls, and some process management calls, but overall I try to take unix as a guideline rather than trying to reimplement one entirely. I also try to take inspiration from other kernels (like fattr (which is equivalent to GetFileAttributes from WinNT), and spawnv from DOS/WinNT).

I guess I should reword it :/


Google's Fuchsia has a similar approach to Posix (no fork, signals, etc). Maybe some of their wording would be of use?

https://fuchsia.googlesource.com/docs/+/refs/changes/56/1013...


That's fair. And to be clear, reading "POSIX-like" makes me expect it to act like a unix, but that hardly means that you should be bound to follow that exactly:) If you wanted to set expectations a bit, maybe "partially POSIX-inspired, with other influences from $FOO and $BAR" would be clearer?


Oh wow someone actually posted this! Thanks a lot for the comments and criticisms guys, really means lot to me. Before I go I'll answer some questions, so ask them away!


I’ll echo what everyone else said - SUPER IMPRESSIVE and awe-inspiring work. Thanks for sharing it with the world.

I have one question: While I can read and understand each individual line of code you wrote (go Crystal!) and what each method does, etc., I’m at a total loss for how you knew what and how to build - big picture wise. Can you share a bit about your process for building the mental model of this? How do you know where to start, what modules to build, what’s needed / what’s already there, etc? What roadmap (if any) are you using?

I’m just amazed at how something like this comes together and would love to learn a bit more about the process a single dev uses to build it.

Thanks in advance!


You can checkout what I replied to jchw. But tldr, wanted to do DOS => got ambitious => made it multitasking => got more ambitious => added graphics and guis.

Currently it's pretty barren driver-wise, I currently have a FAT16 driver, a keyboard/mouse driver, some basic code to handle core architecture hardware and that's it. I really want to have CDROM support, a network driver (ne2k or e1000), an audio driver (sound blaster?) and an actual file system.

My roadmap is go with the flow. If I want a text editor, I'll focus on building a text editor. If I want to play doom I'll port doom (but I dont so I won't :^)


How/when did you get started with coding? How did you learn your skills and how do you stay so productive?


I second this, please, oh lord, tell us!


I just wanted to say, to build such a fully-featured OS on your own, and in such a short time frame, is an incredible achievement!

I very much look forward to reading through the code and learning more about it.


Thanks but the code isn't that clean, there are hacks here and there and it isn't organized as clearly as I wanted to but feel free to look through it.


> the code isn't that clean

It's cleaner than a solid 90% of the code I've read over the years :)


I guess Crystal itself deserve some credit as well :)


Hah, come on, to me you seem like a humble Linus Torvalds!


- What are the things that you have patched in crystal and libc?

- Any plan to release ISO for us to quickly run it in our local system?


Precise GC information, the crystal compiler prepends a dword/qword value indicating an class' typeid upon allocation. I decided to patch the compiler to generate 2 functions, one that outputs the class' size based on a typeid, another one that outputs the offsets of each pointer in that class as a bitmap, based on a typeid.

The compiler also generates a null-terminated array of pointers pointing to the offsets of global variables.

No iso images yet, I haven't implemented iso9660 filesystem support, but it's coming soon?


1. Would you consider this project "mature", or still rapidly evolving? Any particular aspects you are actively working on?

2. Any other project ideas you are toying around with?

Kudos and cheers!


Favorite anime?


How old are you?


shhh.


From digging trough his blog, looks like 16-19


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: