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
52+ 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...
-
The following transactions occurred in October at Pawnee Workshops, a custom manufacturer of furniture: 1. Purchased $16,000 of materials. 2. Issued $800 of supplies from the materials inventory. 3....
-
Provide additional information about the salesquantity variance by calculating the market-share and market-size variances
-
Cost-plus target return on investment pricing. John Beck is the managing partner of a business that has just finished building a 60-room motel. Beck anticipates that he will rent these rooms for...
-
Futura Company purchases the 62,000 starters that it installs in its standard line of farm tractors from a supplier for the price of $10.80 per unit. Due to a reduction in output, the company now has...
-
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...
-
Given the operation times provided: a. Develop a job sequence that minimizes idle time at the two work centers. b. Construct a chart of the activities at the two centers, and determine each ones idle...
-
Using the perpetual inventory system, calculate the ending inventory and Cost of Goods Sold under each of the following methods. Beginning Inventory 10 units @ $1 Purchases January 5 January 20 20...
-
the manager of wongs food express estimates operating costs for the year will total $300,000 for fixed costs. 28. find the sales dollars required with a contribution margin ratio of 40 percent to...
-
Tara Williams and Tilly North had been yoga buddies for almost a decade. Yoga was an escape from the daily stresses of being working parents for both of them. One thing Tara and Tilly always talked...
-
4) This question concerns the simulation of price trajectories in the Black-Scholes model. We therefore want to simulate price vectors: (St St, Str); where tiit, i=0,1,..., n. The total number of...
-
Consider a pure exchange economy with two goods, (x,y), and two consumers, (1,2). Con- sumers' endowments are e (4,2) and e = (6,6) and their preferences are represented by utility functions: u(x,y)...
-
Determine the relative humidity and the partial pressure of the dry air if, for the atmospheric air: a) Tdb 5 60 8F, P atm 5 14.5 psia, and v 5 0.01 lbm v /lbm a b) Tdb 5 95 8F, P atm 5 14.3 psia,...
-
Listed below are common types of current liabilities, contingencies, and commitments: a. Accounts payable b. Bank loans and commercial paper c. Notes payable d. Dividends payable e. Sales and excise...
-
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...
-
On February 1, 2021, the Xilon Corporation issued 50,000 shares of its no-par common stock in exchange for five acres of land located in the city of Monrovia. On the date of the acquisition, Xilon's...
-
Consolidated statement of financial position Austin buys all of the share capital of Reed on 31 December 2007 The SFPs of the two companies at 31 December 20x7. are as follows: Austin Reed $...
-
On January 1, 2017, Metlock Inc. borrowed and received $400,000 from a major customer, Bridgeport Corp. The debt is evidenced by a zero-interest-bearing note due in 4 years. Metlock, as consideration...
Study smarter with the SolutionInn App