I really like the new HN. Quality of articles is way up.
I've found myself spending a lot more time here as well. Was there any code/policy change with the HN site? Or is this new moderators jumping in and helping out a lot? Either way, I agree that it is excellent.
Kernel 101 – Let’s write a Kernel
31–40 of 104 posts
Re: Kernel 101 – Let’s write a Kernel
#32Earlier quoted context omitted.
I'm going to give OP the benefit of the doubt on this one. A couple things worth noting, it successfully boots, does not cause a fault of any kind, and is in a position to interact directly with the bare metal. The tools that we use to interact with a *nix system are often just that, bits of code in user-space. This is a kernel-space program. That it does not do any of the memory management or device access yet doesn…
Come on, no. It is not a kernel. It's a program that runs "on bare metal". Let me define what a piece of code needs to do to be a "kernel": it needs to manage some resources to allow other programs to run using those resources. E.g. memory, cpu time, I/O peripherals etc. You know a kernel when you see one.
Re: Kernel 101 – Let’s write a Kernel
#33In particular, setting up interrupt handlers, paging, and getting a PIC setup is pretty neat.
Re: Kernel 101 – Let’s write a Kernel
#34Re: Kernel 101 – Let’s write a Kernel
#35Why C? I'm just curious if another language can be used. (c++, go, rust).
If you get to that point, then you have the fact that the C ABI is fairly standard, extremely easy to use, and well-known, so it makes it easy to intermingle assembly and C. If you did it in C++, you'd definitely want to extern "C" any symbol asm is going to call so it isn't mangled, Rust should be the same, no idea on Go (You'd really also want to extern "C" any user-space system calls, because the name mangling might get in the way.). For the last point, you have to be able to use pointers and write to arbitrary memory locations, which is easy for C and C++, possible in Rust, but I don't know about Go.
IMO, the code displayed in this example is really hardly a kernel (It is, but it doesn't really do anything). For a more complex kernel, you may get a benefit from using a language other then C, but for something this simple C lowers the complexity to get a working example with minimal issues going.
Re: Kernel 101 – Let’s write a Kernel
#36Why C? I'm just curious if another language can be used. (c++, go, rust).
Re: Kernel 101 – Let’s write a Kernel
#37Earlier quoted context omitted.
If someone here has gone to college, then they'll know what 101 means - course numbering.
The courses that I've taken that were very basic and introductory was named 100. The next one was perhaps 101. Introductory courses in more specialized courses often had numbers signifying which research group they belonged to, with a low number at the end. Practices vary, even at my own university. I'm guessing that 101 specifically is an americanism.
Re: Kernel 101 – Let’s write a Kernel
#38If anybody is doing this, let me share some words of advice based on experience. Please use a virtual machine instead of doing this on your primary machine. You eliminate the risk of messing up your machine. Also, if you setup the VM properly, you get a debugger.
Re: Kernel 101 – Let’s write a Kernel
#39Earlier quoted context omitted.
Come on, no. It is not a kernel. It's a program that runs "on bare metal". Let me define what a piece of code needs to do to be a "kernel": it needs to manage some resources to allow other programs to run using those resources. E.g. memory, cpu time, I/O peripherals etc. You know a kernel when you see one.
A kernel is a program that runs "on bare metal". This program is equivalent to hello world for kernels - it's the simplest possible one. It is called "Kernel 101", after all.
"With the aid of the firmware and device drivers, the kernel provides the most basic level of control over all of the computer's hardware devices. It manages memory access for programs in the RAM, it determines which programs get access to which hardware resources, it sets up or resets the CPU's operating states for optimal operation at all times, and it organizes the data for long-term non-volatile storage with file systems on such media as disks, tapes, flash memory, etc."[1]
A program that prints "hello world" doesn't come close to meeting that description.
Re: Kernel 101 – Let’s write a Kernel
#40Earlier quoted context omitted.
I've found myself spending a lot more time here as well. Was there any code/policy change with the HN site? Or is this new moderators jumping in and helping out a lot? Either way, I agree that it is excellent.
About a week or two ago pg added moderation. I cannot find the thread right now, but basically comments are not published until someone with high enough karma (I think 1000 points) approves the comment.