Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <pthread.h>
- #include <unistd.h>
- #include <stdlib.h>
- #include <sys/neutrino.h>
- #include <sys/syspage.h>
- #include <iostream>
- using namespace std;
- int child;
- int coid;
- void* funcOne(void *){
- printf("Thread[0]: send empty msg\n");
- long start = ClockCycles();
- MsgSend(coid, NULL,0 ,NULL, 0);
- long stop = ClockCycles();
- long res = stop - start;
- printf("Thread[0]: Cycles = %lld\n",res);
- }
- void* funcTwo(void *){
- int rovid = MsgReceive(child, NULL, 0, 0);
- printf("Thread[1]: received msg\n");
- MsgReply(rovid, 0, NULL, 0);
- }
- int main(){
- int threadOne;
- int threadTwo;
- child = ChannelCreate(0);
- coid = ConnectAttach(0,0,child,0,0);
- pthread_create(&threadOne, 0, funcOne, NULL);
- pthread_create(&threadTwo, 0, funcTwo, NULL);
- usleep(10000);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement