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