Simultaneous versus iterative servers .


44 views
Uploaded on:
Description
Fork and executive capacities.
Transcripts
Slide 1

Simultaneous versus iterative servers Iterative server prepare one demand at once Easy to construct Unnecessary postpone Concurrent server handles different demands at one time. More hard to outline and assemble Better execution

Slide 2

Fork and executive capacities #incllude<unistd.h> int fork(); Return 0 in youngster, prepare ID of kid in parent –1 on mistake There are two run of the mill employments of fork A procedure makes a duplicate of itself with the goal that one duplicate handle one operation while the other duplicate does another errand. A procedure needs to execute another program. Since the best way to make another procedure is by calling fork, the procedure first calls fork to make a duplicate of itself, and after that one of the copies(child) calls executive to supplant itself with the new program

Slide 3

executive #include<unistd.h> int execl(const scorch *pathname, const burn *arg0,… ); int execv(const roast *pathname, singe *const argv[]); int execle(const roast *pathname, const burn *arg0,… , ); int execve(const roast *pathname, burn *constargv[], singe *constenvp[]); int execlp(const burn *filename, const burn *arg0,… ); int execvp(const scorch *filename, singe *const argv[]); All sizr return –1 on blunder, no arrival on sucess

Slide 4

Outline for common simultaneous server int pid,s, conn; S = Socket( .. );/fill in server address Bind(s, ..); Listen(s, LISTNQ); while(1){ conn = Accept(s, ..); if( (pid = fork()) ==0) { close (s); doit( conn); close(conn); exit(0); }/end of if close(conn); }//end of while circle

Slide 5

Concurrent, association arranged Connection-situated servers actualize simultaneousness among associations as opposed to among individual solicitations. Association between customer server handle more than a solitary demand: The convention permit a customer to over and again send asks for and get reactions without ending the association or making another one.

Slide 6

Algorithm-parent,madter Create an attachment and tie to the outstanding location for the administration being advertised. Leave the attachment detached Place the attachment in uninvolved mode, making it prepared for use by a server. Over and over call acknowledge to get the following solicitation from a customer, and make another procedure to handle the reaction

Slide 7

Algorithm-child,slave Begin with an association go from the master(I.e. an attachment for the association) Interact with the customer utilizing the association: read request(s) and send back response(s) Close the association and exit. The slave exits in the wake of taking care of all solicitations from one customer

Slide 8

Apparent simultaneousness utilizing a solitary string Create an attachment and tie to the outstanding port for the service.add attachment to the rundown of those on which I/O is conceivable. Utilize select to sit tight for I/O on existing attachments If unique attachment is prepared, utilize acknowledge to acquire the following association, and add the new attachment to the rundown of those on which I/O is conceivable. In the event that some attachment other than the first is prepared, utilize recv and perused to get the following solicitation, forma reaction, and utilize send or compose to send the reaction back to the customer Continue handling with step 2.

Recommended
View more...