seanhalle@1: /* seanhalle@1: * Copyright 2012 OpenSourceResearchInstitute.org seanhalle@1: * Licensed under GNU General Public License version 2 seanhalle@1: * seanhalle@1: * author seanhalle@yahoo.com seanhalle@1: */ seanhalle@1: seanhalle@1: #include seanhalle@1: #include seanhalle@1: seanhalle@1: #include "DKU__Test_App/DKU__Test_App.h" seanhalle@1: #include //declares PR__create_process -- else get integer return value seanhalle@1: seanhalle@1: #define NO_INPUT_OR_OUTPUT NULL seanhalle@1: seanhalle@2: seanhalle@2: seanhalle@1: /*This demonstrates the use of the proto-runtime system. It allows multiple seanhalle@1: * languages to be mixed within a single sub-program. It also allows multiple seanhalle@1: * sub-programs to be started, where each uses its own set of languages. The seanhalle@1: * running sub-programs can then communicate with each other. seanhalle@1: * seanhalle@1: */ seanhalle@1: int main( int argc, char **argv ) seanhalle@1: { PRProcess *testProcess1, *testProcess2; seanhalle@1: seanhalle@2: DEBUG__printf(TRUE, "arguments: %s | %s", argv[0], argv[1] ); seanhalle@2: seanhalle@1: //A proto-runtime based language sits on top of the proto-runtime. So, seanhalle@1: // first start the proto-runtime system, then create processes (which seanhalle@1: // start languages inside themselves) seanhalle@1: PR__start(); seanhalle@1: seanhalle@1: //This info shows up in the header of output files holding measurements seanhalle@1: //These calls MUST be made after PR__start and before creating a process seanhalle@1: PR__set_app_info("Test for developing VReo"); seanhalle@1: PR__set_input_info("no input"); seanhalle@1: seanhalle@1: seanhalle@1: //Now that PR is started, create processes. seanhalle@1: //Each process creates a seedVP and starts it running -- that then starts seanhalle@1: // the languages used inside the process.. seanhalle@1: //To get results from a process, it gets complicated.. simple soln is seanhalle@1: // just use PR's malloc and free, in the main thread, between PR__start seanhalle@1: // and PR__shutdown seanhalle@1: //The call returns a process struct seanhalle@1: SeedParams *params = PR__malloc( sizeof(SeedParams) ); seanhalle@1: testProcess1 = PR__create_process( &test_app_seed_Fn, params ); seanhalle@1: seanhalle@1: PR__wait_for_process_to_end( testProcess1 ); seanhalle@1: printf("\n\nresults: %d, %d\n\n", params->data[0], params->data[1] ); seanhalle@1: seanhalle@1: PR__free(params); seanhalle@1: seanhalle@1: PR__wait_for_all_activity_to_end(); //equivalent of detecting shutdown seanhalle@1: PR__shutdown(); seanhalle@1: seanhalle@1: exit(0); //cleans up seanhalle@1: }