Differences between revisions 1 and 2
Revision 1 as of 2011-07-11 15:59:04
Size: 2547
Editor: wwwcache
Comment:
Revision 2 as of 2011-07-11 16:23:35
Size: 2543
Editor: wwwcache
Comment: minor grammar fix
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
There are several examples of Barrelfish programs demonstrating various aspects of the API in usr/examples. The readme in that folder explains exactly how to get them all running, this article is merely paraphrasing the its contents. There are several examples of Barrelfish programs demonstrating various aspects of the API in usr/examples. The readme in that folder explains exactly how to get them all running, this article is merely paraphrasing its contents.

Barrelfish is not self-hosting at the moment, so programs which are to be run on Barrelfish must be compiled alongside it. There are several examples of Barrelfish programs demonstrating various aspects of the API in usr/examples. The readme in that folder explains exactly how to get them all running, this article is merely paraphrasing its contents.

This article assumes you have run though the steps in Getting Started up to generating a Makefile.

Hello World

First we will get a basic Hello World program running on Barrelfish. The program is located in usr/examples/xmpl-hello.

Usually you need to create a directory under usr in which you place your source code and a Hakefile which lists the source files to compile and a target, however this is all done for us in this example.

To get Hake to include a target for the hello world program in the generated Makefile, we must first add the target to the symbolic_targets.mk file in the build directory. So open up build/symbolic_targets.mk and add the following line to the MODULES_COMMON variable

/sbin/examples/xmpl-hello \

After this has been done, you will have to regenerate the Makefile like so

cd build
../hake/hake.sh -s .. -a x86_64

Note: You will have to modify the -a argument above if you are not building for a 64-bit target.

Now we run make and the hello world program should be compiled. Finally, to run the hello world program once Barrelfish has booted we need to append the following line to build/menu.lst

module  /x86_64/sbin/examples/xmpl-hello

And now if we run make sim we should see a "Hello World" message displayed once fish has started.

Message-Passing Interfaces

The only other files you will need to interact with for running programs are .if files. These files specify interfaces used for message passing. The example program xmpl-rpc found in usr/examples/ shows how this works. An explanation of the message passing API can be found here: idc.pdf

All .if files which you wish to use must be added to the flounderGenDefs variable in the if/Hakefile. So for the xmpl-rpc example the change would look like this

-- whereas these are using the new-style bindings
[ flounderGenDefs (options arch) f
      | f <- [ "bcast",
               "bench",
           ... 
               "xmplrpc"]
             arch <- allArchitectures
] ++

BarrelfishWiki: Programming_for_Barrelfish (last edited 2015-01-30 15:14:44 by Simon Gerber)