News for hackers. Stuff that matters.
Re:Kernel 101 – Let’s write a Kernel by kyberias on Monday April 14, 2014 @04:07PM (#7588523)
I'm not exactly Linus Torvalds but I'm pretty sure a program that prints one line of text is not "a kernel". :)
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

Re:Kernel 101 – Let’s write a Kernel by slashdotaccount on Monday April 14, 2014 @04:21PM (#7588622)
If someone here has gone to college, then they'll know what 101 means - course numbering.
Re:Kernel 101 – Let’s write a Kernel by dragonwriter on Monday April 14, 2014 @06:14PM (#7589255)
> If someone here has gone to college, then they'll know what 101 means - course numbering.

At most colleges whose course numbering system I've seen, the kind of introductory course that the idiom "101" refers to would actually be "1"; at many of them, "101" would be an upper division class. Its an idiom that may have connected to some colleges' numbering system at some time, but it mostly exists independently now, and actually going to college doesn't actually make its intended meaning any more obvious.

Re:Kernel 101 – Let’s write a Kernel by kjs3 on Thursday April 17, 2014 @12:16AM (#7601975)
I went to 4 colleges, applied to a number of others (not all US based), taught at a few and am giving advice to friends kids now going to college. With minor variations (3-digit v 4-digit course numbers) I've never, ever seen a college course with a single digit course number. Or 2 digit. But then, I've never met an English speaker so culturally tone deaf that they would question the idiom "Foo 101" as being anything other than "intro to Foo".
Re:Kernel 101 – Let’s write a Kernel by Dewie on Monday April 14, 2014 @04:35PM (#7588741)
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 by beachstartup on Monday April 14, 2014 @05:25PM (#7589062)
from my experience almost no schools in america still use 101 as the introductory course. at this point, it's basically an idiomatic expression of american english.
Re:Kernel 101 – Let’s write a Kernel by lmm on Tuesday April 15, 2014 @04:48AM (#7590918)
Only in American.
Re:Kernel 101 – Let’s write a Kernel by rdc12 on Monday April 14, 2014 @08:17PM (#7589663)
And if you look at the comments on the post itself, you will see this "Hey, i am actually planning to write another post with addition of a keyboard driver among others. :)"

This post is just a small steping stone on the way to a kernel (assuming the poster continues)

Re:Kernel 101 – Let’s write a Kernel by aaron987 on Monday April 14, 2014 @07:00PM (#7589401)
It may or may not be "a kernel", but personally, I learned a lot from this one simple tutorial. As someone who normally plays with website code, even something this simple can be very helpful in understanding other areas of programming and how computers work.
Re:Kernel 101 – Let’s write a Kernel by kyberias on Tuesday April 15, 2014 @05:56AM (#7591057)
Let me rephrase. This is _bootstrap code_ for something that might someday be a kernel. It could also be bootstrap code for something else, a game perhaps. But right now it's nothing else.
Re:Kernel 101 – Let’s write a Kernel by bronson on Monday April 14, 2014 @04:39PM (#7588776)
That's how the Linux kernel started.

(technically it was two lines of text printing alternately to prove the scheduler worked, but close enough)

Re:Kernel 101 – Let’s write a Kernel by Rusky on Monday April 14, 2014 @08:51PM (#7589750)
Not that this article isn't cool and valuable, but the fact that it had a scheduler at all puts it light years ahead of this in being-a-kernel.
Re:Kernel 101 – Let’s write a Kernel by nwg on Monday April 14, 2014 @04:15PM (#7588583)
It is already a kernel, technically, right?
Re:Kernel 101 – Let’s write a Kernel by gkya on Tuesday April 15, 2014 @01:48AM (#7590468)
A kernel is a program that provides services to userland programs. I reckon printing "my first kernel" is hardly a service to any userland program.
Re:Kernel 101 – Let’s write a Kernel by bananas on Monday April 14, 2014 @04:12PM (#7588570)
Yet...