SIMPL Review

Course content Enter chat room Send email 
to mailing list
Check calendar

A Review of SIMPL (Note that this has been taken directly from earlier course work.)

SIMPL is really two things.

First of all SIMPL represents a very good paradigm for designing software.    It promotes encapsulation of complexity and ready extendability ... both good things in a software package.

SIMPL is also an LGPL'd open source library that you can link to (dynamically or statically) that enables you to write software that readily exchanges Send/Receive/Reply (QNX ) style messages.

OK what does it really do?

It is a library.     Once you have it installed you can write your code using a rich (yet simple) set of functions for Interprocess Communication (IPC).    These functions include:

and a few lesser used ones.

So as you can see the SIMPL library API is very clean indeed.

How does it work?

In SIMPL vocabulary we speak of Linux processes as being of one of two types:

As you can see in the figure above there are several elements associated with a SIMPL message pass.

The first of these is the container for the bytes in the message itself.    That is contained within a shared memory area allocated by the sender process.   Actually there are two areas:  one for the outgoing message and one for the reply message.

To help with process blocking (more on that later) and synchronization a slotID is exchanged on a named pipe or fifo prior to each message pass.

A typical message exchange between a sender and a receiver would go something like this:

  1. SIMPL receiver process starts up and does a name_attach() to register its SIMPL name
  2. SIMPL receiver then does some initialization and drops into a Receive blocked state by calling the Receive() function
  3. SIMPL sender process starts up and does a name_attach() to register its unique SIMPL name
  4. sender then does a name_locate() to connect to the receiver's fifo
  5. sender composes a message and drops it into the outgoing shared memory area
  6. sender places its slotID onto the receiver's fifo and drops into a Send blocked state by calling the Send() function
  7. receiver wakes up and retrieves the slotID from the fifo and then connects to the shared memory area and retrieves the actual message contents
  8. receiver processes the message and composes a reply which is then placed directly into the sender's reply shared memory area
  9. receiver places its slotID onto the sender's fifo and drops back into Receive blocked state by calling the Receive() function
  10. sender wakes up and retrieves the reply
Before I lose you all in the details let's illustrate these things by way of some examples.

The first step: getting the SIMPL tools and installing them on your system

NOTE: If you want to wait and use the self installing archive to install SIMPL for you, you can skip on to the lesson material now.

If you want to understand a bit more about SIMPL by doing a manual installation of the toolkit by all means read through the following procedure.

Before you begin you will need to decide where your SIMPL source tree will exist and make a couple of environment variables accordingly.
Hint on environment variables:
If you have never heard of environment variables please look them up in your Linux reference material.     The two environment variables that SIMPL uses must be set up so as to be always available after a login ... in much the same way as the Linux PATH enviroment variable is.    Typically this involves adding some "export" commands into one of the shell initialization files on your system.   $HOME/.bash_profile,  $HOME/.bashrc,   $HOME/.profile or /etc/profile are some examples of shell initialization files.

If you don't know which "dot file" to use for your Linux distribution   try the following experiment.      Add in an "echo hi" line to one of the "dot" files.     Logout and back into your system (if you are a GUI person open a text console window also).      If you see your "hi" then that is the file in which to add the export lines below.

You can elect to place your SIMPL source anywhere you please as long as the subdirectory is called "simpl".   Suppose you decided to place all the SIMPL source at:

then you would need to create an environment variable called SIMPL_HOME which pointed to this directory.   ie. in your local .bashrc (or other suitable hidden file) you would add the following line:
export SIMPL_HOME=/home/simpl
The SIMPL library will also need to access a various fifos involved in the SIMPL message exchange.     You will need to create a directory to hold the inodes for the various fifo's used by the SIMPL environment.    Once again you can place this directory anywhere you please ... no requirement to call this subdirectory fifo.    Suppose that you elect to place this "fifo" directory at:
then you would need to create a second environment variable called FIFO_PATH which points to this directory. ie.
export FIFO_PATH=/home/simpl/fifo

The SIMPL source tree has been carefully designed not to "pollute" your system.    All SIMPL related files will exist under one of these two directories above.

You are now ready to go online and grab the latest version of SIMPL  source code from the SIMPL Open Source project website.

main SIMPL home page
sourceforge SIMPL site

The SIMPL project is a dynamic Open Source project and releases are made regularly.   It is also quite stable.

It is important that you pickup the latest release to capture all the bug fixes that have been done.    When in doubt which version to use the Sourceforge site always only contains the latest release.

Once you have downloaded the latest tarball you need to place it at the subdirectory immediately above the SIMPL_HOME.  ie.

