Question: what is the output and please explain the code how many processes and threads were created what are the contents of emilia.txt is line 28
what is the output and please explain the code how many processes and threads were created what are the contents of emilia.txt is line 28 important what is the purpose of dub2
1 void* rem (void *args) { 2 3 4} 5 void* ram (void *args) { 6 7 18 19 20 21 8} 9 int main(void) { 10 11 12 13 14 15 16 17 22 23 24 25 26 27 28 29 30 printf("Blue: %d ", *((int*) args)); exit(0); 31 32} printf("Pink: %d ", ((int*) args)[0]); return NULL; pid_t pid; pthread_t pthread; int status; //declaring vars int fd = open("emilia.txt", O_CREAT | O_TRUNC | O_WRONLY, 0666); int *subaru = (int*) calloc(1, sizeof(int)); printf("Original: %d ", *subaru); if(pid = fork()) { *subaru = 1337; pid = fork(); } if(!pid) { } else { pthread_create(&pthread, NULL, ram, (void*) subaru); for (int i = 0; i < 2; i++) waitpid (-1, &status, 0); pthread_create(&pthread, NULL, rem, (void *) subaru); } pthread_join(pthread, NULL); if(*subaru == 1337) dup2 (fd, fileno (stdout)); printf("All done! "); return 0;
Step by Step Solution
3.43 Rating (150 Votes )
There are 3 Steps involved in it
OUTPUT Original 0 Blue 0 All done Explanation This C program creates 3 processes and 2 threads The main process creates two child processes using the ... View full answer
Get step-by-step solutions from verified subject matter experts
