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 *){
- qtime_entry* per_sec = SYSPAGE_ENTRY(qtime);
- long long PER_SEC = per_sec -> cycles_per_sec;
- printf("Thread[1]: send empty msg\n");
- long start = ClockCycles();
- MsgSend(coid, NULL,0 ,NULL, 0);
- long stop = ClockCycles();
- long res = stop - start;
- double t = (double) res / PER_SEC;
- printf("Thread[1]: Cycles = %lld\n",res);
- }
- void* funcTwo(void *){
- int rovid = MsgReceive(child, NULL, 0, 0);
- printf("Thread[2]: received msg\n");
- MsgReply(rovid, 0, NULL, 0);
- }
- int main(){
- int thread[2];
- child = ChannelCreate(0);
- coid = ConnectAttach(0,0,child,0,0);
- pthread_create(&thread[0], 0, func1, NULL);
- pthread_create(&thread[1], 0, func2, NULL);
- usleep(10000);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement