In the server in Figure 12.8, pool.nready is reinitialized with the value obtained from the call to
Question:
In the server in Figure 12.8, pool.nready is reinitialized with the value obtained from the call to select. Why?
Figure 12.8
Transcribed Image Text:
1 #include "csapp.h"
2
4
5
6
7
8
9
TO
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
typedef struct { / Represents a pool of connected descriptors /
/ Largest descriptor in read set */
fd_aet read_set; / Set of all active descriptors */
int maxid;
Id set ready_set; / Subset of descriptors ready for reading /
int ready:
/* Number of ready descriptors from select */
int maxi;
/ High water index into client array */
int clientfd [FD_SETSIZE]: / Set of active descriptors /
rio_t clientrio [FD_SETSIZE]: / Set of active read buffers /
} pool;
int byte_cnt = 0; /* Counts total bytes received by server +/
int main(int arge, char *argv)
{
36
37
38
39
40
41
42
43
44 }
int listenfd, connfd;
socklen_t clientlen;
struct sockaddr_storage clientaddr;
static pool pool;
11 (argc ! 2) {
fprintf(stderr, "usage: %s
1 #include "csapp.h"
2
4
5
6
7
8
9
TO
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
typedef struct { / Represents a pool of connected descriptors /
/ Largest descriptor in read set */
fd_aet read_set; / Set of all active descriptors */
int maxid;
Id set ready_set; / Subset of descriptors ready for reading /
int ready:
/* Number of ready descriptors from select */
int maxi;
/ High water index into client array */
int clientfd [FD_SETSIZE]: / Set of active descriptors /
rio_t clientrio [FD_SETSIZE]: / Set of active read buffers /
} pool;
int byte_cnt = 0; /* Counts total bytes received by server +/
int main(int arge, char *argv)
{
36
37
38
39
40
41
42
43
44 }
int listenfd, connfd;
socklen_t clientlen;
struct sockaddr_storage clientaddr;
static pool pool;
11 (argc ! 2) {
fprintf(stderr, "usage: %s \n", argv[0]);
exit(0);
}
listenfd Open_11stenfd (argv[1]);
init_pool (11stenfd, pool);
while (1) {
/* Wait for listening/connected descriptor(s) to become ready /
}
pool.ready_set-pool.read_set;
pool.nready Select (pool.maxrd+1, Epool.ready_set, NULL, NULL, NULL);
/* If listening descriptor ready, add new client to pool /
11 (FD ISSET (11stenrd, &pool.ready_set)) {
}
clientlen - sizeof (struct sockaddr_storage);
connfd- Accept (11stenfd, (SA)&clientaddr, &clientlen);
add_client (connfd, &pool);
/* Echo a text line from each ready connected descriptor +/
check_clients (@pool);
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 0% (2 reviews)
poolnready is an integer variable We r...View the full answer
Answered By
Jeff Omollo
As an educator I have had the opportunity to work with students of all ages and backgrounds. Throughout my career, I have developed a teaching style that encourages student engagement and promotes active learning. My education and tutoring skills has enabled me to empower students to become lifelong learners.
5.00+
5+ Reviews
49+ 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
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
a. Stock market index information: S&P 500 (stock) index level: Nasdaq Composite (stock) index level: b. Interest rate information : Prime rate: Federal funds rate: Commercial paper rate (90 days):...
-
In this problem, you will perform the operating procedures necessary to maintain inventory stock items and process purchase orders, purchase invoices, and cash payment transactions for the week of...
-
What are the concepts of traditional and contemporary organizational design? Will these designs be influenced differently by management and the environment?
-
Youre a new member of the planning staff within the finance department at Bertram Enterprises, a large manufacturer of household goods. The firm does an annual operating plan and a long-range plan...
-
A convertible bond has a par value of $1,000 and a conversion price of $40. The stock currently trades for $30 a share. What are the bonds conversion ratio and conversion value at t = 0?
-
Design a stack effect/solar chimney (vented Trombe wall) to produce an average velocity of \(0.3 \mathrm{~m} / \mathrm{s}\) within a \(4 \mathrm{~m}\) wide by \(5 \mathrm{~m}\) long by \(3...
-
VOC Industries Inc. manufactures recreational vehicles. VOC uses a job order cost system. The time tickets from May jobs are summarized below. Job 301 ........... $ 6,700 Job 302 ...........5,100 Job...
-
Build an erd diagram showing the appropriate relationships for the entities team, coach, player, stats, awards, and all star games.
-
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...
-
Let us determine the behavior of the instruction pushq %rsp for an x86-64 processor. We could try reading the Intel documentation on this instruction, but a simpler approach is to conduct an...
-
List the three major forms of business. a. What form is most common? b. What form accounts for the largest proportion of sales?
-
On November 23, 2023, Hamlet acquires and places in service a 7-year class asset with a cost of $100,000 (the only asset acquired during the year). Hamlet does not elect immediate expensing under...
-
Vaughn Manufacturing developed the following data for the current year: Beginning Work in Process Inventory $141000 Direct materials used 208000 Actual overhead 176000 Overhead applied 184000 Cost of...
-
Pacifica Industrial Products Corporation makes two products, Product H and Product L. Product H is expected to sell 41,000 units next year and Product L is expected to sell 8,200 units. A unit of...
-
Describe seniority and longevity pay practices, elements of merit pay, and examples of performance appraisal methods. What are some drawbacks to at least one from each category?
-
What's the history with Prince Harry and Meghan Markle with the palace and why it was a big deal for Markle to not attend the coronation of King Charles?
-
The most probable velocity ump is the velocity possessed by the greatest number of gas particles. At a certain temperature, the probability that a gas particle has the most probable velocity is equal...
-
What are technical skills At what level are they most important and why?
-
For the following C statement, write a minimal sequence of MIPS assembly instructions that does the identical operation. Assume $t1 = A, $t2 = B, and $s1 is the base address of C. A = C[0] < < 4;
-
Assume $t0 holds the value 0x00101000. What is the value of $t2 aft er the following instructions? $t2, $0, slt $t0 bne $t2, $0, ELSE DONE ELSE: addi $t2, $t2, 2 DONE:
-
Suppose the program counter (PC) is set to 0x2000 0000. Is it possible to use the jump (j) MIPS assembly instruction to set the PC to the address as 0x4000 0000? Is it possible to use the...
-
13. Which of the following is not part of the second line of defense? a. pH of the skin b. Cytokines c. Phagocytosis d. Fever 14. Cells infected with a virus produce glycoproteins that interfere with...
-
Marie Tess Co. wants to evaluate a potential investment decision. Ex Corp. and Way Corp. are being eyed for this investment. Ex Corp is a pretty stable firm with a net income of P500,000. Ex...
-
10. When an organ or tissue is transplanted between genetically different individuals it is called a(n) a. xenograft. b. isograft. c. autograft. d. allograft. 11. Which of the following blood types...
Study smarter with the SolutionInn App