In Figure 12.43, we might be tempted to free the allocated memory block immediately after line 14
Question:
In Figure 12.43, we might be tempted to free the allocated memory block immediately after line 14 in the main thread, instead of freeing it in the peer thread. But this would be a bad idea. Why?
Figure 12.43
Transcribed Image Text:
1 #include "csapp.h" 2 #define N 4 3 4 5 67 8 9 10 11 12 13 14 1567 18 19 20 21 22 23 24 25 26 27 28 void *thread (void *vargp); int main() { } pthread_t tid [N]; int i, *ptr; } for (i = 0; i < N; i++) { ptr Malloc(sizeof (int)); *ptr 1; Pthread_create(&tid[i], NULL, thread, ptr); = = } for (i = 0; i < N; i++) Pthread_join(tid[i], NULL); exit(0); /* Thread routine */ void *thread (void *vargp) { int myid*((int *)vargp); Free (vargp); printf("Hello from thread %d\n", myid); return NULL;
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 0% (1 review)
If we free the block immediately after the ca...View the full answer
Answered By
Diane Joyce Pastorin
Please accept my enthusiastic application to solutioninn. I would love the opportunity to be a hardworking, passionate member of your tutoring program. As soon as I read the description of the program, I knew I was a well-qualified candidate for the position.
I have extensive tutoring experience in a variety of fields. I have tutored in English as well as Calculus. I have helped students learn to analyze literature, write essays, understand historical events, and graph parabolas. Your program requires that tutors be able to assist students in multiple subjects, and my experience would allow me to do just that.
You also state in your job posting that you require tutors that can work with students of all ages. As a summer camp counselor, I have experience working with preschool and kindergarten-age students. I have also tutored middle school students in reading, as well as college and high school students. Through these tutoring and counseling positions, I have learned how to best teach each age group.
4.60+
2+ Reviews
10+ Question Solved
Related Book For
Computer Systems A Programmers Perspective
ISBN: 9781292101767
3rd Global Edition
Authors: Randal E. Bryant, David R. O'Hallaron
Question Posted:
Students also viewed these Computer science questions
-
Hyten Corporation On June 5, 1998, a meeting was held at Hyten Corporation, between Bill Knapp, Director of Marketing/Sales, and John Rich, director of engineering. The purpose of the meeting was to...
-
Never mind computers and tech services. IBM's radical new focus is on revamping customers' operations -- and even running them It was over a lunch in Cincinnati two years ago that IBM Chief Executive...
-
Assignment 5: Hash Table implementation andconcordance There are three parts to this assignment. In the first two parts,you will complete the implementation of a hash map and aconcordance program. In...
-
When Ralph Lauren makes shirts to a customers exact preferences, what utility is provided?
-
Broxholme Industries has sales of $40 million, equity totaling $27.5 million, and an ROS of 12%. The sustainable growth rate has been calculated at 10.9%. What dividend payout ratio was assumed in...
-
Ryan Newton recently received the following information related to Ryan Companys December 31, 2014, balance sheet. Inventory ...............$ 2,900 Cash ................. 4,300 Equipment...
-
Organic Co. makes a variety of products from a joint process. The joint cost per batch run is \(\$ 30,000\) and each batch produces the following products: How would you classify each product (joint,...
-
Questions 13 use the following data: Assume that Fast Networks owns the following long-term available-for-sale investments: 1. Fasts balance sheet should report a. investments of $65,100. b....
-
Value an investment income stream of $1,650pa received at the end of each year for 16 years where your client requires a yield of 7% pa and the best safe accumulative rate is 4% pa. Round your answer...
-
In Linux systems, typing Ctrl+D indicates EOF on standard input. What happens if you type Ctrl+D to the program in Figure 12.6 while it is echoing each line of the client? Figure 12.6 1 #include...
-
Assume that a CGI program needs to send dynamic content to the client. This is typically done by making the CGI program send its content to the standard output. Explain how this content is sent to...
-
The probability that more than 500 adult Americans support a bill proposing to extend daylight savings time A discrete random variable is given. Assume the probability of the random variable will be...
-
Select a useful case brief format. Use the right caption when naming the brief. Identify the case facts. Outline the procedural history. State the issues in question. State the holding in your words....
-
At what annual interest rate, compounded annually, would $510 have to be invested for it to grow to $1,895.64 in 15 years?
-
In Tomcik v. Ohio Dep't of Rehabilitation & Correction , 20Links to an external site. the plaintiff, Janet Tomcik, was in the custody of the defendant, a penal institution. As part of the...
-
ABC Company's balance sheets for March appear below: March 1 March 31 ASSETS : Cash 29,000 17,000 Accounts receivable 55,000 64,000 Inventory 49,000 38,000 Land 31,000 94,000 LIABILITIES + EQUITY :...
-
Discuss the criminal offences and privacy torts that could be applied to the following scenario. Please provide examples of at least 2 torts and 2 criminal offences, discuss elements of criminal...
-
a. Find the area under the standard normal curve to the left of z = 0 P(z < 0) b. Find the area under the standard normal curve to the right of z = 0 P(z> 0)
-
Why is inventory management important for merchandising and manufacturing firms and what are the main tradeoffs for firms in managing their inventory?
-
Calculate by hand 8.625 10 1 divided by -4.875 10 0 . Show all the steps necessary to achieve your answer. Assume there is a guard, a round bit, and a sticky bit, and use them if necessary. Write...
-
Calculate (3.984375 10 - 1 + 3.4375 10 -1 ) + 1.771 10 3 by hand, assuming each of the values are stored in the 16-bit half precision format described in Exercise 3.27 (and also described in the...
-
Calculate 3.984375 10 -1 + (3.4375 10 -1 + 1.771 10 3 ) by hand, assuming each of the values are stored in the 16-bit half precision format described in Exercise 3.27 (and also described in the...
-
Suppose you have received a tax refund in the amount of $2,000. While you are tempted to spend it immediately on the newest iPhone, a FitBit, and some new clothes, you have decided to be financially...
-
(Please ignore the $ sign when you insert your answer and round your answer to two decimal places if needed).Assume that ReOI for the next year is expected to be $192,212 and to be so forever. Cost...
-
Kiser Mfg. is considering a rights offer. The company has determined that the ex-rights price will be $78. The current price is $100 per share, and there are 25 million shares outstanding. The rights...
Study smarter with the SolutionInn App