source: CIVL/examples/concurrency/simpleSendFunction.cvl@ bb03188

main test-branch
Last change on this file since bb03188 was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 751 bytes
RevLine 
[a52ef0f]1#include <stdio.h>
2#include <comm.cvh>
3
4void testStream($gcomm gc){
5 $comm comm = $comm_create($here, gc, 1);
6 $message message = $comm_dequeue(comm, 0, $COMM_ANY_TAG);
7 printf("New kernel message received\n");
8 void (*kernel)();
9 $message_unpack(message, (void*)&kernel, sizeof(kernel));
10 kernel();
[52b7367]11 $comm_destroy(comm);
[a52ef0f]12}
13
14void print(){
[52b7367]15 printf("Inside kernel function!\n");
[a52ef0f]16}
17
18void main(){
19 $gcomm gcomm = $gcomm_create($here, 2);
20 $comm comm = $comm_create($here, gcomm, 0);
[52b7367]21 $proc otherProc = $spawn testStream(gcomm);
22 void (*printFunc)() = &print;
23 $message message = $message_pack(0, 1, 0, &printFunc, sizeof(printFunc));
[a52ef0f]24 $comm_enqueue(comm, message);
[52b7367]25 $wait(otherProc);
[a52ef0f]26 $comm_destroy(comm);
27 $gcomm_destroy(gcomm, NULL);
28}
Note: See TracBrowser for help on using the repository browser.