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...
-
Using the scenarios in case Exhibit 9, what role does leverage play in affecting the return on equity (ROE) for CPK? What about the cost of capital? In assessing the effect of leverage on the cost of...
-
Determine the values of amplitude \(C\) and phase \(\phi\) in the relation (13.48) of harmonic oscillator given by (13.36). The proper frequency of the system is \(\omega_{o}=\sqrt{\frac{k}{m}}\),...
-
5. STATUTORY INTERPRETATION Courts interpret a statute by using the plain meaning rule; then, if necessary, legislative history and intent; and finally, if necessary, public policy. (p. 84)
-
For years The Glass Slipper restaurant has operated in a resort community near a popular ski area of New Mexico. The restaurant is busiest during the first 3 months of the year, when the ski slopes...
-
Your company has been doing well, reaching $1.09 million in earnings, and is considering launching a new product. Designing the new product has already cost $544,000. The company estimates that it...
-
The Tusquittee Company is a retail company that began operations on October 1, 2018, when it incorporated in the state of North Carolina. The Tusquittee Company is authorized to issue 100,000 shares...
-
23/01/2022, 12:03 Question 8 Quiz: AURAMA006 Assessment Task 1 1 pts identify and explain the eight (8) sections required for preparing a business case that includes a financial analysis. Write your...
-
What is a Solution Space?
-
Describe the supply chain performance metrics that are used to track the supply chain performance of a project. What is the rationale for selecting these metrics?
-
What is the relationship between a Problem Space and an Opportunity Space?
-
Define and describe the SCOR model. What are its basic processes? Discuss how the SCOR model can be applied to your organization.
-
What is a UC scenario?
-
You are an independent consultant, who is hired by a portifolio manager to develop a methodology for computing investment risk metrics using data on daily share prices of individual stocks....
-
Use the following data to answer the next two (2) questions: Product 1 Product 2 Product 3 Direct Material Cost $25,000 $30,000 $35,000 Direct Labor Cost $30,000 $40,000 $50,000 Direct Labor Hours...
-
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...
-
Comparative financial statements for the Rahul Corporation for the year ended December 31 are given below. A total of 500,000 shares of stock were outstanding. The market value of the company's stock...
-
Refer to the data in Exercise 13-15. Compute the following financial ratios for the year 2009: Data From Exercise 13-15 Comparative financial statements for the Rahul Corporation for the year ended...
-
Simply Spa Collections had a current ratio of 2.5 to 1 on December 31 of the current year. On that date, the companys assets were as follows: Required a. What was the company's current ratio on...
Study smarter with the SolutionInn App