operating-systemmemory-addressvirtual-address-space

Logical address space in 64-bit and 32-bit OS


Currently I am going through the Operating system principles by Galvin book. I am enjoying reading it but in the mean time I have a question.

Can I say that if I use a 64-bit operating system then the logical address space (that a CPU generates) can be of 64 bits? I.e. it will be able to map a large number of frames in the physical memory. If I use a 32-bit OS then the CPU can generate maximum of 232 logical address space.

Is that correct?


Solution

  • Sort of, but there are many technicalities which make these names less useful.

    First, there are two different sizes that matter to an operating system: Address size and data size. The address size determines how big of an address space is available, and the data size determines how much data can be used in a single-word operation. In my experience, operating systems are usually identified by data size, which means the address size could be something else.

    Below are some example architectures and their address and data sizes. As the table shows, the most common 32 bit and 64 bit architectures today have the same data and address sizes, which is why your statement is partially correct. Note that x86 processors in 16-bit mode have a larger address size than data size. This is caused by additional segment registers being used in addressing, which makes the architecture less restrictive.

                     Address size      Data size
    x86 16-bit        20 bits           16 bits
    x86 32-bit        32 bits           32 bits
    x86 64-bit        64 bits           64 bits
    ARM 32-bit        32 bits           32 bits
    ARM 64-bit        64 bits           64 bits
    

    However, the address size does not necessarily indicate how big of a logical address space can be used. There could be a limitation which restricts the space to a smaller area. For example, no current x86-64 processor supports a 64 bit address space. Instead, they require that the high 16 bits of any address be a sign extension of bit 47, allowing a 248 address space, 256 TiB instead of 16 EiB. This reduces the number of address lines which need to be used in the processor while allowing far more than anyone currently uses.

    Finally, everything so far has been in reference to the logical or virtual address space. The physical address space could have a different size. Newer 32 bit x86 systems have Physical Address Extension, which enables 36 bit physical addresses, and x86-64 systems are limited to no more than a 52 bit physical address space, but this can be further limited by the memory controller/motherboard. When the logical address space is bigger than the physical address space, it allows the entire physical address space to be mapped to multiple places at once. When the logical address space is smaller, it allows multiple complete address spaces to be stored in physical memory at the same time.