Linux kernel module in Go?

4,054 views
Skip to first unread message

Anant Narayanan

unread,
Feb 19, 2010, 1:23:09 PM2/19/10
to golang-nuts
Hi all,

I was wondering if it is possible to write a Linux kernel module using
Go. Has anyone tried this? I would imagine we would use cgo to
interface with the kernel, but I'm not sure how I'd go about building
such a module.

Any help/tips would be appreciated.

Thanks!
- Anant

kennetha...@gmail.com

unread,
Feb 20, 2015, 3:41:41 PM2/20/15
to golan...@googlegroups.com, an...@kix.in
This is interesting to me too. I'd like to generate kernel assembler with the go compiler; go is type safe, and it makes great use of concurrency.

Eric Johnson

unread,
Feb 23, 2015, 4:14:37 PM2/23/15
to golan...@googlegroups.com, an...@kix.in
This kind of question has been asked previously on this list, IIRC. I suggest searching the history.

Trouble is that Go actually has a runtime that does garbage collection, and manages go routines. Very difficult to somehow bring such functionality into the kernel. If you somehow don't use either go routines or GC, you're talking about a subset of the language that is significantly less appealing.

Eric.

andrewc...@gmail.com

unread,
Feb 23, 2015, 6:30:39 PM2/23/15
to golan...@googlegroups.com, an...@kix.in
I think the level of expertise and effort required would make it very difficult to achieve.

Egon

unread,
Feb 24, 2015, 2:04:16 AM2/24/15
to golan...@googlegroups.com, an...@kix.in, kennetha...@gmail.com
I think you are better off doing this in C.
Or if you only want to experiment/learn then Rust/Nim/D are also possibilities.

+ Egon

Kenneth Adam Miller

unread,
Feb 24, 2015, 2:08:14 AM2/24/15
to golang-nuts
Yeah, I hadn't searched the mailing list before I mentioned it.

And yeah, I'm just looking to get better safety in a kernel programming setting than what we have; go was one (maybe) option, and rust is another. Thanks for mentioning each of those, I've been talking around some other forums and I've found my answer.

adon...@google.com

unread,
Feb 24, 2015, 2:12:02 PM2/24/15
to golan...@googlegroups.com, an...@kix.in
My advice: don't.  Whatever possible gains you'll realize from writing in Go will be nullified a hundred times over by the problem of working in two languages.   A device driver should really not need that much code.

Reply all
Reply to author
Forward
0 new messages