4 ms·
i would love to see just the opposite.. plan9-go a plan9 kernel and tools all coded in go. but go is a first class citizen when you think of something like ras
by oscargrouch 13y ago
i would love to see just the opposite.. plan9-go
a plan9 kernel and tools all coded in go.
but go is a first class citizen when you think of something like raspberry..
you can think golang wherever you can think of python
- graue 13y agoYou can't write a kernel in Go because it has a mandatory runtime system and garbage collection. However, Mozilla's Rust language is similar in some ways, can work runtime-less, and a small demo kernel has been written in it: https://github.com/charliesome/rustboot https://github.com/charliesome/rustboot
- read_again 13y ago> You can't write a kernel in Go because it has a mandatory runtime system and garbage collection. Could you please provide a link or two on that, or give some explanation on why this is not possible?
- foobarbazqux 13y agoIt's quite possible, here's an example: https://en.wikipedia.org/wiki/Singularity_%28operating_system%29 https://en.wikipedia.org/wiki/Singularity_%28operating_syste... They only used C and assembly for interrupt handling.
- cypher543 13y agoYou can't write a kernel completely in Go. But that's the case with every language except assembly (and, with a GCC-specific x86 extension, C). If you were to implement the core runtime in assembly, there'd be nothing to stop you from writing the higher-level functionality of a kernel in Go.
- ballard 13y agoThis maybe true for most system languages on some platforms. My OS internals are rusty, but from hacking on minix, there was an issue for x86 bootstrapping into protected mode stuff to set important things like interrupt handlers and other addresses. Whether this is done in the language by macros, embedded asm or external asm, ultimately a binary is produced that is code and data segments for the architecture.
- 4ad 13y agoOf course that you can; kernels are not magic. Many kernels have been written in languages with far more heavyweight runtime systems than Go. A few examples have been provided in the comments. Here is a toy example in Go: http://gofy.cat-v.org/ http://gofy.cat-v.org/ You need some bits of assembly, but that's true for C, C++, Rust and whatever else as well.
- oscargrouch 13y agohe´s not saying that its not possible to use go for that.. its just that the compiler puts the go runtime wich is specific for the userland and that in the end of the line will create a bunch of kernel syscalls for whatever systems you are.. to make this happen, it should be possible to, at least change the runtime , or not use a runtime at all.. so the little boot part in assembly could call a go function in kernel mode
- 4ad 13y agoOf course you'll need a specific runtime just like for C you can't use the user space libc. There's no difference between C and Go here. You can create your own runtime as you see fit. In fact, the Go distribution used to ship with such a bare metal runtime. Search the repository history for the tiny runtime. Reviving it again should be easier then porting Go to a new architecture, which is quite easy. Making a stub runtime (equivalent to booting a C kernel with no libc) is not more than half an hour of work. Go can call assembly and C, and assembly and C can call Go. This is used a lot in the runtime, nothing special about it.
- oscargrouch 13y agohow about create a option in the compiler to ditch the standard runtime, or even to put another runtime in place.. suppose you create a kernel kit library/runtime.. instead the one in go.. who assume you are in userspace.. its possible.. i think if only they allowed to create a binary with no runtime in it... and with the binary encoding for the boot (dont remember what it is right now) it would just be feasible.. people could start hacking it
- ballard 13y agoAs implied in other comments, rsc ported quite a bit of p9p to go.