Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > DKU > DKU__Test_App
diff 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 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/main.c Tue Sep 24 08:42:31 2013 -0700 1.3 @@ -0,0 +1,57 @@ 1.4 +/* 1.5 + * Copyright 2012 OpenSourceResearchInstitute.org 1.6 + * Licensed under GNU General Public License version 2 1.7 + * 1.8 + * author seanhalle@yahoo.com 1.9 + */ 1.10 + 1.11 +#include <malloc.h> 1.12 +#include <stdlib.h> 1.13 + 1.14 +#include "DKU__Test_App/DKU__Test_App.h" 1.15 +#include <PR__include/PR__WL.h> //declares PR__create_process -- else get integer return value 1.16 + 1.17 +#define NO_INPUT_OR_OUTPUT NULL 1.18 + 1.19 +/*This demonstrates the use of the proto-runtime system. It allows multiple 1.20 + * languages to be mixed within a single sub-program. It also allows multiple 1.21 + * sub-programs to be started, where each uses its own set of languages. The 1.22 + * running sub-programs can then communicate with each other. 1.23 + * 1.24 + */ 1.25 +int main( int argc, char **argv ) 1.26 + { PRProcess *testProcess1, *testProcess2; 1.27 + 1.28 + DEBUG__printf2(TRUE, "arguments: %s | %s", argv[0], argv[1] ); 1.29 + 1.30 + //A proto-runtime based language sits on top of the proto-runtime. So, 1.31 + // first start the proto-runtime system, then create processes (which 1.32 + // start languages inside themselves) 1.33 + PR__start(); 1.34 + 1.35 + //This info shows up in the header of output files holding measurements 1.36 + //These calls MUST be made after PR__start and before creating a process 1.37 + PR__set_app_info("Test for developing VReo"); 1.38 + PR__set_input_info("no input"); 1.39 + 1.40 + 1.41 + //Now that PR is started, create processes. 1.42 + //Each process creates a seedVP and starts it running -- that then starts 1.43 + // the languages used inside the process.. 1.44 + //To get results from a process, it gets complicated.. simple soln is 1.45 + // just use PR's malloc and free, in the main thread, between PR__start 1.46 + // and PR__shutdown 1.47 + //The call returns a process struct 1.48 + SeedParams *params = PR__malloc( sizeof(SeedParams) ); 1.49 + testProcess1 = PR__create_process( &test_app_seed_Fn, params ); 1.50 + 1.51 + PR__wait_for_process_to_end( testProcess1 ); 1.52 + printf("\n\nresults: %d, %d\n\n", params->data[0], params->data[1] ); 1.53 + 1.54 + PR__free(params); 1.55 + 1.56 + PR__wait_for_all_activity_to_end(); //equivalent of detecting shutdown 1.57 + PR__shutdown(); 1.58 + 1.59 + exit(0); //cleans up 1.60 + }
