台北科技大学:《计算机网络》(英文版) NP04 16 server ex con

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

●● Multiple Threads o each process can include many threads o All threads of a process share o memory (program code and global data o open file/socket descriptors o signal handlers and signal dispositions o working environment(current directory,user ID, etc.) 6 SIE, NTUT, Taiwan
6 CSIE, NTUT, Taiwan Multiple Threads Each process can include many threads. All threads of a process share: ⚫ memory (program code and global data) ⚫ open file/socket descriptors ⚫ signal handlers and signal dispositions ⚫ working environment (current directory, user ID, etc.)

°°| Thread- Specific Resources o Each thread has it's own ● Thread id( Integer) ● Stack ● Registers ● Program Counter o Threads within the same process can communicate using shared memor Must be done carefully! SIE NTUT. Taiwan
7 CSIE, NTUT, Taiwan Thread-Specific Resources Each thread has it’s own: ⚫ Thread ID (integer) ⚫ Stack ⚫ Registers ⚫ Program ⚫ Counter Threads within the same process can communicate using shared memory. Must be done carefully!

●。 Posix Threads We will focus on posix threads -most widely supported threads programming APl SIE, NTUT, Taiwa
8 CSIE, NTUT, Taiwan Posix Threads We will focus on Posix Threads - most widely supported threads programming API

●。f。rk() Process A Global fork( Variables Process B Code Global Variables Stack Code Stack SIE NTUT. Taiwan
9 CSIE, NTUT, Taiwan fork() Process A Global Variables Code Stack Process B Global Variables Code Stack fork()

●● Thread creation pthread create( pthread t *tid, const pthread attr t xattr V。id*(*func)(Void*) v。id*arg); Func is the function to be called When func( returns the thread is terminated 10 SIE NTUT. Taiwan
10 CSIE, NTUT, Taiwan Thread Creation pthread_create( pthread_t *tid, const pthread_attr_t *attr, void *(*func)(void *), void *arg); Func() is the function to be called. When func() returns the thread is terminated
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 台北科技大学:《计算机网络》(英文版) NP04 16 server ex.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 16 server.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 16 multi services.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 16 multi proto.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 16 Client Software Design.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 16 Socket API.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 15 Client Server model.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 12 CONTENTS.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 11 Introduction.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 1 CONTENTS.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 0 Network Programming.ppt
- 哈尔滨工业大学:《网络应用开发》英文版 网络开发与应用实验指导书.pdf
- 哈尔滨工业大学:《网络应用开发》英文版 NAD-chapter7.pdf
- 哈尔滨工业大学:《网络应用开发》英文版 NAD-chapter7-6.pdf
- 哈尔滨工业大学:《网络应用开发》英文版 NAD-chapter6.pdf
- 哈尔滨工业大学:《网络应用开发》英文版 NAD-chapter6-6.pdf
- 哈尔滨工业大学:《网络应用开发》英文版 NAD-chapter5.pdf
- 哈尔滨工业大学:《网络应用开发》英文版 NAD-chapter5-6.pdf
- 哈尔滨工业大学:《网络应用开发》英文版 NAD-chapter4.pdf
- 哈尔滨工业大学:《网络应用开发》英文版 NAD-chapter4-6.pdf
- 台北科技大学:《计算机网络》(英文版) NP04 18.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 2 CONTENTS.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 20(comer).ppt
- 台北科技大学:《计算机网络》(英文版) NP04 20.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 21(comer).ppt
- 台北科技大学:《计算机网络》(英文版) NP04 22(comer).ppt
- 台北科技大学:《计算机网络》(英文版) NP04 23(comer).ppt
- 台北科技大学:《计算机网络》(英文版) NP04 24(comer).ppt
- 台北科技大学:《计算机网络》(英文版) NP04 27 Mobile ip discussion overview.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 28 Real-Time Transport protocol.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 3 CONTENTS.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 4 CONTENTS.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 5 Subnetting.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 8 Internet Protocol (IP).ppt
- 《计算机图形学》课程教学资源:第3章 图形的基本运算.ppt
- 《计算机图形学》课程教学资源:第4章 图形的观察运算.ppt
- 《计算机图形学》课程教学资源:第6章(6-1)图形的数据结构.ppt
- 《计算机图形学》课程教学资源:第6章 图形的数据结构.ppt
- 《计算机图形学》课程教学资源:第7章 三维图形显示基础.ppt
- 《计算机图形学》课程教学资源:第10章 光照物体的显示.ppt