Differences between revisions 3 and 4
Revision 3 as of 2011-07-11 16:25:07
Size: 2552
Editor: giro
Comment: various small grammar fixes
Revision 4 as of 2011-07-11 17:05:26
Size: 2543
Editor: wwwcache
Comment: various grammar edits
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
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.
Barrelfish is not self-hosting at the moment, so programs to be run on it 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.
Line 4: Line 4:
This article assumes you have run though the steps in [[Getting_Started|Getting Started]] up to generating a Makefile. This article assumes you have run though the steps in [[Getting_Started|Getting Started]] up through generating a Makefile.
Line 9: Line 9:
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. 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.
Line 11: Line 11:
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, located in the build directory.
So open up build/symbolic_targets.mk and add the following line to the MODULES_COMMON variable
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, located in the build directory.
Open up build/symbolic_targets.mk and add the following line to the MODULES_COMMON variable:
Line 17: Line 17:
After this has been done, you will have to regenerate the Makefile like so After this has been done, you will have to regenerate the Makefile like so:
Line 25: Line 25:
Finally, to run the hello world program once Barrelfish has booted, we need to append the following line to build/menu.lst Finally, to run the hello world program once Barrelfish has booted, we need to append the following line to build/menu.lst:
Line 34: Line 34:
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 All .if files that 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:

Barrelfish is not self-hosting at the moment, so programs to be run on it 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 through 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, located in the build directory. 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 that 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)