cd ..
<place your SIMPL tarball here>
then you can undo your tarball by typing
tar -zxvf whateveryourSIMPLtarballnameis
At this point you should have a whole bunch of source code sitting at SIMPL_HOME.

Addendum for Python

The python interpreter needs to know where you are keeping  the modules that you want to be able to import. One way to accomplish this is set the shell variable called PYTHONPATH.  To set this variable, type:
export PYTHONPATH=$SIMPL_HOME/python/modules

You will need this in order to be able to import the simpl functionality.

The next step: building the SIMPL libraries

After installing all the source on your system the next step is to build all this source code into the SIMPL libraries.

To do this you will need to:

              cd $SIMPL_HOME/scripts

This should cause the SIMPL source to completely build and install itself.

The SIMPL source tree has some Tcl/Tk hooks built into it.    If you do not have Tcl/Tk installed on your Linux system you will need to do this now as we will be using Tcl/Tk in a later lesson as our GUI language. 


 Making sure that the SIMPL tools work

One of the subdirectories under the SIMPL_HOME tree is called benchmarks.     Some SIMPL executables were build here.   They can be used to "time" the SIMPL message passing on your system.

We will be using them here to verify that you have SIMPL installed and the environment variables correctly defined.

The buildsimpl script should have caused two executables to be built.

To run this benchmark test you will need to open 2 text consoles on your system and point each to the

On console 1: logged onto $SIMPL_HOME/benchmarks/bin  type

receiver -n BOBR
where BOBR - is an arbitrary SIMPL name you have chosen for this receiver.

On console 2: logged onto $SIMPL_HOME/benchmarks/bin  type

sender -n BOBS -r BOBR -t 100000 -s 1024
where -n BOBS - is the SIMPL name for the sender
              -r BOBR - is SIMPL name used for the receiver above
              -t 100000  - means send 100000 messages before displaying timing
              -s 1024 - says make each message 1024 bytes in length (same size for replies)
When you hit enter on console 2 the sender locates receiver and then marks the time. It then procedes to send 100000 1k  messages to the receiver each time blocking for the same size reply.
If you see seg faults in the above:
This is a clear indication that you do not have your environment variables (in particular FIFO_PATH) defined in such a way that they are set for each login.   ie. if you were to type "echo $FIFO_PATH" nothing would show up.

SIMPL uses these two environment variables both at build time (SIMPL_HOME) and at run time (FIFO_PATH) so it is very important that you  export both of these environment variables so that they are always set.

When this preset number of  messages have been exchanged the sender calculates and reports the total elapsed time in msec.

You have asked your system to do a substantial piece of work here.    Depending on your processor type and speed this may take several tens of seconds to complete.

Once you have the number you can easily compute the number of SIMPL messages per second that your system is capable of exchanging.
Congratulations!  You have successfully installed SIMPL on your system!

It might be nice to share your benchmark results with the mailing list.

For those of you who are interested in such things SIMPL's benchmarks are within an order of magnitude of QNX on the same hardware.   ie. QNX will exchange messages about 10 times faster than SIMPL under Linux.      With modern computing hardware the SIMPL message passing speed is more than adequate for most applications, however.     Besides SIMPL is Open Source and you can't beat its price point.

Because SIMPL does not use the TCP/IP stack for local message passing it will be significantly faster at passing messages between Linux processes on the same box.

The SIMPL "sandbox"

SIMPL maintains a kind of "phone book" to keep information about all running SIMPL processes.

This "phone book" is kept as a set of special files in the directory you named:

The name_attach() API call should create a pair of fifos which are used by SIMPL to synchronize the message exchange to your process and the reply message back to your process.

The name_locate() API call reads info from this directory and the filenames contained therein.

There are several utilities that come with the SIMPL package for viewing and manipulating this fifo directory.

The first of these is affectionately called "the hammer" by some folks:

rm *
If you are careful when you run the "hammer" it will ensure that your SIMPL sandbox is clean.     It will not, however, insure that any rogue processes you had running were terminated properly.

For that you will need to run another pair of utilities before invoking the "hammer".

The first of these  utilities is the slot viewer:

If you run this it will show all the SIMPL names currently registered  along with the pid they are associated with.

Try rerunning the test above and while the timing is taking place,  change to  another console and run fcshow.

Finally if you have a need to kill a rogue SIMPL process by its SIMPL name then there is a utility called:

which you use as
fcslay <SIMPLname>
Once again give this a try by starting up the receiver above and from another console typing
fcslay BOBR
End of SIMPL Review.

Copyright of iCanProgram Inc.  2002,2009