本文介绍了如何做一个电脑只用了几个寄存器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解一些总成,并有4个或8个左右通用寄存器。如何在电脑上工作的所有程序与只是寄存器的数量,尤其是多线程和一切?

I know a little about assembly, and that there are 4 or 8 or so general purpose registers. How do all the programs on a computer work with just that amount of registers, especially with multithreading and everything?

推荐答案

多线程本身并不影响使用的寄存器的数量。当一个线程被换出,一般有其寄存器保存到存储器中,下一个线程来运行有从previous装载了这些寄存器保存。

Multi-threading itself doesn't affect the number of registers in use. When a thread is swapped out, it generally has its registers saved to memory and the next thread to run has those registers loaded up from its previous save.

的实例是具有一个线程控制块结构(TCB)的系统。这种结构将包含(而线程未运行),保存的指令指针,堆栈指针,通用寄存器,浮点寄存器,螺纹统计等。总之,一切都需要完全恢复线程它是在当它被换出另一个线程来运行的状态。

An example is a system having a thread control block structure (TCB). This structure would contain (while the thread wasn't running), the saved instruction pointer, stack pointer, general purpose registers, floating point registers, thread statistics and so on. In short, everything needed to totally restore the thread to the state it was in when it was swapped out for another thread to run.

和不能代表一切,在一台计算机上的那张是登记完成。现代的编译器可以优化code,这样的数据项目中最被保存在寄存器中,但是绝大多数的数据都保存在内存中,并仅在需要时购买到寄存器中。

And not everything that goes on in a computer is done in registers. Modern compilers can optimise code so that the data items used the most are kept in registers but the vast majority of data is held in memory and only bought into registers when needed.

我关于这个问题读过的最好的书是的它检查计算机中的层而言,从该数字逻辑电平到操作系统级别,每个级别的建筑上的previous。

The best book I've ever read on the subject is Tanenbaum's "Structured Computer Organization" which examines computers in terms of layers, from the digital logic level up to the operating system level, with each level building on the previous.

           

           

旁白:的我的梦想是有一天能写一本书就这样,涵盖的所有的,从夸克水平提高到Emacs的: - )

这篇关于如何做一个电脑只用了几个寄存器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 04:23