io_completion_port - IEG 4180 IEG 4180 Network Software...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: IEG 4180 IEG 4180 Network Software Design and Programming Network Software Design and Programming I/O Completion Port I/O Completion Port IEG4180: Network Software Design and Programming - I/O Completion Port 2 Copyright Jack Y. B. Lee All Rights Reserved Contents • 1. Introduction • 2. Threading Models • 3. I/O-based Thread Scheduling • 4. Win32 I/O Completion Port • 5. Threads Management • 6. I/O-based Concurrent Server • 7. Comparison with Alertable I/O • References IEG4180: Network Software Design and Programming - I/O Completion Port 3 Copyright Jack Y. B. Lee All Rights Reserved Accept a Connection Create a new Thread Data Exchange Done? No Terminate Yes One thread per client session for data exchange. Master thread for accepting connection only. 1. Introduction • High-Concurrency Servers ¡ Large number of connections/sessions can be active simultaneously. ¡ Example: Web server, messaging server. IEG4180: Network Software Design and Programming - I/O Completion Port 4 Copyright Jack Y. B. Lee All Rights Reserved Thread 1 Thread 2 Thread N . . . Context switching 1. Introduction • A Multithread Architecture ¡ One thread per connection leading to many threads. ¡ Threads consume memory (stack, etc..) ¡ The OS end-up spending too much time in context-switching among the threads. Now even using a pre-created thread pool cannot solve the overhead problem. So what is the fundamental cause of this problem? IEG4180: Network Software Design and Programming - I/O Completion Port 5 Copyright Jack Y. B. Lee All Rights Reserved 2. Threading Models • Session-based Model ¡ Each thread serves one client session (e.g. an HTTP session). ¡ The thread is used for both state-tracking and CPU scheduling . ¡ Number of active threads equal number of concurrent client sessions. • I/O-Based Model ¡ Decouples state-tracking from CPU scheduling. ¡ Threads are all homogenous with keep states for I/O calls only. ¡ A thread can serve different sessions at different times. ¡ A session can be served by different threads at different times. ¡ Hence a thread is not dedicated to a session, just dedicated to an I/O request processing. IEG4180: Network Software Design and Programming - I/O Completion Port 6 Copyright Jack Y. B. Lee All Rights Reserved 3. I/O-based Thread Scheduling Accept a Connection Concurrency Control (Max C Threads) Service Thread Service Thread Service Thread Service Thread Service Thread Service Thread Worker Thread Thread Pool Create session states I/O Processing Worker Thread Worker Thread Running Threads Thread returns to Post New IO Requests IO Request Pending I/O Requests IO Completion Worker Thread Wakeup Post an I/O Request Session State Tracking I/O and CPU Scheduling IEG4180: Network Software Design and Programming - I/O Completion Port 7 Copyright Jack Y. B. Lee All Rights Reserved 3. I/O-based Thread Scheduling • Concurrency Limit ¡ Thread is compute-bound • Most efficient when # of active threads = # of CPUs...
View Full Document

This note was uploaded on 05/18/2010 for the course INFORMATIO IEG 4180 taught by Professor Jacky.b.lee during the Spring '09 term at CUHK.

Page1 / 22

io_completion_port - IEG 4180 IEG 4180 Network Software...

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

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