What is the relationship between "64-bit operating system", "x64-based processor" to word size? - operating-system

I was wondering, does a 64-bit operating system and a x64-based processor mean that the word size (i.e. memory transfer size between processor and physical memory) is 64 bits? What if the operating system is a 32-bit and processor x64? And what about x86-based processors? How do these two specifications (XX-bit operating system and xXX-based processor) relate to the actual word size in the hardware?

No, it doesn't mean that. modern x86 CPUs have 64-byte cache lines, and can do accesses to cache at any power-of-2 width from 1 byte up to a 32 byte SIMD vector, or 64-byte in CPUs with AVX512. See also What Every Programmer Should Know About Memory?
"word size" is not really a meaningful term for x86; it's not a word-oriented ISA at all.
In Intel documentation a "word" is 16 bits, just to maintain consistency with documentation going back to 8086. The bus and register widths in hardware are unrelated to that.
x86-64 has 64-bit integer registers when running in long mode (64-bit mode). And supports 64-bit addresses. (Actually 48 bit virtual addresses, and up to 52-bit physical depending on the hardware, because of the page table format. Why in 64bit the virtual address are 4 bits short (48bit long) compared with the physical address (52 bit long)?)
x86 CPUs since 32-bit Pentium have been able to do 64-bit data transfers. Why is integer assignment on a naturally aligned variable atomic on x86?

Related

If a 32 bit address processor can access 4GB how does this processor deal with hard disk of size 500 Gb?

