News for hackers. Stuff that matters.
Re:Kernel 101 – Let’s write a Kernel by TehCorwiz on Monday April 14, 2014 @04:15PM (#7588584)
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't mean it's not a kernel.

It might actually be interesting to take these techniques and apply them to something else. Maybe a demo, ala the demoscene, that runs on the bare metal. Maybe implement a game that doesn't have the overhead of an os.

This is less a finished product and more an inspiration. So often I think that people miss that about things. Sometimes things aren't done, sometimes they're just beginning.

Re:Kernel 101 – Let’s write a Kernel by Nav_Panel on Monday April 14, 2014 @08:52PM (#7589753)
> Maybe implement a game that doesn't have the overhead of an os.

I'm in CMU's operating systems class right now and that was one of our projects (our second). The first was writing a stack-tracing debug library, the third was a user-space thread library built on top of a particular kernel spec, and then the fourth was to build a kernel basically from scratch, using our thread library as a test program.

Here's a link to the spec for the game we built on the bare metal: https://www.cs.cmu.edu/~410/p1/proj1.html

That fourth project, or "p3" as it's known around here, is known to be a killer. It's tough to write a whole kernel in 6 weeks (+ 1 week of break), especially when it's expected to have a full virtual memory system, kernel tasks/threads for concurrent programming, program loading, interrupt handling, etc, even with a partner.

Re:Kernel 101 – Let’s write a Kernel by TehCorwiz on Friday April 18, 2014 @03:21AM (#7608275)
Wow, that's pretty cool. Thanks for the link.
Re:Kernel 101 – Let’s write a Kernel by akiselev on Monday April 14, 2014 @06:02PM (#7589213)
http://en.wikipedia.org/wiki/Microkernel

This isn't even a microkernel. This would at best be an example of firmware on an Intel/AMD x86/x64 booted from Grub that prints to the console.

This code, however, doesn't do a single thing that other software expect even a microkernel to do (provide for basic scheduling, memory management if an MMU is available [which it is in this case], and IPC/FS).

Re:Kernel 101 – Let’s write a Kernel by steveklabnik on Monday April 14, 2014 @06:30PM (#7589300)
http://en.wikipedia.org/wiki/Exokernel <- if you're playing the 'how big is a kernel' game.
Re:Kernel 101 – Let’s write a Kernel by akiselev on Monday April 14, 2014 @06:40PM (#7589325)
Awesome link, thanks!

The key part of any kernel can be expressed from this Exokernel definition:

   Exokernels are tiny, since functionality is limited to ensuring protection and multiplexing of resources, which are vastly simpler than conventional microkernels' implementation of message passing and monolithic kernels' implementation of abstractions.
They have to, in some way shape or form, deal with conflicting requests for resources from their client applications (whether or not you have a concept of privileged or protected execution like on basic microcontrollers). I'd be curious to see how exokernels manage time unless each application implements its own scheduler and gives up control of execution.
Re:Kernel 101 – Let’s write a Kernel by steveklabnik on Monday April 14, 2014 @06:42PM (#7589332)
The generic answer to any question about exokernels is "In userspace."

It also applies here: There's generally a userspace scheduler which programs can register themselves with. Or they can implement their own.

Re:Kernel 101 – Let’s write a Kernel by nsxwolf on Monday April 14, 2014 @04:31PM (#7588696)
Reminds me of the old "booter" games on the PC that used their own kernel instead of MS DOS [1]

It would be fun to see how far one could go with modern hardware. Writing your own driver for a modern graphics card sounds absolutely terrifying (and fun).

[1] http://en.wikipedia.org/wiki/PC_booter

Re:Kernel 101 – Let’s write a Kernel by Intermernet on Tuesday April 15, 2014 @06:42AM (#7591146)
This one was awesome: http://en.wikipedia.org/wiki/Buck_Rogers:_Planet_of_Zoom#Pla...

CGA graphics(!), and pushed the monophonic speaker on a basic XT further than anything I'd seen at the time.

Unplayable on "turbo" mode :-)

Re:Kernel 101 – Let’s write a Kernel by nsxwolf on Tuesday April 15, 2014 @01:31PM (#7593102)
I have a version of that on cartridge for my TI-99/4A!
Re:Kernel 101 – Let’s write a Kernel by kyberias on Monday April 14, 2014 @05:06PM (#7588947)
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 by ertdfgcb on Monday April 14, 2014 @05:17PM (#7589023)
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.
Re:Kernel 101 – Let’s write a Kernel by greenyoda on Monday April 14, 2014 @05:30PM (#7589079)
A kernel may be a program that runs on bare metal, but not every program that runs on bare metal is a kernel.

"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.

[1] https://en.wikipedia.org/wiki/Operating_system#Kernel