04 基于共享内存分布式程序设计技术.ppt

  1. 1、本文档共126页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
04 基于共享内存分布式程序设计技术

Parallel and Distributed Systems Instructor: Zhang Weizhe (张伟哲) Computer Network and Information Security Technique Research Center , School of Computer Science and Technology, Harbin Institute of Technology Programming Shared Address Space Platforms What is a thread? A thread is an independent sequence of execution of program code inside a UNIX process A thread is often called a lightweight process – but it is NOT a process (something smaller than a process) Why Threads? Do concurrent control more efficiently Use fork() to create a process: is expensive, usually the child process need copy the whole context from the parent process. Inter-process communication is expensive and difficult. OS does more effort to switch process contexts. Creating a thread Threads use and exist within the process resources, so creating a thread is faster than creating a process. Inter-thread communication is easy, usually we can use global variable or struct to share data between threads. OS switches thread contexts easier than process contexts. Shared or Not Shared between thread and process Shared process instruction most data(A thread can have its own private data) open files signal handlers and signal dispositions current working directory user and group ID Not shared thread ID set of registers (including pc and sp) stack errno signal mask priority Programing with windows threads Microsoft Win32 threads Microsoft .Net threads Programming with pthreads Programming with OpenMP Win32 thread API CreateThread MyThreadStart CloseHandle WaitForSingleObject WaitForMultipleObjects CreateMutex ReleaseMutex InitializeCriticalSection DeleteCriticalSection EnterCriticalSection LeaveCriticalSection CreateSemaphore ReleaseSemaphore Win32* HANDLE type Each Windows object is referenced by HANDLE type variables Pointer to kernel objects Thread, process, file, event, mutex, semaphore, etc. Object creation functions return HANDLE Object controlled through its handle Don’t manipulate objects dire

文档评论(0)

l215322 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档