main
|
Last change
on this file 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:
847 bytes
|
| Rev | Line | |
|---|
| [a52ef0f] | 1 | #include <stdio.h>
|
|---|
| 2 | #include <comm.cvh>
|
|---|
| 3 |
|
|---|
| 4 | void 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 |
|
|---|
| [52b7367] | 14 | void print(int num){
|
|---|
| 15 | printf("Inside kernel function with number %d!\n", num);
|
|---|
| [a52ef0f] | 16 | }
|
|---|
| 17 |
|
|---|
| 18 | void main(){
|
|---|
| 19 | $gcomm gcomm = $gcomm_create($here, 2);
|
|---|
| 20 | $comm comm = $comm_create($here, gcomm, 0);
|
|---|
| [52b7367] | 21 | $proc otherProc = $spawn testStream(gcomm);
|
|---|
| 22 | int x;
|
|---|
| 23 | void capturedPrint() {
|
|---|
| 24 | print(x);
|
|---|
| 25 | }
|
|---|
| 26 | void (*printFunc)() = &capturedPrint;
|
|---|
| 27 | $message message = $message_pack(0, 1, 0, &printFunc, sizeof(printFunc));
|
|---|
| [a52ef0f] | 28 | $comm_enqueue(comm, message);
|
|---|
| [52b7367] | 29 | x = 25;
|
|---|
| 30 | $wait(otherProc);
|
|---|
| [a52ef0f] | 31 | $comm_destroy(comm);
|
|---|
| 32 | $gcomm_destroy(gcomm, NULL);
|
|---|
| 33 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.