使用C ++中的寄存器变量可以做多少坏事 [英] How much bad can be done using register variables in C++

查看:107
本文介绍了使用C ++中的寄存器变量可以做多少坏事的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚知道我们可以在C ++程序中明确使用寄存器。我不知道如果我声明和使用所有可用的寄存器在一个单一的C ++程序,并运行它相当长的时间。

I just came to know that we can use registers, explicitly in C++ programs. I wonder what if i declare and use all available registers in a single C++ program and run it for considerable amount of time. How badly will my system behave and what (if any) measures will be taken by the os to come out of the situation.

推荐答案

  • A common misconsception: the register keyword
  • register Keyword (see the non-Microsoft specific part)
  • "register" keyword in C?

过度使用注册关键字不太可能对现代系统产生严重的负面影响。每个线程在执行期间保持其自己的寄存器值,其寄存器使用将不会对其他线程产生任何直接影响。编译器将拒绝或忽略不能导致可行程序的寄存器使用。不良的寄存器使用最多只会降低性能,操作系统将不采取特殊措施。

Excessive use of the register keyword is unlikely to have serious negative impact on modern systems. Every thread maintains its own register values during execution, and its register usage will not have any direct impact on other threads. The compiler will either reject or ignore register usage that cannot result in a viable program. Poor register use will at most merely reduce performance and the OS will take no special action.

这篇关于使用C ++中的寄存器变量可以做多少坏事的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