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
46+ 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...
-
Presented below are the financial statements of Rajesh Company. Rajesh Company Comparative Statements of Financial Position December 31 Rajesh Company Income Statement For the Year Ended December 31,...
-
What are the requirements of a modern surface condenser ?
-
M. M. Sprout, a catalog mail order retailer, has one customer service representative (CSR) to take orders at an 800 telephone number. If the CSR is busy, the next caller is put on hold. For...
-
Calculate the details of working capital? current ratio = 3 . 5 liquid ratio = 2 . 5 stock turnover ratio = 6 time debtor collection period = 3 months gross profit ratio = 2 0 % net working capital...
-
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...
-
Critically discuss the saying turnover is vanity, profit is sanity but cash is reality.
-
Why is strategic audit recommended in case study analysis for students?
-
Identify the common signs that indicate an outsourcing strategy is not executed effectively.
-
Explain the role of executive leadership in building the strategic vision in corporations.
-
Is downsizing a good strategy for revamping an organizations competitiveness when it is facing major competitive threats in the market?
-
Why is EVA an important component of the strategic management process?
-
Describe the two basic types of acquisitions that can result in a business combination.
-
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...
-
A pool has three water faucet and one drain faucet. The first water faucet can fill up the pool in 3 hours, the second water faucet can fill up the pool in 4 hours, and the third water faucet can...
-
5. One particular equation involving energy states that E = 1mv where the energy E has 2 units of joules (J), the mass m is in units of kg, and the velocity v is in units of m/s. Another energy...
-
The figure shown gives the position of a car moving in the x-direction as a function of time, x(t). Four times are marked by blue squares and labeled A - D. For which times is the acceleration of the...
Study smarter with the SolutionInn App