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: 50% (2 reviews)
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...
-
Utica Manufacturing (UM) was recently acquired by MegaMachines, Inc. (MM), and organized as a separate division within the company. Most manufacturing plants at MM use an ABC system, but UM has...
-
Over the past year. M. D. Ryngaert & Co. has realized an increase in its current ratio and a drop in its total assets turnover ratio. However, the company's sales, cash and marketable securities....
-
The assets of Fonzarelli Corporation are presented on the next page (000s omitted). InstructionsIndicate the deficiencies, if any, in the foregoing presentation of Fonzarelli Corporation??sassets....
-
At the start of 2020, Company developed the following budgeted total cost function: $10.07% + $195,900, where X is number of units produced. Budgeted production for the year was 10,100 unts. It...
-
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...
-
Using the following data, compute (a) The unemployment rate, (b) The employment rate, (c) The labor force participation rate. The civilian noninstitutional population = 200 million, number of...
-
on the following statement: Mona is an industrial engineer working for car parts manufacturing facility. She collected the following data on three alternatives of sustainable energy systems to be...
-
Alvarado Company produced 2,900 units of product that required 6 standard direct labor hours per unit. The standard fixed overhead cost per unit is $2.55 per direct labor hour at 16,200 hours, which...
-
Find the complexity of the function given below. void function(int n) { int i, count =0; for(i=1; i*i
-
analyze the code and fix the error Main.java 2 public class Main 3- { 4 public static void main(String[] args) { 5 6 Scanner myObj-new Scanner(System.in); 7 int count = 0; // sets count to zero CO G...
-
Please provide a reflection on interimsof a C-Level Leader of a start-up technology company, how/what strategy you will consider to grow your business.
-
The cylinder of Fig. 11.27 contains a 4-kg mixture of ideal gases at 40 8C and 200 kPa, with a molar analysis of 30% N2, 15% O2, and 55% H2. It undergoes a constant-pressure expansion until the...
-
Chris Zulliger was a chef at the Plaza Restaurant in the Snowbird Ski Resort in Utah. The restaurant is located at the base of a mountain. As a chef for the Plaza, Zulliger was instructed by his...
-
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...
-
Exercise 8-16 (Algo) Comparison of FIFO and LIFO; periodic system (LO8-1, 8-4) Alta Ski Company's inventory records contained the following information regarding its latest ski model. The company...
-
During 2014, NorthCo spent $2.10 million discovering a technical software innovation that will change the way people use their computers. This amount included $0.80 million in salaries of research...
-
kindle solve this question as soon as possible. Thank you in advance. URGENT HELP REQUIRED. Question: Determine overhead cost, using direct labor cost, direct labor hour, and machine hour methods: a....
Study smarter with the SolutionInn App