annotate main.c @ 7:eecb8b6c092d

ML_dev -- Works
author Sean Halle <seanhalle@yahoo.com>
date Mon, 04 Mar 2013 00:32:02 -0800
parents 1c9122bfd1c8
children
rev   line source
seanhalle@0 1 /*
seanhalle@0 2 * Copyright 2012 OpenSourceResearchInstitute.org
seanhalle@0 3 * Licensed under GNU General Public License version 2
seanhalle@0 4 *
seanhalle@0 5 * author seanhalle@yahoo.com
seanhalle@0 6 */
seanhalle@0 7
seanhalle@0 8 #include <malloc.h>
seanhalle@0 9 #include <stdlib.h>
seanhalle@0 10
seanhalle@0 11 #include "VSs__Test_App/VSs__Test_App.h"
seanhalle@0 12
seanhalle@6 13 /*This demonstrates the use of the proto-runtime system. It allows multiple
seanhalle@6 14 * languages to be mixed within a single sub-program. It also allows multiple
seanhalle@6 15 * sub-programs to be started, where each uses its own set of languages. The
seanhalle@6 16 * running sub-programs can then communicate with each other.
seanhalle@0 17 *
seanhalle@0 18 */
seanhalle@0 19 int main( int argc, char **argv )
seanhalle@6 20 { PRProcess *testProcess1, *testProcess2;
seanhalle@6 21
seanhalle@0 22 DEBUG__printf2(TRUE, "arguments: %s | %s", argv[0], argv[1] );
seanhalle@0 23
seanhalle@6 24 //A proto-runtime based language sits on top of the proto-runtime. So,
seanhalle@6 25 // first start the proto-runtime system, then create processes (which
seanhalle@6 26 // start languages inside themselves)
seanhalle@6 27 PR__start();
seanhalle@6 28
seanhalle@6 29 //This info shows up in the header of output files holding measurements
seanhalle@6 30 //These calls MUST be made after PR__start and before creating a process
seanhalle@6 31 PR__set_app_info("test of multi-lang functionality");
seanhalle@6 32 PR__set_input_info("no input");
seanhalle@6 33
seanhalle@6 34
seanhalle@6 35 //Now that PR is started, create processes.
seanhalle@6 36 //Each process creates a seedVP and starts it running -- that then starts
seanhalle@6 37 // the languages used inside the process..
seanhalle@6 38 //To get results from a process, it gets complicated.. simple soln is
seanhalle@6 39 // just use PR's malloc and free, in the main thread, between PR__start
seanhalle@6 40 // and PR__shutdown
seanhalle@6 41 //The call returns a process struct (which has access to the seedVP)
seanhalle@6 42 int32 *result = PR__malloc( 2 * sizeof(int32) );
seanhalle@6 43 testProcess1 = PR__create_process( &test_app_seed_Fn, result );
seanhalle@6 44
seanhalle@6 45 //testProcessor2 = PR__create_processor( &test_app2, NULL );
seanhalle@6 46 //PR__connect_processors(testProcess1, OUT, testProcess2, IN);
seanhalle@6 47 //PR__connect_processors(testProcess2, OUT, testProcess1, IN);
seanhalle@6 48
seanhalle@6 49 PR__wait_for_process_to_end( testProcess1 );
seanhalle@6 50 printf("results: %d, %d\n", result[0], result[1] );
seanhalle@6 51
seanhalle@6 52 PR__free(result);
seanhalle@6 53
seanhalle@7 54 PR__wait_for_all_activity_to_end(); //equivalent of detecting shutdown
seanhalle@6 55 PR__shutdown();
seanhalle@0 56
seanhalle@0 57 exit(0); //cleans up
seanhalle@0 58 }