Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > VSs > VSs__Test_App__LangDev
view main.c @ 6:1c9122bfd1c8
ML_dev -- Compiles and runs
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Sat, 02 Mar 2013 10:03:18 -0800 |
| parents | 7a85919442f2 |
| children | eecb8b6c092d |
line source
1 /*
2 * Copyright 2012 OpenSourceResearchInstitute.org
3 * Licensed under GNU General Public License version 2
4 *
5 * author seanhalle@yahoo.com
6 */
8 #include <malloc.h>
9 #include <stdlib.h>
11 #include "VSs__Test_App/VSs__Test_App.h"
13 /*This demonstrates the use of the proto-runtime system. It allows multiple
14 * languages to be mixed within a single sub-program. It also allows multiple
15 * sub-programs to be started, where each uses its own set of languages. The
16 * running sub-programs can then communicate with each other.
17 *
18 */
19 int main( int argc, char **argv )
20 { PRProcess *testProcess1, *testProcess2;
22 DEBUG__printf2(TRUE, "arguments: %s | %s", argv[0], argv[1] );
24 //A proto-runtime based language sits on top of the proto-runtime. So,
25 // first start the proto-runtime system, then create processes (which
26 // start languages inside themselves)
27 PR__start();
29 //This info shows up in the header of output files holding measurements
30 //These calls MUST be made after PR__start and before creating a process
31 PR__set_app_info("test of multi-lang functionality");
32 PR__set_input_info("no input");
35 //Now that PR is started, create processes.
36 //Each process creates a seedVP and starts it running -- that then starts
37 // the languages used inside the process..
38 //To get results from a process, it gets complicated.. simple soln is
39 // just use PR's malloc and free, in the main thread, between PR__start
40 // and PR__shutdown
41 //The call returns a process struct (which has access to the seedVP)
42 int32 *result = PR__malloc( 2 * sizeof(int32) );
43 testProcess1 = PR__create_process( &test_app_seed_Fn, result );
45 //testProcessor2 = PR__create_processor( &test_app2, NULL );
46 //PR__connect_processors(testProcess1, OUT, testProcess2, IN);
47 //PR__connect_processors(testProcess2, OUT, testProcess1, IN);
49 PR__wait_for_process_to_end( testProcess1 );
50 printf("results: %d, %d\n", result[0], result[1] );
52 PR__free(result);
54 //PR__wait_for_all_activity_to_end(); //equivalent of detecting shutdown
55 PR__shutdown();
57 exit(0); //cleans up
58 }
