diff main.c @ 6:1c9122bfd1c8

ML_dev -- Compiles and runs
author Sean Halle <seanhalle@yahoo.com>
date Sat, 02 Mar 2013 10:03:18 -0800
parents 7a85919442f2
children eecb8b6c092d
line diff
     1.1 --- a/main.c	Mon Sep 03 03:16:32 2012 -0700
     1.2 +++ b/main.c	Sat Mar 02 10:03:18 2013 -0800
     1.3 @@ -10,15 +10,49 @@
     1.4  
     1.5  #include "VSs__Test_App/VSs__Test_App.h"
     1.6  
     1.7 -/*
     1.8 +/*This demonstrates the use of the proto-runtime system.  It allows multiple
     1.9 + * languages to be mixed within a single sub-program.  It also allows multiple
    1.10 + * sub-programs to be started, where each uses its own set of languages. The
    1.11 + * running sub-programs can then communicate with each other.
    1.12   * 
    1.13   */
    1.14  int main( int argc, char **argv )
    1.15 - { 
    1.16 -   
    1.17 + { PRProcess *testProcess1, *testProcess2;
    1.18 + 
    1.19     DEBUG__printf2(TRUE, "arguments: %s | %s", argv[0], argv[1] );
    1.20     
    1.21 -   VSs__Test_App( );
    1.22 +      //A proto-runtime based language sits on top of the proto-runtime. So, 
    1.23 +      // first start the proto-runtime system, then create processes (which
    1.24 +      // start languages inside themselves)
    1.25 +   PR__start();
    1.26 +   
    1.27 +      //This info shows up in the header of output files holding measurements
    1.28 +      //These calls MUST be made after PR__start and before creating a process
    1.29 +   PR__set_app_info("test of multi-lang functionality");
    1.30 +   PR__set_input_info("no input");
    1.31 +   
    1.32 +  
    1.33 +      //Now that PR is started, create processes.  
    1.34 +      //Each process creates a seedVP and starts it running -- that then starts
    1.35 +      // the languages used inside the process..
    1.36 +      //To get results from a process, it gets complicated..  simple soln is 
    1.37 +      // just use PR's malloc and free, in the main thread, between PR__start
    1.38 +      // and PR__shutdown
    1.39 +      //The call returns a process struct (which has access to the seedVP)
    1.40 +   int32 *result = PR__malloc( 2 * sizeof(int32) );
    1.41 +   testProcess1 = PR__create_process( &test_app_seed_Fn, result );
    1.42 +   
    1.43 +   //testProcessor2 = PR__create_processor( &test_app2, NULL );
    1.44 +   //PR__connect_processors(testProcess1, OUT, testProcess2, IN); 
    1.45 +   //PR__connect_processors(testProcess2, OUT, testProcess1, IN); 
    1.46 +      
    1.47 +   PR__wait_for_process_to_end( testProcess1 );
    1.48 +   printf("results: %d, %d\n", result[0], result[1] );
    1.49 +   
    1.50 +   PR__free(result);
    1.51 +   
    1.52 +   //PR__wait_for_all_activity_to_end();  //equivalent of detecting shutdown
    1.53 +   PR__shutdown();
    1.54     
    1.55     exit(0); //cleans up
    1.56   }