In the process-based server in Figure 12.5, we observed that there is no memory leak and the
Question:
In the process-based server in Figure 12.5, we observed that there is no memory leak and the code remains correct even when line 33 is deleted. In the threads based server in Figure 12.14, are there any chances of memory leak if lines 31 or 32 are deleted. Why?
Figure 12.5
Figure 12.14
Transcribed Image Text:
1 #include "csapp.h"
2 void echo(int connfd);
3
4
5
6
7
8
9
10
11
234
13
12 {
14
15
16
17
18
19
void sigchld_handler (int sig)
{
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
}
while (waitpid (-1, 0, WNOHANG) > 0)
int main(int argc, char **argv)
}
;
return;
int listenfd, connfd;
socklen_t clientlen;
struct sockaddr_storage clientaddr;
if (argc != 2) {
fprintf(stderr, "usage: %s
1 #include "csapp.h"
2 void echo(int connfd);
3
4
5
6
7
8
9
10
11
234
13
12 {
14
15
16
17
18
19
void sigchld_handler (int sig)
{
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
}
while (waitpid (-1, 0, WNOHANG) > 0)
int main(int argc, char **argv)
}
;
return;
int listenfd, connfd;
socklen_t clientlen;
struct sockaddr_storage clientaddr;
if (argc != 2) {
fprintf(stderr, "usage: %s \n", argv[0]);
exit(0);
}
Signal (SIGCHLD,
listenfd =
sigchld_handler);
Open listenfd (argv[1]);
while (1) {
clientlen = sizeof (struct sockaddr_storage);
}
connfd = Accept (listenfd, (SA) &clientaddr, &clientlen);
if (Fork() == 0) {
Close (listenfd); /* Child closes its listening socket */
echo (connfd); /* Child services client */
Close (connfd); /* Child closes connection with client */
exit(0);
/* Child exits */
}
Close (connfd); /* Parent closes connected socket (important!) */
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 75% (4 reviews)
Yes there are chances of memory leak if lines 31 or 32 are deleted from Figure 1214 Since the th...View the full answer
Answered By
GERALD KAMAU
non-plagiarism work, timely work and A++ work
4.40+
6+ Reviews
11+ 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
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
1. Hannah is applying for a life policy on her girlfriend Sarahs life. The policy is $500,000 and carries a large premium. Hannah is the main earner, so she is concerned about not being able to pay...
-
Chief Justice Truepenny (Guilty): Our murder statute permits no exception applicable to this case, however our sympathies may incline us to make allowance for the tragic situation in which these men...
-
Discuss the seven contemporary communication issues facing managers.
-
You are developing next years financial plan for Ajax Inc., a medium sized manufacturing company thats currently operating at 80% of factorys capacity. The firm is launching a sales promotion thats...
-
What are the normal balances for Apples Cash, Accounts Payable, and Interest Expense accounts?
-
Do Lab 12 in this chapter's appendix, but for three-stage systems. Operation is at \(293 \mathrm{~K}, 1.0 \mathrm{~atm}, \mathrm{~F}=10 \mathrm{kmol} / \mathrm{h}\) and is \(10 \mathrm{~mol} \%\)...
-
Pat's Print Shops has a warehouse that supplies paper and other supplies to its store locations. It has two service departments, Information Services (S1) and Operation Support (S2), and two...
-
Paul's car slid off the icy road, causing $3,000 in damage to his car. He was also treated for minor injuries, costing $1,000. His car insurance has a $350 deductible, after which the full loss is...
-
A. Fill each entry in the following table with Yes or No for the example program in Figure 12.15. In the first column, the notation v.t denotes an instance of variable v residing on the local stack...
-
In the server in Figure 12.8, pool.nready is reinitialized with the value obtained from the call to select. Why? Figure 12.8 1 #include "csapp.h" 2 4 5 6 7 8 9 TO 11 12 13 14 15 16 17 18 19 20 21 22...
-
KCCO, Inc., has current assets of $5,300, net BASIC fixed assets of $24,900, current liabilities of $4,600, and long-term debt of $10,300. What is the value of the shareholders' equity account for...
-
Nachos, Inc. paid $18,268.20 in interest expense on its long-term debt. If Nachos' average tax rate is 39%, what was the "tax savings" on this interest expense? (Round your answer to the nearest...
-
Jeff Krause purchased 1,000 shares of a speculative stock in January for $1.93 per share. Six months later, he sold them for $10.35 per share. He uses an online broker that charges him $10.00 per...
-
A new blu-ray player costs $94.99 in the store. What would your total cost be if the sales tax is 4.5 % ? Round your answer to the nearest cent, if necessary.
-
Have you ever witnessed ineffective vs. effective delegation while you've been at a job? In a short paragraph, describe the situation and reflect what behaviors made it ineffective or effective. (5...
-
Ha Magan is saving money and plans on making quarterly contributions into an account earning an annual interest rate of 6% compounded quarterly. If Magan would like to end up with $49,000 after 6...
-
Find the probability that a piece of data picked at random from a normal population will have a standard score (z) that lies between the following pairs of z-values: a. to z = - 2.75 z = -1.38 b. to...
-
What is the difference between direct materials and indirect materials?
-
Assume that we would like to expand the MIPS register file to 128 registers and expand the instruction set to contain four times as many instructions. 1. How this would this affect the size of each...
-
Find the shortest sequence of MIPS instructions that extracts bits 16 down to 11 from register $t0 and uses the value of this field to replace bits 31 down to 26 in register $t1 without changing the...
-
Provide a minimal set of MIPS instructions that may be used to implement the following pseudoinstruction: not $t1, $t2 // bit-wise invert
-
Who within established agency processes and legislation has the scope of responsibility for executing the below transactions (credits and debits). End of month eft payments to landlords and other...
-
The weights of newborn puppies in a large litter have a normal distribution and a mean of 12.5 lbs with a standard deviation of 3 lbs. Use the Empirical Rule to determine the percent of puppies that...
-
Las finanzas tienen como objetivo.. Seleccione una: a. La obtencin de recursos en los mercados reconocidos b. La administracin financiera del capital de trabajo c. Asignar el presupuesto del gobierno...
Study smarter with the SolutionInn App