Difference between revisions of "Go on L4"

From TUDOS-Wiki
Jump to navigationJump to search
 
Line 24: Line 24:
 
   make install
 
   make install
  
== Building the L4 Go package ==
+
== Building the L4Go package ==
  
 
After successfully compiling and installing GCCGO, you need to define the environment variables GCCGO_SRC and GCCGO_INST to point to the GCCGO source and installation directories respectively. With those variables defined, you can then go and build l4/pkg/go:
 
After successfully compiling and installing GCCGO, you need to define the environment variables GCCGO_SRC and GCCGO_INST to point to the GCCGO source and installation directories respectively. With those variables defined, you can then go and build l4/pkg/go:
Line 30: Line 30:
 
   # cd src/l4/pkg/go
 
   # cd src/l4/pkg/go
 
   # GCCGO_SRC=<path to GCCGO source> GCCGO_INST=<path to GCCGO installation> O=<path to L4Re build dir> make
 
   # GCCGO_SRC=<path to GCCGO source> GCCGO_INST=<path to GCCGO installation> O=<path to L4Re build dir> make
 +
 +
== Inter-process Go channels ==
 +
L4Go provides a special flavor of Go channels that make use of L4 IPC mechanisms to allow for inter-process data exchange while retaining the channel syntax (for creation and sending/receiving objects) and semantics (with regard to synchronization properties). These channels are provided in terms of a Go package: l4go_chan. More detailed information about the details of these channels can be found in the following thesis: [http://os.inf.tu-dresden.de/papers_ps/danielmueller-beleg.pdf Daniel Müller - Evaluation of the Go Programming Language and Runtime for L4Re].
 +
 +
The following example illustrates the usage of these channels in a client/server context:
 +
 +
==== Client ====
 +
  package main
 +
 
 +
  import "os"
 +
  import "fmt"
 +
 
 +
  import l4w "l4go_wrap"
 +
  import l4c "l4go_chan"
 +
 
 +
 
 +
  func main() {
 +
    channel := make(chan int)
 +
 
 +
    if e := l4c.Connect(channel, "channel", false); e != nil {
 +
      fmt.Fprintln(os.Stderr, "error: connecting channel failed:", e)
 +
      return
 +
    }
 +
 
 +
    for i := 0; i < 200; i++ {
 +
      channel <-i
 +
    }
 +
 
 +
    l4w.SleepForever()
 +
  }
 +
 +
==== Server ====
 +
  package main
 +
 
 +
  import "os"
 +
  import "fmt"
 +
 
 +
  import l4c "l4go_chan"
 +
 
 +
 
 +
  func main() {
 +
    channel := make(chan int)
 +
 
 +
    if e := l4c.Connect(channel, "channel", true); e != nil {
 +
      fmt.Fprintln(os.Stderr, "error: connecting channel failed:", e)
 +
      return
 +
    }
 +
 
 +
    for {
 +
      fmt.Println("received value:", <-channel)
 +
    }
 +
  }
 +
 +
In order to make an L4Go channel refer to another L4 task it must be '''connected''' to it. This can be accomplished using the ''Connect()'' function provided by ''l4go_chan'' package. It accepts, among the channel to connect, the name of the L4 communication channel (string) as, for instance, specified within the Lua start script. The third parameter states wether this end of the L4Go channel belongs to the server or client side (true or false, respectively) of the L4 communication channel.
 +
  
 
== Troubleshooting ==
 
== Troubleshooting ==

Latest revision as of 22:58, 6 August 2012

The runtime for the Go programming language has been ported to L4Re (and will be released soon).

Preparation

Go on L4 works in conjunction with the gccgo compiler which you need to set up yourself beforehand.

  • gccgo requires some libraries to be available on your system. On Ubuntu do:
 sudo apt-get install libmpc-dev libmpfr-dev libgmp3-dev
  • For building gccgo, a detailed description is available on the Go homepage. In short:
 # create gccgo dir
 mkdir gccgo
 cd gccgo
 
 # install dir for the local build
 mkdir install
   
 # GCCGO
 svn checkout -r 179017 svn://gcc.gnu.org/svn/gcc/branches/gccgo gccgo
 mkdir obj
 cd obj
 ../gccgo/configure --enable-languages=c,c++,go --with-ld=/home/user/gccgo/install/bin/ld \
   --prefix=/home/user/gccgo/install
 make
 make install

Building the L4Go package

After successfully compiling and installing GCCGO, you need to define the environment variables GCCGO_SRC and GCCGO_INST to point to the GCCGO source and installation directories respectively. With those variables defined, you can then go and build l4/pkg/go:

 # cd src/l4/pkg/go
 # GCCGO_SRC=<path to GCCGO source> GCCGO_INST=<path to GCCGO installation> O=<path to L4Re build dir> make

Inter-process Go channels

L4Go provides a special flavor of Go channels that make use of L4 IPC mechanisms to allow for inter-process data exchange while retaining the channel syntax (for creation and sending/receiving objects) and semantics (with regard to synchronization properties). These channels are provided in terms of a Go package: l4go_chan. More detailed information about the details of these channels can be found in the following thesis: Daniel Müller - Evaluation of the Go Programming Language and Runtime for L4Re.

The following example illustrates the usage of these channels in a client/server context:

Client

 package main
 
 import "os"
 import "fmt"
 
 import l4w "l4go_wrap"
 import l4c "l4go_chan"
 
 
 func main() {
   channel := make(chan int)
 
   if e := l4c.Connect(channel, "channel", false); e != nil {
     fmt.Fprintln(os.Stderr, "error: connecting channel failed:", e)
     return
   }
 
   for i := 0; i < 200; i++ {
     channel <-i
   }
 
   l4w.SleepForever()
 }

Server

 package main
 
 import "os"
 import "fmt"
 
 import l4c "l4go_chan"
 
 
 func main() {
   channel := make(chan int)
 
   if e := l4c.Connect(channel, "channel", true); e != nil {
     fmt.Fprintln(os.Stderr, "error: connecting channel failed:", e)
     return
   }
 
   for {
     fmt.Println("received value:", <-channel)
   }
 }

In order to make an L4Go channel refer to another L4 task it must be connected to it. This can be accomplished using the Connect() function provided by l4go_chan package. It accepts, among the channel to connect, the name of the L4 communication channel (string) as, for instance, specified within the Lua start script. The third parameter states wether this end of the L4Go channel belongs to the server or client side (true or false, respectively) of the L4 communication channel.


Troubleshooting

libtool version mismatch

Q: When building libgo from source, I get an error like this:

 libtool: Version mismatch error.  This is libtool 2.2.6b Debian-2.2.6b-2ubuntu3, but the
 libtool: definition of this LT_INIT comes from libtool 2.2.7a.
 libtool: You should recreate aclocal.m4 with macros from libtool 2.2.6b Debian-2.2.6b-2ubuntu3
 libtool: and run autoconf again.

A: Remove gccgo/libgo/config/ltversion.m4 and gccgo/libgo/config/ltmain.m4. Continue build process.