ImageVerifierCode 换一换
格式:DOCX , 页数:10 ,大小:27.40KB ,
资源ID:6404209      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/6404209.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(计算机线程 外文翻译 外文文献 英文文献.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

计算机线程 外文翻译 外文文献 英文文献.docx

1、计算机线程 外文翻译 外文文献 英文文献译 文Chapter 25 Thread BasicsWhy Does Windows Support Threads? .691Thread Overhead. 692Stop the Madness.696CPU Trends.699NUMA Architecture Machines.700CLR Threads and Windows Threads.703Using a Dedicated Thread to Perform an AsynchronousCompute-Bound Operation.704Reasons to Use Thr

2、eads.706Thread Scheduling and Priorities.708Foreground Threads versus Background Threads.713What Now?. .715In this chapter, I introduce the basic concepts concerning threads, and I offer a way for developers to conceptualize about them and their use. Ill explain why Microsoft Windows introduced the

3、concept of threads, CPU trends, the relationship between common language runtime (CLR) threads and Windows threads, the overhead associated with using threads ,how Windows schedules threads, the Microsoft .NET Framework classes that expose thread properties, and much more.The chapters in Part V of t

4、his book, “Threading,” explain how Windows and the CLR work together to provide a threading architecture. It is my hope that after reading these chapters,you will take away a foundation of knowledge that will allow you to effectively use threads to design and build responsive, reliable, and scalable

5、 applications and components.Why Does Windows Support Threads?Back in the early days of computers, operating systems didnt offer the concept of a thread.In effect, there was just one thread of execution that ran throughout the entire system, which included both operating system code and application

6、code. The problem with having only one thread of execution was that a long-running task would prevent other tasks from executing.For example, in the days of 16-bit Windows, it was very common for an application that was printing a document to stall the entire machine, causing the OS and all other ap

7、plications to stop responding.And, sometimes applications would have a bug in them, resulting in an infinite loop that also stopped the entire machine from operating.At this point, the end user would have no choice but to reboot the computer by pressing the reset button or power switch. Of course, e

8、nd users hated doing this (they still do, in fact) because all running applications terminated; more importantly, any data that these applications were processing was thrown out of memory and lost. Microsoft knew that 16-bit Windows would not be a good enough operating system to keep Microsoft relev

9、antas the computer industry progressed, so they set out to build a new OS to address the needs of corporations and individuals. This new OS had to be robust, reliable, scalable, and secure, and it had to improve the many deficiencies of 16-bit Windows. This OS kernel originally shipped in Microsoft

10、Windows NT. Over the years, this kernel has had many tweaks and features added to it. The latest version of this kernel ships in the latest versions of the Microsoft client and server Windows operating systems.When Microsoft was designing this OS kernel, they decided to run each instance of an appli

11、cation in what is called a process. A process is just a collection of resources that is used by a single instance of an application. Each process is given a virtual address space, ensuring that the code and data used by one process is not accessible to another process. This makes application instanc

12、es robust because one process cannot corrupt code or data being used by another. In addition, the OSs kernel code and data are not accessible to processes; therefore,its not possible for application code to corrupt operating system code or data. So now,application code cannot corrupt other applicati

13、ons or the OS itself, and the whole computing experience is much better for end users. In addition, the system is more secure because application code cannot access user names, passwords, credit card information, or other sensitive information that is in use by another application or the operating s

14、ystem itself.This is all well and good, but what about the CPU itself? What if an application enters an infinite loop? Well, if there is only one CPU in the machine, then it executes the infinite loop and cannot execute anything else, so while the data cannot be corrupted and is more secure,the syst

15、em could still stop responding to the end user. Microsoft needed to fix this problem,too, and threads were the answer. A thread is a Windows concept whose job is to virtualize the CPU. Windows gives each process its very own thread (which functions similar to a CPU),and if application code enters an

16、 infinite loop, the process associated with that code freezesup, but other processes (which have their own threads) are not frozen; they keep running!Thread OverheadThreads are awesome because they enable Windows to be responsive even when applicationsare executing long-running tasks. Also, threads

17、allow the user to use one application(like Task Manager) to forcibly kill an application that appears frozen because it is executing a long-running task. But as with every virtualization mechanism, threads have space (memory consumption) and time (runtime execution performance) overhead associated w

18、ith them.Lets explore this overhead in more detail now. Every thread has one of each of the following: Thread kernel object The OS allocates and initializes one of these data structures for each thread created in the system. The data structure contains a bunch of properties(discussed later in this c

19、hapter) that describe the thread. This data structure also contains what is called the threads context. The context is a block of memory that contains a set of the CPUs registers. When Windows is running on a machine with an x86 CPU, the threads context uses about 700 bytes of memory. For x64 and IA

20、64 CPUs, the context is about 1,240 and 2,500 bytes of memory, respectively. Thread environment block (TEB) The TEB is a block of memory allocated and initialized in user mode (address space that application code can quickly access). The TEB consumes 1 page of memory (4 KB on x86 and x64 CPUs, 8 KB

21、on an IA64 CPU).The TEB contains the head of the threads exception-handling chain. Each try block that the thread enters inserts a node in the head of this chain; the node is removed from the chain when the thread exists in the try block. In addition, the TEB contains the threads thread-local storag

22、e data as well as some data structures for use by Graphics Device Interface (GDI) and OpenGL graphics. User-mode stack The user-mode stack is used for local variables and arguments passed to methods. It also contains the address indicating what the thread should execute next when the current method

23、returns. By default, Windows allocates 1 MB of memory for each threads user-mode stack. Kernel-mode stack The kernel-mode stack is also used when application code passes arguments to a kernel-mode function in the operating system. For security reasons,Windows copies any arguments passed from user-mo

24、de code to the kernel from the threads user-mode stack to the threads kernel-mode stack. Once copied, the kernel can verify the arguments values, and since the application code cant access the kernelmode stack, the application cant modify the arguments values after they have been validated and the O

25、S kernel code begins to operate on them. In addition, the kernel calls methods within itself and uses the kernel-mode stack to pass its own arguments,to store a functions local variables, and to store return addresses. The kernel-mode stack is 12 KB when running on a 32-bit Windows system and 24 KB

26、when running on a 64-bit Windows system. DLL thread-attach and thread-detach notifications Windows has a policy that whenever a thread is created in a process, all DLLs loaded in that process have their DllMain method called, passing a DLL_THREAD_ATTACH flag. Similarly, whenever a thread dies, all D

27、LLs in the process have their DllMain method called, passing it a DLL_THREAD_DETACH flag. Some DLLs need these notifications to perform some special initialization or cleanup for each thread created/destroyed in the process. For example,the C-Runtime library DLL allocates some thread-local storage s

28、tate that is required should the thread use functions contained within the C-Runtime library.In the early days of Windows, many processes had maybe 5 or 6 DLLs loaded into them,but today, some processes have several hundred DLLs loaded into them. Right now, on mymachine, Microsoft Office Outlook has

29、 about 250 DLLs loaded into its process address space!This means that whenever a new thread is created in Office Outlook, 250 DLL functions must get called before the thread is allowed to do what it was created to do. And these 250 functions must be called again whenever a thread in Outlook dies. Wo

30、wthis can seriously affect the performance of creating and destroying threads within a process.So now, you see all the space and time overhead that is associated with creating a thread, letting it sit around in the system, and destroying it. But the situation gets even worsenowwere going to start ta

31、lking about context switching. A computer with only one CPU in it can do only one thing at a time. Therefore, Windows has to share the actual CPU hardware among all the threads (logical CPUs) that are sitting around in the system.At any given moment in time, Windows assigns one thread to a CPU. That thread is allowed to run for a time-slice (sometimes referred to as a quantum). When the time-slice expires,Windows context switches to another thread. Every context switch requires that Windows performs the f

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1