concurrent vs iterative servers l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Concurrent vs. iterative servers PowerPoint Presentation
Download Presentation
Concurrent vs. iterative servers

Loading in 2 Seconds...

play fullscreen
1 / 8

Concurrent vs. iterative servers - PowerPoint PPT Presentation


  • 700 Views
  • Uploaded on

Concurrent vs. iterative servers. Iterative server process one request at a time Easy to build Unnecessary delay Concurrent server handles multiple requests at one time. More difficult to design and build Better performance. Fork and exec functions. #incllude<unistd.h> int fork();

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Concurrent vs. iterative servers' - Sophia


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
concurrent vs iterative servers
Concurrent vs. iterative servers
  • Iterative server
    • process one request at a time
    • Easy to build
    • Unnecessary delay
  • Concurrent server handles multiple requests at one time.
    • More difficult to design and build
    • Better performance
fork and exec functions
Fork and exec functions
  • #incllude<unistd.h>
  • int fork();
  • Return 0 in child, process ID of child in parent –1 on error
  • There are two typical uses of fork
    • A process makes a copy of itself so that one copy handle one operation while the other copy does another task.
    • A process wants to execute another program. Since the only way to create a new process is by calling fork, the process first calls fork to make a copy of itself, and then one of the copies(child) calls exec to replace itself with the new program
slide3
exec
  • #include<unistd.h>
  • int execl(const char *pathname, const char *arg0,…);
  • int execv(const char *pathname, char *const argv[]);
  • int execle(const char *pathname, const char *arg0,…, );
  • int execve(const char *pathname, char *constargv[], char *constenvp[]);
  • int execlp(const char *filename, const char *arg0,…);
  • int execvp(const char *filename, char *const argv[]);
  • All sizr return –1 on error, no return on sucess
outline for typical concurrent server
Outline for typical concurrent 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 loop

concurrent connection oriented
Concurrent, connection-oriented
  • Connection-oriented servers implement concurrency among connections rather than among individual requests.
  • Connection between client-server handle more than a single request: The protocol allow a client to repeatedly send requests and receive responses without terminating the connection or creating a new one.
algorithm parent madter
Algorithm-parent,madter
  • Create a socket and bind to the well-known address for the service being offered. Leave the socket unconnected
  • Place the socket in passive mode, making it ready for use by a server.
  • Repeatedly call accept to receive the next request from a client, and create a new process to handle the response
algorithm child slave
Algorithm-child,slave
  • Begin with a connection passed from the master(I.e. a socket for the connection)
  • Interact with the client using the connection: read request(s) and send back response(s)
  • Close the connection and exit. The slave exits after handling all requests from one client
apparent concurrency using a single thread
Apparent concurrency using a single thread
  • Create a socket and bind to the well-known port for the service.add socket to the list of those on which I/O is possible.
  • Use select to wait for I/O on existing sockets
  • If original socket is ready, use accept to obtain the next connection, and add the new socket to the list of those on which I/O is possible.
  • If some socket other than the original is ready, use recv and read to obtain the next request, forma response, and use send or write to send the response back to the client
  • Continue processing with step 2.