Writing a toy kernel in Go

2,200 views
Skip to first unread message

eksp...@gmail.com

unread,
May 12, 2011, 6:53:18 PM5/12/11
to golan...@googlegroups.com
I'm planning to do this project over summer for my own education about operating systems and Go internals.

I'd like to know if I can get the kernel running in similar way as http://wiki.osdev.org/Bare_bones or is the runtime required even if I didn't use goroutines and such yet?

Feel free to tell me anything I be aware of.

Evan Shaw

unread,
May 12, 2011, 7:28:23 PM5/12/11
to golan...@googlegroups.com
On Fri, May 13, 2011 at 10:53 AM, <eksp...@gmail.com> wrote:
> I'd like to know if I can get the kernel running in similar way
> as http://wiki.osdev.org/Bare_bones or is the runtime required even if I
> didn't use goroutines and such yet?
> Feel free to tell me anything I be aware of.

You'd be giving up a lot by dropping the runtime. Off the top of my head:

* maps
* many slice operations
* string conversions between []int, []byte, and integer types
* goroutines
* channels
* defer
* many/all interface features
* garbage collection/allocation
* most built-in functions

It should be possible to keep the OS-independent parts and implement
something minimal in order to keep allocation and garbage collection.
You might want to do something for the print functions too. You can
probably live without the rest.

- Evan

eksp...@gmail.com

unread,
May 12, 2011, 7:43:13 PM5/12/11
to golan...@googlegroups.com
I totally forgot I will lose defer, maps and others. I'll just try to implement the runtime. :)

Arlen Cuss

unread,
May 12, 2011, 7:56:46 PM5/12/11
to golan...@googlegroups.com
On Thu, 2011-05-12 at 15:53 -0700, eksp...@gmail.com wrote:
> I'm planning to do this project over summer for my own education about
> operating systems and Go internals.

That sounds like a lot of fun! Are you intending to do this as a
personal thing, or possibly open-source? I'd be interested in watching,
at the very least!

--
Arlen Cuss
Software Engineer

Phone: +61 3 9877 9921
Email: ar...@noblesamurai.com

Noble Samurai Pty Ltd
Level 1, 234 Whitehorse Rd
Nunawading, Victoria, 3131, Australia

noblesamurai.com | arlen.co

signature.asc

eksp...@gmail.com

unread,
May 12, 2011, 7:59:44 PM5/12/11
to golan...@googlegroups.com
I don't see any reason to not release it open sourced but I'm doing that only after I actually get some code running.

Arlen Cuss

unread,
May 12, 2011, 8:06:12 PM5/12/11
to golan...@googlegroups.com
On Thu, 2011-05-12 at 16:59 -0700, eksp...@gmail.com wrote:
> I don't see any reason to not release it open sourced but I'm doing
> that only after I actually get some code running.

That indeed is a pity ;-) Anyway, let us know when you do release it!

signature.asc

Russ Cox

unread,
May 12, 2011, 10:37:53 PM5/12/11
to Arlen Cuss, golan...@googlegroups.com
In the repository history there is a toy kernel called "tiny".
If you run hg log -k tiny you'll find it. It doesn't build anymore
with the current version of Go but it illustrates what might
be done. It had the whole package runtime, including the
garbage collector, in the kernel.

Russ

Paulo Pinto

unread,
May 13, 2011, 4:30:20 AM5/13/11
to golang-nuts
I would not give up on the runtime.

Please research a bit the Oberon project and Spin. Both used
safe languages with GC that compiled to native code, Oberon and
Modula-3
repectively. Well some versions of Oberon use a kind of bytecode for
the executable representation
I think, but the code is compiled to native when the modules are
loaded.

Not sure if I am right on this, it has been a long time (years) since
I don't play with
Oberon.

Anyway, here are some links you might want to look into,

http://www.oberon.ethz.ch/
http://www-old.oberon.ethz.ch/compiler/index.html
http://www.oberon.ethz.ch/bibliography/publications (Have a look at
the PDF books)

http://www-spin.cs.washington.edu/external/overview.html

Good luck with your project.
Paulo



On May 13, 1:28 am, Evan Shaw <eds...@gmail.com> wrote:

Uriel

unread,
May 13, 2011, 4:32:34 AM5/13/11
to Arlen Cuss, golan...@googlegroups.com
See also the 'tinygo' project, that is an updated and expanded version
of the code that was part of the Go tree:

http://code.google.com/p/tinygo/

And for another (currently dormant) experiment on writing a kernel in
Go see GoFY:

http://code.google.com/p/gofy/source/browse/

uriel

Reply all
Reply to author
Forward
0 new messages