Advertisement
Aaaaa988

fromQNX Main

Dec 24th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <pthread.h>
  3. #include <unistd.h>
  4. #include <stdlib.h>
  5. #include <sys/neutrino.h>
  6. #include <sys/syspage.h>
  7. #include <iostream>
  8.  
  9. using namespace std;
  10.  
  11. int child;
  12. int coid;
  13.  
  14. void* funcOne(void *){
  15. printf("Thread[0]: send empty msg\n");
  16. long start = ClockCycles();
  17. MsgSend(coid, NULL,0 ,NULL, 0);
  18. long stop = ClockCycles();
  19. long res = stop - start;
  20.  
  21. printf("Thread[0]: Cycles = %lld\n",res);
  22. }
  23.  
  24. void* funcTwo(void *){
  25. int rovid = MsgReceive(child, NULL, 0, 0);
  26. printf("Thread[1]: received msg\n");
  27. MsgReply(rovid, 0, NULL, 0);
  28. }
  29.  
  30. int main(){
  31. int threadOne;
  32. int threadTwo;
  33. child = ChannelCreate(0);
  34. coid = ConnectAttach(0,0,child,0,0);
  35.  
  36. pthread_create(&threadOne, 0, funcOne, NULL);
  37. pthread_create(&threadTwo, 0, funcTwo, NULL);
  38.  
  39. usleep(10000);
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement