欢迎来到天天文库
浏览记录
ID:26020846
大小:183.50 KB
页数:22页
时间:2018-11-24
《【精品】线程的定义(introduction)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、海量管理资源免费下载!1概述1.1线程的定义(Introduction)Threadscanbestbedescribedas“lightweightprocesses”.ThetraditionalUNIX-stylenotionofaprocesshasbeenfoundtobeinconvenient,ifnotinadequateforseveralapplicationsindistributedsystemsdevelopment.Theneedsoftheseapplicationsarebestservedb
2、ythreads,whichgeneralizethenotionofaprocesssothatitcanbeassociatedwithmultipleactivities.ThepopularityofthreadshasresultedintheirimplementationonUNIXsystemsandthreadlibrariesarenowwidelyavailabletoprogrammersforthedevelopmentofconcurrentapplications.1.2ThreadsImple
3、mentationThreadscanbeimplementedinoneoftwoways:1.User-levelthreads:Thereisnokernelsupportformulti-threadedprocesses.Hence,thekernelonlyhasasingle-threadedprocessabstraction,butmulti-threadedprocessesareimplementedinalibraryofprocedureslinkedwithapplicationprograms.
4、Thekernelhasnoknowledgeoflightweightprocesses(threads),andthereforecannotschedulethemindependently.Athreadsrun-timelibraryorganizestheschedulingofthreads.Athreadwouldblocktheprocessandthereforeallthreadswithinitifitmadeablockingsystemcall,sotheasynchronousI/Ofacili
5、tiesofUNIXareused.Themajordisadvantageofthisschemeisthatthreadswithinaprocesscannottakeadvantageofamulti-processor.(上段译文)User-level没有核心支持的多线程的进程。因此,核心只有单线程进程概念,而多线程进程由与应用程序连接的过程库实现。核心不知道线程的存在,也就不能独立的调度这些线程了。一个线程运行库组织线程的调度。如果一个线程调用了一个阻塞的系统调用,进程可能被阻塞,当然其中的所有线程也同时被阻塞,
6、所以UNIX使用了异步I/O工具。这种机制的的最大缺点是不能发挥多处理器的优势。Theadvantagesinclude:l(系统消耗小)Certainthreadoperationsaresignificantlylesscostly.Forexample,switchingbetweenthreadsbelongingtothesameprocessdonotnecessarilyinvolveasystemcall,andhencesavethisover-head.l(可以修改以适应特殊的应用)User-levelt
7、hreadimplementationscanbecustomizedorchangedtosuittheparticularapplicationrequirements.Thisisparticularlyusefulforreal-timemultimediaprocessingetc.Also,itispossible管理资源吧·管理人自己的下载网站海量管理资源免费下载!tosupportmanymoreuser-levelthreadsthancanbydefaultbyakernel.2.Kernel-level
8、threads:Thisimplementationallowsthreadswithindifferentprocessestobescheduledaccordingtoasingleschemeofrelativeprioritizing.Thisissuitedforexploit
此文档下载收益归作者所有