Minimal embedded Erland system

Joe Armstrong <>
Thu Sep 23 11:08:12 CEST 1999


On Wed, 22 Sep 1999, Joergen Froejk Kjaersgaard wrote:

> I have tried to make a minimal embedded Erlang system to use as a
> template. However, when i start the system - even in embedded mode - I
> get an Erlang shell prompt.
> 

... Ummm :-)

> test.erl:
> ======
> -module(test).
> -behaviour(application).
> -export([hello_sayer/0, start/2, stop/1]).
> 
> hello_sayer() ->
>     io:put_chars("hello, world\n"),
>     receive _ -> []
>     end.

... Minimal! - the very fact that you call "io:" means you have to pull in a
dozen or so modules and it won't be very minimal!

... cut ...

> test.app:
> =======
> {application, test,
>  [{description,  "A simple test application"},

... etc ...

Using applications is the wrong way to go if you are making
miminimal systems.

To find out how to do this read section 1.4 of "System principles"
very carefully.

It's at

http://www.erlang.org/doc/doc/doc/system_principles/system_principles.html#1.4

You will need to pre-load exactly two modules to make a minimal system
init.erl and erl_prim_loader.erl

In 

http://www.erlang.org/examples/examples-2.0.html

under the section sos you will find a description of a complete mini
OS which can you simple io - using sos instead of io you can write:

     -module(sos_test1).
     -export([main/0]).
      
     main() ->
            sos:write("Hello world\n").
			     
			     
To run this we must first compile sos_test1
using the compiler in the Erlang development environment. Once we have done
this then we can run the program as follows: 


unix> sos sos_test1
Hello world

We can time this as follows: 


> time sos sos_test1
Hello world
0.09u 0.04s 0:00.37 35.1

The details are in http://www.erlang.org/examples/examples-2.0.html

Actually sos.erl is worthly of study since it *is* an entire applocation
OS in a few hundred lines.


/Joe

--
Joe Armstrong,                       
Bluetail AB,                           tel:  +46 8 692 22 11
Hantverkargatan 78,                    fax:  +46 8 654 70 71
SE-112 38 Stockholm, Sweden            info: www.bluetail.com




More information about the erlang-questions mailing list