A 32-bit register can store 232 different values. The signed range of integer values that can be stored in 32 bits is -2,147,483,648 through 2,147,483,647 (unsigned: 0 through 4,294,967,295). Hence, a processor with 32-bit memory addresses can directly access 4 GiB of byte-addressable memory. so how this kind of processor deal with disk of size more than 4 gb?
Hence, a processor with 32-bit memory addresses can directly access 4 GiB of byte-addressable memory. so how this kind of processor deal with disk of size more than 4 gb?
For disks; typically they're not byte addressable and the smallest amount that can be read or written (the block size) is 512 bytes or larger (maybe 4096 bytes). Block numbers may also be larger than 32 bits (e.g. maybe 48 bit block numbers).
With 512-byte blocks and 48 bit block numbers (which was common in the late 1990s; for ATA and SATA, etc) you'd end up with a maximum disk size of 134217728 GiB.
Of course the CPU probably (see note) can't directly access any of the data on disk. Software (file system) has to ask a device driver to fetch the block/s it wants, and device driver asks hardware (disk controller) to copy data between disk and memory. Depending on OS; this software interface (used by file system to ask device driver to read or write blocks) most likely uses 64-bit block numbers (e.g. two 32-bit registers joined together).
Note: More recently, the possibility of using non-volatile RAM (e.g. https://en.wikipedia.org/wiki/3D_XPoint ) as storage changed things (it is byte addressable and does use physical addresses); but modern hardware is all "64-bit" (with physical addresses that may be 48 bits or larger in practice) so even though the theoretical limit is much smaller it's still large enough in practice (e.g. maybe 200000 GiB).
On x86-64, the main CPU architecture of most desktop computers, an interface is standardized in the AHCI (Advanced Host Controller Interface). The computer accesses the hard-disk using this interface which is, in practice, a PCI-Express device compliant with the PCI-Express specification.
With PCI, the CPU has a memory controller which will write to the PCI devices registers instead of RAM when writing to some portions of RAM. Software (the operating-system) will write in uncached RAM and it will instead write to the registers of the PCI device. This way it can tell the devices, including an AHCI, to do some operations like a DMA operation from the hard-disk to RAM and vice-versa.
I didn't read the specification in full but the specification probably holds 64 bits registers that can be written as 2 32 bits words. More often, software will write to the lower part of the register then to the higher part of the register. This allows any 32 bits computers to still be able to interact with AHCI. On a 64 bits computer, the registers will be written as one 64 bits write.
A 32 bits computer is thus still able to trigger DMA writes to some portions of the hard-disk which are much higher than 4GB.

Why the Operative System of 32 bits has the limitation of 4 GB of RAM?

Why the Operative System of 32 bits has the limitation of 4 GB of RAM?. I know the processor has a register, the PC(Program Counter), where the adress of an instruction is located and if this register is of 32 bits, its a hardware limitation because of size of the register. But why the Operative System of 32 bits has this limitation? Its harcoded in its kernel that the maximum ram avalaible can be 2 exponent 32 bits?
Thanks
Why the Operative System of 32 bits has the limitation of 4 GB of RAM?
It probably doesn't.
"32-bit" typically refers to the size of general purpose registers and may have nothing to do with the size of any address. For example, for modern 64-bit operating systems addresses are often only 48 bits.
Also; most operating systems use some form of paging where virtual address size may have nothing to do with physical address size. For example; for 32-bit 80x86 using PAE (Physical Address Extensions); virtual addresses are limited to 32-bit (causing each process to be limited to 4 GiB of "virtual space", minus whatever kernel reserves for itself); but physical addresses are/were 36 bits (giving a limit of "up to 64 GiB of RAM, minus space used for devices, ROMs, etc").
Even when physical address size is 32-bit, there are other hardware restrictions - e.g. some of those bits may be ignored by the hardware and/or used for other purposes (e.g. one bit used as an "encrypt the RAM or not" flag), and/or not supported by the RAM controller; and some of the physical address space must be used by things that are not RAM (ROM, devices, etc); so it's extremely unlikely that "32-bit physical addresses" will mean "max. of 4 GiB of RAM".
Finally; it is possible for hardware to support bank switching, where RAM is split into banks and some banks are mapped into the physical address space while others are not; and where "which bank/s are selected" is controlled by OS using special hardware. This was very common for 8-bit and 16-bit CPUs (e.g. "expanded memory" cards plugged into an ISA slot in PCs in the early 1980s); but has become significantly less common as physical address sizes have increased.
The limit is because in 32-bit architectures you are referencing the addresses in memory using 32-bit addresses. So this means that in 32-bit architecture you can only reference 2^32 addresses. Next we need to take into consideration that each address means that we are referencing a single byte which is 8 bits. This means that in effect we can reference 2^32 * 8 bits
Now lets get to the mathy part of the answer. If you can reference 2^32 * 8 bits then you can reference 2^35 bits and 2^35 = 34359738368 bits = 4294967296 bytes = 4194304 kilobytes = 4096 megabytes
And that is why you can only reference 4GiB of memory in 32-bit computers.

32 bit and its relation with Ram?

Does 32 bit mean ram size should be 4GB ? or can a computer with say 32GB ram also have 32 bit provided adress space does not exceed 32 bit ?
When we say 32-bit windows or 64-bit OS, which part of OS exactly differs between the two ? I mean does some part of kernel differ ? if yes then which part ?
NOTE: this question is not a duplicate. please dont vote to close
No 32-bit does not necessarily refer to the size of the address bus. If the address bus is 32-bit then certainly the maximum RAM in the system is 4 gb, or 2^32. There have been several examples of 32-bit machines that could exceed 4gb of RAM, however, by using a concept of Page-Extended Addressing (PAE) That was introduces in the mid 1990s.
Another examples where this comes into play is the first IBM PC. It used a 16-bit microprocessor known as the 8088. The 8088 had a 20-bit address line and as such had the capacity of 2^20 (1MB) of RAM.
When we speak of a microprocessor having a certain number of 'bits', such as a 16-bit microprocessor or a 32-bit microprocessor, we are primarily referring to the basic data unit that the processor can handle at a time. This is determined by the size of the processor registers, which are the areas of the processor used for holding data for calculations and decisions.
Because there is a fundamental difference in how machine code is used to grab and process data in a 32-bit vs a 64-bit system, All code must be compiled specifically for the machine you want it to run on. This is why there are two version of many x86 operating systems. There is often one for 32-bit and one for 64-bit x86. x86 microprocessors have a legacy of backwards compatibility and are therefore able to run in 16, 32, or 64-bit modes. This means that you can run 32-bit windows on a 64-bit processor. If this backwards compatibility wasn't build in, however, this would not be possible.
So, as far as which part of the kernel differs, the answer is all of it. The same is true for desktop applications that are coded for 64-bit machines. If they have two versions, the entire code is different as the compiler optimizes for one or the other.

Size of microprocessor

I have read that the microprocessor consists of several components, each having same/different "sizes". But what really confuses me is what determines the stated size of a microprocessor as 16-bit, 32-bit or 64-bit...
Is it:
the the ALU's capacity?
the size of the data bus?
the size of the address bus?
the "least common denominator" of the above?
or some other factor that I hitherto don't know about?
Generally the bit-size of a processor is the size of its general purpose registers. this often corresponds to the size of the memory bus and possibly the address bus, but doesn't necessarily.
For example, Intel sold a version of the 386 chip called the 386SX (http://en.wikipedia.org/wiki/Intel_80386#The_i386SX_variant) that internally was a 386 with 32-bit registers, but only has a 16 bit data bus. I think that most people would consider the chip to still be a 32-bit processor instead of a 16 bit processor.
I think I'll have a go. Traditionally I think that "size" meant the width (number of bits) in the register set. On "my" first computer the DEC PDP-8/E the single register available - the accumulator - was 12 bits wide and it was a 12-bit computer, on the PDP-11 the registers were 16 bits wide and it was a 16-bit computer. IBM 370 and VAX had 32-bit registers and were 32-bit computers.
Starting with the 80386 things became difficult. Depending on operating mode it could present itself to be a real mode 8086, a protected mode (PM) 80286 or a PM 80386. With the 64-bit processors using AMD64 or x86-64 you have all of the above and also 64-bit PM. So what are they? It should depend on the basic operating mode of the OS that's running on it. Windows NT 2000, Windows XP-32, Vista-32 7-32 make the processor 32-bit. OS with "64" in them make the processor 64 bit.
As to buses and stuff. There are two physical buses on x86-processors address+data and two logical buses memory+i/o. Special pins on the processor determine if the operation is memory or i/o, read or write and so on. On the 8086/8088 the data and address buses shared the same pins A0-A15 with D0-D15/A0-A7 with D0-D7 with bits A16-A19/A8-A19 being strictly address. On the 80286 they were separate, not sure about the 80186/80188. On the 80286 there were 24 address and 16 data lines. On the 80386 and 80486 there were 32 each for address and data. The 80386SX had the same external configuration as the 80286.
After this buses get complicated. The processors run so fast internally that they are more or less constantly waiting for their caches which in turn are more or less constantly waiting on external RAM. To satisfy the caches' insatiable hunger for data external memory began delivering it in 64 bit wide chunks starting with the Pentium and Pentium MMX that are both 32 bit processors with 32 address lines but with 64 data lines.
With later processors the number of address lines were increased to 36 allowing a total addressable external memory of 64 GB. The processors remained 32-bit internally.
On multi-core processors the hunger for data is even more pronounced so they may have several sets of address and data buses to faciltiate data being crammed into the processor. Desktop processors may have two or three and server processors three to four. I'm not sure but I believe some have switched to 128 bit wide data buses.
For modern 64-bit processors it is not feasible to also have 64 address lines since that would allow memory up to 16 billion Gigabytes which is not possible today. Some motherboards allow 128 GB which means that the processor needs at least 37 address lines.
As you can see address and data buses are no longer really usable to determine processor size. They actually haven't for the last 25 (80386 modes) years.
In C the int type is supposed to be equivalent to the register width. On AMD64 it isn't because there just isn't that great a need for 64 bit ints: 32 bit ints do just nicely in most cases. The width of a pointer in C on AMD64 is 64 bits though.
Generally this refers to the amount of the memory (2^n) bytes that is addressable by the CPU. Usually it's the same as data bus, but the hardware may do multiple accesss to retrieve that amount so is not 100% guaranteed. Sometimes it also corresponds to CPU register size, however it too can be different.

what is difference between 32 bit vs 64 bit OSs and processors (Intel architecture and WIndows)

The only difference I know is that size of the registers for 64-bit and 32-bit processors are 64 and 32 bits, respectively. Also the addresses are 64 bits in 64 bit processors. Are there any other differences between these two?
x86_64 has more registers than x86, so more work can be done on the CPU rather than constantly fetching bits from RAM. Also, x86_64 guarantees that the CPU supports at least SSE2, so the compiler knows it can optimize for that.
Those are the key differences, but those differences have many effects - for instance, since addresses are larger, the amount of memory you can effectively access is greater - 32-bit OSes are traditionally limited to around 4GB of memory.
In 32-bit machine the maximum size of RAM will be 4GB
2^32=4294967296 bits which equals to 4GB
but in case of 64-bit machine this will be-
2^64=18446744073709551616 bits which equals to 17179869184 GB
Physical Address Extension (PAE) is a feature to allow x86 processors to access a physical address space larger than 4 GB. This can go up to 64 GB. To use PAE, the OS must support this feature. All major OSes allow the use of PAE, including Windows.
Hence, memory access can't really be held as grounds for distinction between 32-bit & 64-bit OSes.
On the other hand, almost all the processors coming now into the market are 64-bit capable, so it really depends on your OS, how much memory access it allows.
The main difference between 32-bit processors and 64-bit processors is
the speed they operate. 64-bit processors can come in dual core, quad
core, and six core versions for home computing (with eight core
versions coming soon).
Multiple cores allow for increase processing
power and faster computer operation. Software programs that require
many calculations to function operate faster on the multi-core 64-bit
processors, for the most part.
It is important to note that 64-bit
computers can still use 32-bit based software programs, even when the
Windows operating system is a 64-bit version.
Another big difference
between 32-bit processors and 64-bit processors is the maximum amount
of memory (RAM) that is supported. 32-bit computers support a maximum
of 3-4GB of memory, whereas a 64-bit computer can support memory
amounts over 4 GB. This is important for software programs that are
used for graphical design, engineering design or video editing, where
many calculations are performed to render images, drawings, and video
footage. One thing to note is that 3D graphic programs and games do
not benefit much, if at all, from switching to a 64-bit computer,
unless the program is a 64-bit program.
A 32-bit processor is adequate
for any program written for a 32-bit processor. In the case of
computer games, you'll get a lot more performance by upgrading the
video card instead of getting a 64-bit processor.
In the end, 64-bit
processors are becoming more and more commonplace in home computers.
Most manufacturers build computers with 64-bit processors due to
cheaper prices and because more users are now using 64-bit operating
systems and programs. Computer parts retailers are offering fewer and
fewer 32-bit processors and soon may not offer any at all.
Extract from : Here.