Hacker News new | past | comments | ask | show | jobs | submit login
NetBSD Code Study (silas.net.br)
88 points by jayp1418 on June 16, 2020 | hide | past | favorite | 38 comments



Author here. Thanks for posting this. This is something I wanted to continue. The plan is still discussing NetBSD source code, as much as I can. Reading NetBSD code is a great way to learn operating systems! :-)


Imo NetBSD source code is much cleaner than some of the equivalent FreeBSD code. I just wish the NetBSD documentation was on par.


I like the idea.

Few years ago there was an similar thing but with OpenBSD code. There is a IRC channel on Freenode who a group of people go through OpenBSD code like "doas" and stuff.

I follow your future articles :)


Can you share the link for OpenBSD?


Hi, I'm the guy who did the OpenBSD code reads.

The daily started in June 2017 we kept up doing it daily for 42 days straight. In total there were 47 code reads.

http://blog.tintagel.pl/2017/06/09/openbsd-daily.html

http://blog.tintagel.pl/2017/09/10/openbsd-daily-recap.html


Thank you.


Thanks for article .. looking forward to seeing more code reading.


I always found it noteworthy in that the designers of Microsoft Windows did not consider co-existance with other OS on the same computer, i.e., "dual-booting". When I install NetBSD I never have to worry about it clobbering any code needed by other OS to boot. Not sure about today, but years ago Windows used to require being installed in the first bootable partition. If some other OS code occupied that position it was clobbered. On the other hand, the designers of NetBSD seem to have considered the possible co-existence with other OS on the same computer. To me, that is great design. NetBSD has this author's favorite bootloaders and I consider their kernels more flexible to boot than Linux kernels. I do not use grub. NetBSD has long supported the 1995 multiboot specification. Years ago, Linux did not. Perhaps that has changed. It always seemed like there were only a limited number of bootloaders that could boot Linux.


Because historically hardware was tied to the OS, UNIX is the only OS that took the route of making the underlying hardware meaningless.

It is also the main reason why NeXT and Sun NeWS are the only UNIX forks that ever provided a good desktop experience.


Are we not including macOS in this? Still the best UNIX desktop experience, IMHO.


I think MacOS == NeXT for the purpose of this discussion.


Indeed, that was my point.


Does the "server experience" count? I have never been sold on the "desktop" abstraction. I prefer to administer the computer through the command line. I guess that is why I like NetBSD. I do not see "OS" and "desktop" as synonymous or mutually inclusive.


I guess, if one wants to pretend to have a PDP-11 closet.


You mean, a huge painted cardboard mockup with a Raspberry Pi inside?


> If some other OS code occupied that position it was clobbered.

why bother with embrace, extend, extinguish if you can just skip to extinguish? :)


They sorta did then sorta skipped everyone else. The real requirement was that their bootloader was in the first partition. You can install windows to a different drive/folder. It would probably mess with a lot of programs out there though. The later versions (past 2000 I think, maybe xp its been awhile) did not really give you the option to put it somewhere else.

https://docs.microsoft.com/en-us/windows-hardware/drivers/de...

The problem is they only really made it work correctly with OS2, WindowsNT, Win9x, and DOS. Even then it was kind of a pain to make it work correctly.

Have not messed with the UEFI bits they added in recent versions so it may be different now. But I doubt it.


[flagged]


Did not realize I had to do full on research before posting on everything? My point if you had read it would be boot.ini allows multi boot in particular cases. I am not sure on the UEFI bits as I do not really multi boot anymore. I am sure it is great or miserable. I just personally have little need to do it anymore as VM's tend to solve the particular issues I ran into. Did your browbeating me bring much to the discussion? Why did you bother to comment other than to mock me? Am I understanding YOU correctly?


> I always found it noteworthy in that the designers of Microsoft Windows did not consider co-existance with other OS on the same computer

More likely, given that the desktop OS monopoly was well in place when Windows (as an OS, rather than the graphical framework that rode on top of DOS as a separate product, so especially the NT lineage) was designed, and coexistence actively weakened that, coexistence was considered and considered incompatible with Microsoft’s strategic objectives. Forcing a choice between Windows or something else rather than Windows and something else was good for MS.


"Forcing a choice between Windows or something else rather than Windows and something else was good for MS."

That was always the feel I got from Microsoft. They do what is good for Microsoft. I do not get that sort of feel using NetBSD.

What is good for Microsoft is not necessarily good for me.



This is why Microsoft was and is the devil. We must never forget Netscape, Be, constant virus attacks, and the bad old days when Internet Explorer was the dominant web browser which they allowed to rot like a garbage can full of shit. To use or develop with any Microsoft products today, or to work there or own their stock, is to agree with all of these terrible things.


Thankfully Bill Gates has moved on to Vaccines.


And that interest arose only because his spouse is so interested in Africa.


Support for multiboot was added to the NetBSD bootloader so that it could boot Xen, I didn't consider whether it should be able to boot Linux or test that.

If it can boot Linux as well then that is good to know.


Not sure about booting Linux. Some Linux bootloaders cannot boot NetBSD, e.g., syslinux. The FreeBSD bootloader, which is multiboot compliant, can boot NetBSD. At least this was the case years ago. Pardon me if I am ascribing intent to what is merely fortuitous.


>designers of Microsoft Windows did not consider co-existance with other OS on the same computer

Why would they? According to Microsoft and many third-party developers who don't know any better, PC and Windows are the same thing.

It's way less painful these days if you're using UEFI. No thanks to MS though.


From what I have read I suspect this may have been an intentionally created incompatibility. They wanted dual boot to be inconvenient. As a user, that is not the sort of design I want.


Dual boot has always been relatively easy among PC OS via Boot.ini, in what concerns Windows and OS/2, the OSes originally thought for PCs.

It is not as Apple, Atari or Commodore provided dual boot alternatives as well, and Boot Camp was more a result from survival than anything else.


But if the user prefers some other bootloader instead of Microsoft's or Apple's, then all bets are off. The idea of the "primary" OS being something other than Microsoft's or Apple's is not contemplated. For me, the non-GUI OS is the primary OS and the GUI OS is something kept around out of necessity, only used occasionally.


For that there are pizza boxes.


For me, I prefer NetBSD on computers of all shapes and sizes.


> It's way less painful these days if you're using UEFI.

Interesting. My experience has been the opposite; I've had much more issues with UEFI than I ever had using BIOS, even when after disabling Secure Boot in the settings.


That must have been really long time ago, I remember having no problem dual-booting XP with linux.


Did you install XP first or Linux?

The prescribed order was to install XP and then Linux on a different device/partition. Linux would install Grub or LILO in MBR with dual boot options.

Hence, the easy way to clean up Grub or LILO was to boot into DOS from a CD or floppy and run ‘fdisk /mbr’


Oh, this is very nice:) One question: Why does this page open with a link to FreeBSD docs? (Just general information on x86 boot process? Is this code similar/shared between the BSD family members?)


Yes, this is just general information on x86 boot process, but it shares some things with NetBSD boot process, specially how the boot is divided in phases.

When I first started this doc, it was just personal writing, because of that some links are scattered and there are TODO entries laying around. I'll fix that one day :-)


Well done. It gives me inspiration to go through other codebases (Rust compiler, Go compiler, .NET Roslyn, ...)




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: