annotate main.c @ 1:c6fc793f68a5

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