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
-
It is costly in both time and money to go to college. Does it pay off? According to the Bureau of the Census, the answer is yes. The average annual income (in thousands of dollars) of a household...
-
Imagine that you work for the small brick-and-mortar business. The owner of your business wants to focus on generating new revenue through e-commerce, but she knows that this change in operations...
-
Ambassador Watch Company budgeted the following costs for anticipated production for April 2002: Prepare a factory overhead cost budget, separating variable and fixed costs. Assume that all indirect...
-
The motion of the uniform rod AB of mass 8 kg and length h L = 900 mm is guided by small wheels of negligible mass that roll on the surface shown. If the rod is released from rest when =20?,...
-
Becton Labs, Inc., produces various chemical compounds for industrial use. One compound, called Fludex, is prepared using an elaborate distilling process. The company has developed standard costs for...
-
If carbon dioxide is present in the atmosphere, then plants have a source of carbon. Hence, since plants have a source of carbon, carbon dioxide is present in the atmosphere. Use the counterexample...
-
Sandhill Company is considering the purchase of an investment of $271000. Data related to the investment are as follows: Cash flows (at the end of the next four years) Salvage value Tax Rate $149000...
-
Based on CIA (Covered Interest Arbitrage), the spot Yen/US$ exchange rate is Yen100/US$ (i.e., 100 Japanese yen per 1 U.S. dollar) and the one year forward rate is Yen200/US$. If the annual interest...
-
At the beginning of this year, a firm had $30M in cash, $20M in accounts receivable, $45M in inventory and $10M in taxes payable. Going forward, the firm plans to finance some of its inventory with...
-
You are considering a project that will cost you $60,000 today and is projected to earn $5,000 next year, with the inflows growing at a 4% annual rate in perpetuity thereafter. If your cost of...
-
Great Gator Gifts (GGG) launched a Go-Gators Club, where Gator fans can get a special preview and purchase unique Gator items. GGG attracted new customers at a cost of $55.00 each and tracked their...
-
China has a crawl-like arrangement for its exchange rate regime. what arepros and cons of such an arrangement?,which would you want it to be if you could change it and why?
-
You are the newly hired controller for Everest, Inc., a major online retailer of consumer goods. Everest keeps a large inventory of consumer goods on hand for quick shipment to consumers. The CEO of...
-
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...
-
A particle of pure \(\mathrm{NaCl}\) is dissolving in an aqueous liquid solution at \(18^{\circ} \mathrm{C}\). The dissolution of the particle is controlled by mass transfer. The system is vigorously...
-
Calculate the value of Maxwell-Stefan diffusivity for ethanol water at \(40^{\circ} \mathrm{C}\) for ethanol mole fractions of \(0.0,0.2,0.3,0.4,0.7\), and 1.0 . The Fickian diffusivities are...
-
A crystal particle of pure \(\mathrm{NaCl}\) is dissolving in an aqueous liquid (water) solution at \(18^{\circ} \mathrm{C}\). The dissolution of the particle is controlled by mass transfer. The...
Study smarter with the SolutionInn App