- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
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
您可能关注的文档
最近下载
- 人工挖孔桩工程量计算格式表格.xls VIP
- 北京师范大学天津静海实验学校2024-2025学年高二上学期第一次月考化学试卷.docx VIP
- 室内装饰装修施工组织设计.pdf VIP
- 人教A版(2019)必修第一册2.3二次函数与一元二次方程、不等式 同步练习(Word版含解析).docx VIP
- 5000tpd燃烧器技术介绍.pdf VIP
- 2023年山西云时代技术有限公司校园招聘考试笔试题库及答案解析.docx VIP
- 小学低年级传统文化故事教学策略研究与实践教学研究课题报告.docx
- 第4课 运动负荷的监控+课件+ 2025-2026学年人教版(2024)初中体育与健康八年级全一册.pptx VIP
- 中级职称评审-人工智能工程-专业技术报告.docx VIP
- 食品生物技术概论 教学课件 作者 廖威 主编 谭强 主审 第二章 基因工程在食品工业中的应用.ppt VIP
文档评论(0)