- IOCP Server Model
- IOCP (Input Output Completion Port)
IOCP can process several clients request by IO Thread. IOCP can assign Threads to process after IO completed. That is, IO Information completed is enrolled to Kernel Object named Completion Port Object.
- Accept Thread (=Main Thread)
1. generate Completion Port Object
hComPort = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0)
2. connect Socket with Completion Port Object.
CreateIoCompletionPort((HANDLE)hClntSock, hComPort, (DWORD)handleInfo, 0);
2. connect Socket with Completion Port Object.
CreateIoCompletionPort((HANDLE)hClntSock, hComPort, (DWORD)handleInfo, 0);
- IO Threads
1. check IO completed
GetQueuedCompletionStatus(hComPort, &bytesTrans, (LPDWORD)&handleInfo, (LPOVERLAPPED*)&ioInfo, INFINITE);
(LPDWORD)&handleInfo <= CreateIoCompletionPort((HANDLE)hClntSock, hComPort, (DWORD)handleInfo, 0);
(LPOVERLAPPED*)&ioInfo <= WSARecv(handleInfo->hClntSock, &(ioInfo->wsaBuf), 1, &recvBytes, &flags, &(ioInfo->overlapped), NULL);
2. IO Process
GetQueuedCompletionStatus(hComPort, &bytesTrans, (LPDWORD)&handleInfo, (LPOVERLAPPED*)&ioInfo, INFINITE);
(LPDWORD)&handleInfo <= CreateIoCompletionPort((HANDLE)hClntSock, hComPort, (DWORD)handleInfo, 0);
(LPOVERLAPPED*)&ioInfo <= WSARecv(handleInfo->hClntSock, &(ioInfo->wsaBuf), 1, &recvBytes, &flags, &(ioInfo->overlapped), NULL);
2. IO Process
- IOCP Advantagement
1. IO don't need to compose repetitive statement in comparison with 'select' Server Model
2. OS manage sockets as enrolling socket to CP(Completion Port) Object
3. IOCP can adjust Thread number to process IO. Thus IOCP can block performance deterioration according to context switching.
4. IOCP can efficiently use CPU because server don't wait IO completion.
4. IOCP can efficiently use CPU because server don't wait IO completion.
- Running Screen
댓글 없음:
댓글 쓰기