wiki:Aesop example test programs
Last modified 10 years ago Last modified on 02/21/12 15:07:29

Looking at aesop examples

There are several test programs and examples in the following directory:

cd parser/tests/blocking

Please look at the README file in that directory to see the current status of the test programs. As of this writing (January 18) several tests are failing due in-progress refactoring of the aesop cancel functionality.

basic.ae

All aesop programs have to include aesop.h.

Aesop has a different main function than c (because there has to be something at the top level that sets up and drives the aesop engine. You can specify this function by using the aesop_main_set() macro. The first argument is the name of your main routine (called aesop_main() in this example, though you can name it whatever you want). The following arguments are a list of resources to initialize.

Most of the test programs will either use the "btest" or "timer" resources, or both.

The btest resource is just a toy/example used to exercise various aesop features for testing. The timer resource is a production-quality resource that just provides a way to sleep for a specified amount of time.

Example of modifying basic.ae

Let's define a new main routine to take the place of the existing one:

__blocking int test_main(int argc, char** argv)
{
   printf("hello world.\n");
   return(0);
}

Then modify the aesop_main_set() call to refer to this new function:

aesop_main_set(test_main);

At this point you should be able to go into your build directory and run the following command to build basic.ae as a simple hello world example:

cd <top dir of source>
cd build
make parser/tests/blocking/basic

Now if we want to modify it to use a timer with a pbranch, first add definitions for the timer api:

#include "resources/timer/timer.hae"

... and then modify the test_main function to include the following logic:

__blocking int test_main(int argc, char** argv)
{
  pwait{
     pbranch {
        triton_timer(10000);
     }
     pbranch {
        printf("pbranch2");
     }
  }

  printf("done.\n");
  return(0);
}

Aesop tricks

If you wish to see the intermediate c code that is generated by aesop (instead of going directly from .ae files to .o files) you can configure with the --enable-aesop-debug configure option. After doing this you will get additional .i and .s files that show intermediate c code, with and without various preprocessing steps.