Process and threads are mechanisms to realize concurrency in operating systems. Answer the following questions. (a)...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Process and threads are mechanisms to realize concurrency in operating systems. Answer the following questions. (a) Using the concept of Process Control Block, contrast the concept of process and the concept of thread. (b) In relation to your answer to question 4a, describe what output you would observe and what would happen in the OS kernel in terms of process, thread, and process control blocks if you run the following program (the include lines are left out). const int STACK_SIZE = 1024 1024; 2int value = 0; 4int runner (void *param) { 5 value 7310; return 0; 7} sint main(int argc, char *argv[]) { stackTop; 9 10 11 12 13 14 15 16 24 25 char *stack, pid t pid, cpid; pid fork(); 17 printf("CHILD(pid-%d):value%d\n", getpid (), value); 18 cpid clone (runner, stackTop, CLONE_VMI SIGCHLD, NULL); 19 printf("CHILD(pid=%d):value=%d\n", getpid (), value); waitpid (cpid, NULL, 0);: 20 21 printf("CHILD(pid=%d):value=%d\n", getpid (), value); 22 27 28 29 30 31} stack = malloc (STACK_SIZE); stackTop stack + STACK_SIZE; if (pid == 0) { } else if (pid > 0) { printf ("PARENT (pid=%d) value%d\n", getpid (), value); cpid clone (runner, stackTop, SIGCHLD, NULL); printf ("PARENT (pid=%d):value%d\n", getpid (), value); waitpid (cpid, NULL, 0); } wait (NULL); printf ("PARENT (pid=%d): value%d\n", getpid (), value); (c) Explain the purpose of the two lines 13-14 in the above code, and why we write them in such a way. Process and threads are mechanisms to realize concurrency in operating systems. Answer the following questions. (a) Using the concept of Process Control Block, contrast the concept of process and the concept of thread. (b) In relation to your answer to question 4a, describe what output you would observe and what would happen in the OS kernel in terms of process, thread, and process control blocks if you run the following program (the include lines are left out). const int STACK_SIZE = 1024 1024; 2int value = 0; 4int runner (void *param) { 5 value 7310; return 0; 7} sint main(int argc, char *argv[]) { stackTop; 9 10 11 12 13 14 15 16 24 25 char *stack, pid t pid, cpid; pid fork(); 17 printf("CHILD(pid-%d):value%d\n", getpid (), value); 18 cpid clone (runner, stackTop, CLONE_VMI SIGCHLD, NULL); 19 printf("CHILD(pid=%d):value=%d\n", getpid (), value); waitpid (cpid, NULL, 0);: 20 21 printf("CHILD(pid=%d):value=%d\n", getpid (), value); 22 27 28 29 30 31} stack = malloc (STACK_SIZE); stackTop stack + STACK_SIZE; if (pid == 0) { } else if (pid > 0) { printf ("PARENT (pid=%d) value%d\n", getpid (), value); cpid clone (runner, stackTop, SIGCHLD, NULL); printf ("PARENT (pid=%d):value%d\n", getpid (), value); waitpid (cpid, NULL, 0); } wait (NULL); printf ("PARENT (pid=%d): value%d\n", getpid (), value); (c) Explain the purpose of the two lines 13-14 in the above code, and why we write them in such a way.
Expert Answer:
Answer rating: 100% (QA)
a The concept of a process and the concept of a thread both relate to concurrency in operating systems but they differ in several ways which can be contrasted using the concept of a Process Control Bl... View the full answer
Related Book For
Introduction to Management Science A Modeling and Cases Studies Approach with Spreadsheets
ISBN: 978-0078024061
5th edition
Authors: Frederick S. Hillier, Mark S. Hillier
Posted Date:
Students also viewed these operating system questions
-
c) What is an LDR? What is the effect of incident light on Vo in the following sensor circuit? 5 V w ww 1kQ LDR Vo
-
A researcher wanted to find out if there was difference between older movie goers and younger movie goers with respect to their estimates of a successful actors income. The researcher first...
-
In the following normal form game: A B C a 12; -7 10:2 0,9 B 10:1 2:4 8:5 8 4:5 8:14 16: -3 (a) (3 points) Find the pure strategy best responses. You may mark the game table but you will loose a...
-
In Exercises, find the limit. lim 5 x 0-x 813 X
-
How do insurance companies finance the real estate market?
-
Suppose we have the following requirements for a university database that is used to keep track of students' transcripts: (a) The university keeps track of each student's name (SNAME), student number...
-
Conventional management accounting systems provide the foundation for all other accounting systems.What are the main differences and links between conventional management accounting and environmental...
-
Royston Inc. is a large food processing company. It processes 120,000 kilograms of peanuts in the Peanuts Department at a cost of $160,000 to yield 10,000 kilograms of product A, 60,000 kilograms of...
-
Calculate the: net profit margin; total-sales-to-total-assets ratio; the equity multiplier; and the return on equity for both 2017 and 2018. Use yearly data for calculation. What happened between the...
-
Sound Sleeper Ltd. manufactures and sells mattresses to retailers across Canada. In 2020, Sound Sleeper signed a two-year contract with Zzz Ltd. to supply it with 40,000 mattresses at a price of $100...
-
You have been asked by the CEO of Mountaineer Company to assist in analyzing product costs. This analysis is used in internal decision making and in reporting to investors. The following Tableau...
-
Prepare the end-of-year financial reports for 2021-2022. Transactions: Date Transaction 1/7/2021 Initial capital investment of $250,000 3/7/2021 Purchased inventory for $15,000 5/7/2021 Hire 2...
-
Kendra bought 236 donuts for $130. Her profit was $40 once she had sold 100 donuts. What equation epresents Kendra's profit , p(n) as a function of the number sold, n?
-
You are a portfolio manager working for QUALDE Financial Solutions. You have computed the following information regarding four stocks listed on the New York Stock Exchange using 5 years of monthly...
-
Using the data set in column B., perform a Sensitivity Analysis on your Forecast 2023 assuming a change in COGS/Net Sales. Net Sales for Sensitivity 2023 is based on Forecast 2022 Net Sales. How does...
-
Corporation Y has taxable income as follows: 2021 2022 Taxable income before charitable contributions and NOL 10,000 10,000 Net operating loss carryforward from 2020 2,000 Charitable contributions...
-
Leonette decided that Meaghan was smart to get her business started by buying on the installment plan. That way she would have an operating expense and keep her ready cash as operating capital....
-
A 6-lb shell moving with a velocity ?? v0k explodes at point D into three fragments which hit the vertical wall at the points indicated. Fragments A, B, and C hit the wall 0.010 s, 0.018 s, and 0.012...
-
Weenies and Buns is a food processing plant that manufactures hot dogs and hot dog buns. They grind their own flour for the hot dog buns at a maximum rate of 200 pounds per week. Each hot dog bun...
-
a. Formulate and solve a linear programming model for this problem. b. What is your resulting recommendation to the school board? After seeing your recommendation, the school board expresses concern...
-
a. Ash decides to allocate $4 million to fund the exhibit. Given the pieces available and the specific requirements from Ash and Celeste, formulate and solve a binary integer programming problem to...
-
The impact of technology on internal controls includes a. Reduced processing errors. b. Elimination of the need for regular audits. c. Elimination of the need to bond employees. d. More efficient...
-
Why are revenue and expense accounts called temporary? Can you identify and list any other temporary accounts?
-
What are the major steps in preparing closing entries?
Study smarter with the SolutionInn App