Advertisement
Aaaaa988

source

Dec 24th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <pthread.h>
  3. #include <unistd.h>
  4. #include <stdlib.h>
  5. #include <sys/types.h>
  6. #include <sys/stat.h>
  7. #include <fcntl.h>
  8. #include <sys/neutrino.h>
  9. #include <sys/syspage.h>
  10. #include <iostream>
  11.  
  12.  
  13. using namespace std;
  14.  
  15. int coid;
  16.  
  17. void* func(void *){
  18. long long start, stop, res;
  19. char msg = '', rmsg;
  20.  
  21. qtime_entry* t = SYSPAGE_ENTRY(qtime);
  22. long long PER_SEC = t->cycles_per_sec;
  23.  
  24. printf("[Client]: send empty msg\n");
  25. start = ClockCycles();
  26. MsgSend(coid, NULL, 0, NULL, 0);
  27. stop = ClockCycles();
  28. res = stop = start;
  29. double sec = (double) res / PER_SEC;
  30. printf("[Client]\n);
  31. printf("Client: Time = %.10f\n",sec);
  32.  
  33. }
  34.  
  35. int main(){
  36. int child;
  37. int pid;
  38. int thread;
  39.  
  40. int fd = open('taskOne.txt', O_RDWR);
  41. read(fd, &pid, 4);
  42. read(fd, &child, 4);
  43.  
  44. printf("Client connect to: pid = %d; child = %d;\n",pid,child);
  45. coid = ConnectAttach(0, pid, child, 0, 0);
  46.  
  47. pthread_create(&thread, 0, func, NULL);
  48.  
  49. usleep(100000);
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement