Types of Server Concurrency

Types of Server Concurrency - Types of Server Concurrency...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Types of Server Concurrency Iterative Server Fork Process After Request Create New Thread After Request Pool of Threads Pool of Processes
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Iterative Server void iterativeServer( int masterSocket) { while (1) { int slaveSocket =accept(masterSocket, &sockInfo, &alen); if (slaveSocket >= 0) { dispatchHTTP(slaveSocket); } } } Note: We assume that dispatchHTTP itself closes slaveSocket.
Background image of page 2
Fork Process After Request void forkServer( int masterSocket) { while (1) { int slaveSocket = accept(masterSocket, &sockInfo, &alen); if (slaveSocket >= 0) { int ret = fork(); ` if (ret == 0) { dispatchHTTP(slaveSocket); exit(0); } close(slaveSocket); } } }
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Create Thread After Request void createThreadForEachRequest(int masterSocket) { while (1) { int slaveSocket = accept(masterSocket, &sockInfo, &alen); if (slaveSocket >= 0) { pthread_create(&thread, NULL, dispatchHTTP, slaveSocket); } } }
Background image of page 4
Pool of Threads void poolOfThreads( int masterSocket ) { for (int i=0; i<4; i++) { pthread_create(&thread[i], NULL, loopthread,
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

Types of Server Concurrency - Types of Server Concurrency...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online