Concurrent Server Design Multiple- Threads vs Single-thread Chuan-Ming LIu Computer Science and Information Engineering Spring 2004, NTUT TAIWAN CSIE NTUT Taiwan
1 CSIE, NTUT, Taiwan Concurrent Server Design Multiple-Threads v.s. Single-thread Chuan-Ming Liu Computer Science and Information Engineering Spring 2004, NTUT TAIWAN
●● Examples o Using Threads for Concurrency(TCP) o Single-Thread, Currency Servers(TCP) SIE NTUT. Taiwan
2 CSIE, NTUT, Taiwan Examples Using Threads for Concurrency (TCP) Single-Thread, Currency Servers (TCP)
Using Threads for Concurrency (TCp
Using Threads for Concurrency (TCP)
。 Multiple Threads o Master thread for connection requests o Slave threads for handling communication th clients o Thread of execution an abstraction of independent computation Single process can contain one or more threads 4 SIE NTUT. Taiwan
4 CSIE, NTUT, Taiwan Multiple Threads Master thread for connection requests Slave threads for handling communication with clients Thread of execution: an abstraction of independent computation Single process can contain one or more threads
●°。 Threads vs. Processes o Creation of a new process using forko is expensive( time memory) o a thread (sometimes called a lightweight process )does not require lots of memory or startup time 5 SIE NTUT. Taiwan
5 CSIE, NTUT, Taiwan Threads vs. Processes Creation of a new process using fork( ) is expensive (time & memory). A thread (sometimes called a lightweight process) does not require lots of memory or startup time