具有64位硬件的32位操作系统中的内存管理 [英] Memory management in 32 bit os with 64 bit hardware

查看:70
本文介绍了具有64位硬件的32位操作系统中的内存管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道当机器是64位而OS是32位时指针的内存分配.例如,当机器和OS是32位时,指针有4字节,而指针是64位8字节.使用64位计算机将OS保持为32位,那么指针大小将如何处理?以及如何通过具有64位硬件的OS管理指针大小?????

解决方案

//如果使用64位计算机,则将操作系统保持为32位
//那么指针大小会发生什么??

只需编译以下内容:

 //  .. 
 int  * pInt(NULL);
cout<<  sizeof (pInt);
//  ..  

...让它回答:)

//如何通过具有64位硬件的OS对其进行管理???????

64个处理器可以同时使用.

可能像浏览驴子一样
通过32米或64米的线固定...:)


32位操作系统无法使用超出32位可寻址空间的内存.这就是"32位操作系统"的意思!这是地址空间的限制.操作系统可能会更加严格,因为它可能保留地址空间的某些部分以供内部使用.例如Windows通过这种方式保留了大约500MB-1GB的地址空间,这意味着即使32GB的操作系统可能有4GB的可用内存,您最多也可以使用3-3.5GB.

大多数编译器根据目标OS定义指针大小,但不是全部.这是编译器的依赖关系,而不是OS的依赖关系!因此,尽管在针对32位OS的程序中,许多编译器可能只使用4个字节,但有些编译器可能使用8个甚至16个字节.

通常,您不需要关心实际的硬件系统-这就是编译器为您完成的工作.偶尔需要注意的唯一事情就是存储指针的大小,您可以在运行时(甚至使用模板在编译时)使用sizeof运算符进行查询.



首先,编译器根据目标编译器决定数据类型的内存分配.
例如,在turbo c编译器(16位)中,指针占用16个字节,而在像Visual c ++这样的32位编译器中,指针将为32位,并且64位编译器也可在64位计算机上工作.
此链接显示了如何在64位环境中使用可视c ++编译器:http://www.viva64.com/en/k/0006/

术语32位和64位是指计算机处理器寄存器的大小,用于各种功能,如指令提取和执行,它们可以容纳的位数越多,处理速度就越快. blockquote>

I want to know memory allocation for pointers when the machine is 64 bit and OS in 32 bit.For Example when the machine as well as the OS are 32 bit the pointer has 4 bytes and for 64 bit 8 bytes.If we use 64 bit machine keeping the OS as 32 bit then what will happen to the pointer size??and how it is managed by OS with 64 bit hardware???????

解决方案

// If we use 64 bit machine keeping the OS as 32 bit
// then what will happen to the pointer size??

Just compile the following:

//..
int* pInt(NULL);
cout << sizeof(pInt);
//..

...and let it answer :)

// how it is managed by OS with 64 bit hardware???????

A 64-processor can go the both ways.

Probably like a browsing donkey
fixed by a 32- or 64-meters cord... :)


A 32 bit OS can not work with memory beyond the space adressable by 32 bits. That''s what ''32 bit OS'' means! It''s a restriction of address space. An OS might even be more restrictive as it might reserve certain parts of the address space for internal use. E. g. Windows reserves about 500MB-1GB of the address space this way, meaning you can at most use 3-3.5 GB on a 32 bit OS even though it might have 4 GB memory available.

Most compilers define pointer size depending on the target OS, but not all. This is compiler dependend, not OS dependend! So, while many compilers may use only 4 bytes in a program targeted at a 32 bit OS, some might use 8 or even 16 bytes.

Normally you shouldn''t need to care about your actual hardware system - that is what the compiler does for you. The only thing you may occasionally need to watch out for is the size needed to store a pointer, and you can query that at runtime (or even at compile time, using templates) with the help of the sizeof operator.


Hi,

First of all the compiler decides the memory allocation for the datatypes depending on the target compiler.
For example in turbo c compiler(16 bit) the pointer takes up 16 bytes,and in a 32 bit compiler like visual c++ it will be 32 bits and 64 bit compilers are also available to work in 64 bit machine.
This link shows how to use visual c++ compiler in 64 bit environment :http://www.viva64.com/en/k/0006/

The terms 32-bit and 64-bit refer to the the size of the computers processor''s registers,that are used for various functions like instruction fetching and execution,more the number of bits they can hold,faster the processing.


这篇关于具有64位硬件的32位操作系统中的内存管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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