当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

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

资源类别:文库,文档格式:PPT,文档页数:40,文件大小:169KB,团购合买
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 CSIE, NTUT, Taiwan
点击下载完整版文档(PPT)

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

点击下载完整版文档(PPT)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共40页,可试读14页,点击继续阅读 ↓↓
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有