annotate main.c @ 2:d561f123f9a6

working version
author Sean Halle <seanhalle@yahoo.com>
date Sat, 29 Mar 2014 06:10:50 -0700
parents c6fc793f68a5
children
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@2 16
seanhalle@2 17
seanhalle@1 18 /*This demonstrates the use of the proto-runtime system. It allows multiple
seanhalle@1 19 * languages to be mixed within a single sub-program. It also allows multiple
seanhalle@1 20 * sub-programs to be started, where each uses its own set of languages. The
seanhalle@1 21 * running sub-programs can then communicate with each other.
seanhalle@1 22 *
seanhalle@1 23 */
seanhalle@1 24 int main( int argc, char **argv )
seanhalle@1 25 { PRProcess *testProcess1, *testProcess2;
seanhalle@1 26
seanhalle@2 27 DEBUG__printf(TRUE, "arguments: %s | %s", argv[0], argv[1] );
seanhalle@2 28
seanhalle@1 29 //A proto-runtime based language sits on top of the proto-runtime. So,
seanhalle@1 30 // first start the proto-runtime system, then create processes (which
seanhalle@1 31 // start languages inside themselves)
seanhalle@1 32 PR__start();
seanhalle@1 33
seanhalle@1 34 //This info shows up in the header of output files holding measurements
seanhalle@1 35 //These calls MUST be made after PR__start and before creating a process
seanhalle@1 36 PR__set_app_info("Test for developing VReo");
seanhalle@1 37 PR__set_input_info("no input");
seanhalle@1 38
seanhalle@1 39
seanhalle@1 40 //Now that PR is started, create processes.
seanhalle@1 41 //Each process creates a seedVP and starts it running -- that then starts
seanhalle@1 42 // the languages used inside the process..
seanhalle@1 43 //To get results from a process, it gets complicated.. simple soln is
seanhalle@1 44 // just use PR's malloc and free, in the main thread, between PR__start
seanhalle@1 45 // and PR__shutdown
seanhalle@1 46 //The call returns a process struct
seanhalle@1 47 SeedParams *params = PR__malloc( sizeof(SeedParams) );
seanhalle@1 48 testProcess1 = PR__create_process( &test_app_seed_Fn, params );
seanhalle@1 49
seanhalle@1 50 PR__wait_for_process_to_end( testProcess1 );
seanhalle@1 51 printf("\n\nresults: %d, %d\n\n", params->data[0], params->data[1] );
seanhalle@1 52
seanhalle@1 53 PR__free(params);
seanhalle@1 54
seanhalle@1 55 PR__wait_for_all_activity_to_end(); //equivalent of detecting shutdown
seanhalle@1 56 PR__shutdown();
seanhalle@1 57
seanhalle@1 58 exit(0); //cleans up
seanhalle@1 59 }