Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <errno.h>
- #include <string.h>
- #include <signal.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <sys/wait.h>
- #include <time.h>
- #define LEN 10000
- // 1 gig is 256 million ints
- // 1 int 4 bytes
- int main()
- {
- int data[LEN];
- srand(time(NULL));
- for (int i = 0; i < LEN; i++)
- {
- // should only be called once
- data[i] = rand() % (10 + 1 - 0) + 0;
- //printf("generated: %ld",data[i]);
- }
- printf("int arr created\n");
- int childpid = fork();
- long int test = 0;
- if (childpid == 0) {
- int roura2 = open("/tmp/trubka", O_WRONLY | O_NONBLOCK);
- printf("Trubka otevrena PRO zapis %d\n", roura2);
- for (long int i = 0; i < 250; i++) {
- for (long j= 0; j < LEN+1; j++)
- {
- test += data[j];
- printf("i: %d, TEST: %ld\n",j, test);
- }
- printf("DEBUG");
- printf("i: %ld",i);
- int ret = write(roura2, data, sizeof(data));
- }
- printf("TEST END: %ld", test);
- }
- else {
- int roura = open("/tmp/trubka", O_RDONLY | O_NONBLOCK);
- printf("Trubka otevrena PRO CTENI %d\n", roura);
- for (int i = 0; i < 2500000; i++) {
- int ret2 = read(roura, data, sizeof(data));
- }
- }
- /* remove the FIFO */
- //close(roura);
- printf("end");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement