Advertisement
Guest User

Untitled

a guest
Oct 17th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <errno.h>
  5. #include <string.h>
  6. #include <signal.h>
  7. #include <sys/types.h>
  8. #include <sys/stat.h>
  9. #include <fcntl.h>
  10. #include <sys/wait.h>
  11.  
  12. #define LEN 65000
  13.  
  14. // 1 gig is 256 million ints
  15.  
  16. int main()
  17. {
  18.  
  19. char data[65000];
  20. int childpid = fork();
  21. if (childpid == 0) {
  22. int roura2 = open("/tmp/trubka", O_WRONLY);
  23. printf("Trubka otevrena PRO zapis %d\n", roura2);
  24.  
  25. for (int i = 0; i < 1500000; i++) {
  26.  
  27. int ret = write(roura2, data, sizeof(data));
  28. }
  29. }
  30. else {
  31. int roura = open("/tmp/trubka", O_RDONLY | O_NONBLOCK);
  32. printf("Trubka otevrena PRO CTENI %d\n", roura);
  33.  
  34. for (int i = 0; i < 1500000; i++) {
  35.  
  36.  
  37. int ret2 = read(roura, data, sizeof(data));
  38.  
  39. }
  40. }
  41.  
  42. /* remove the FIFO */
  43. //close(roura);
  44. printf("end");
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement