what is the output and please explain the code how many processes and threads were created what
Fantastic news! We've Found the answer you've been seeking!
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 important what is the purpose of dub2
Transcribed Image Text:
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\n", *((int*) args)); exit(0); 31 32} printf("Pink: %d\n", ((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\n", *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!\n"); return 0; 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\n", *((int*) args)); exit(0); 31 32} printf("Pink: %d\n", ((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\n", *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!\n"); return 0;
Expert Answer:
Answer rating: 100% (QA)
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 the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these operating system questions
-
Question How do you design object oriented design models using: a. Model Driven Development (MDD) Assume scenarios or examples to elaborate.
-
Why due diligence, both legal and financial, is important for the song catalog purchase? Why it is important to understand the details of sources of income, how and when it is earned, and how it is...
-
Three transactions for Sunland Gifts are presented here. On October 2, Sunland Gifts purchased $35,500 of merchandise from Sea Toys, terms 1/10, n/30. On October 6, Sunland Gifts returned $2,800 of...
-
For this project, you must select an employer organization and research the organizations employee benefits package (plan). After you research the organizations employee benefits package, collect...
-
Amino acid analysis of a certain tetrapeptide gave alanine, glycine, phenylalanine, and valine in equimolar amounts. What amino acid sequences are possible for this tetrapeptide?
-
The financial statements for Castile Products, Inc., are given below: Account balances at the beginning of the year were accounts receivable, $25,000; and inventory, $60,000. All sales were on...
-
If the 1.5-in.-diameter supporting rods are made from 2014-T6 aluminum, determine the average normal stress developed in each rod when P = 80 kip. D 4 ft 3 ft C A P 3 ft B
-
Data for the North, South, East, and West divisions of Free Bird Company are as follows: a. Determine the missing items, identifying each by the letters (a) through (l). Round percents and investment...
-
Would you be able to recreate the planning and strategic management process that Mr. Nadella used? What would Microsoft's planning flowchart look like based on the goal he proposed? Did Mr. Nadella...
-
A dog training business began on December 1. The following transactions occurred during its first month. December 1 Receives $23,000 cash as an owner investment in exchange for common stock. December...
-
Seek power series solution of the given differential equation about the given point x 0 ; Find the recurrence relation.
-
Sludge is wet solids taht result from the processing in sewage systems. The sludge has to be dried before it can be composed or otherwise handled. if a sludge containing 70% water and 30% solids is...
-
Ruzgar Inc., bonds were selling at $1,040 a year ago. A friend of yours invested into this bond and just received a $100 coupon payment. She sold the bond today for $1,200.If the inflation rate for...
-
What is the purpose of interrupts? How does an interrupt differ from a trap? Can traps be generated intentionally by a user program? If so, for what purpose? List system calls that have to be...
-
One Operating Expense that should be treated as a Capital Expense . Use real numbers from the most recent financial statements of Apple Inc. on SEC, create a capital asset (5 Points) and describe...
-
Jackson and Ashley Turner ( both 4 5 years old ) are married and want to contribute to a Roth IRA for Ashley. In 2 0 2 3 , their AGI is $ 2 2 4 , 3 0 0 . Jackson and Ashley each earned half of the...
-
1. Use any technique taught in previous sections to find each of the following integrals. (b) x* In xdx sin x + secx (a) sinx- tan x -dx (e) (x-2)(x+4) dx (1) sin 2xx (1) In 2 dx (j) dx (c) [ 07...
-
The Taylor's series expansion for cosx about x = 0 is given by: where x is in radians. Write a user-defined function that determines cosx using Taylor's series expansion. For function name and...
-
Phil and Linda are 25-year-old newlyweds and file a joint tax return. Linda is covered by a retirement plan at work, but Phil is not. a. Assuming Phil's wages were $27,000 and Linda's wages were...
-
In 2012, Gale and Cathy Alexander hosted an exchange student, Axel Muller, for 9 months. Axel was part of International Student Exchange Programs (a qualified organization). Axel attended tenth grade...
-
Mallory Corporation has a calendar year-end. The corporation has paid estimated payments of $10,000 during 2012 but still owes an additional $5,000 for its 2012 tax year. a. When is the 2012 tax...
-
In a vapour compression refrigeration system, the condition of refrigerant before entering the compressor is (a) saturated liquid (b) wet vapour (c) dry saturated liquid (d) superheated vapour
-
During a refrigeration cycle, heat is rejected by the refrigerant in (a) compressor (b) condenser (c) evaporator (d) expansion valve
-
The highest temperature during the cycle in vapour compression refrigeration system occurs after (a) compression (b) condensation (c) expansion (d) evaporation
Study smarter with the SolutionInn App