how a 32bit processor can address 4 gigabytes of memory [closed] - operating-system

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 12 years ago.
Improve this question
I didnt understand this because 2^32 is 4 giga bits not bytes right ? since 2^2 * 1024* 1024* 1024 bits right ? Am I wrong ?

The smallest individually addressable unit of memory is a byte. Bits don't have addresses. You have to read a byte or more and then do bit masking and such to get at the individual bits.

As far as i can recall from my college days, this is how it goes
If 32 = size of the address bus, then the total number of memory addresses that can be addressed = 2^32 = 4294967296
However, these are 4294967296 Addresses of memory locations. Since each memory location itself = 1 Byte, hence this gives us 4294967296 bytes that can be addressed.
Hence 4GB Memory can be addressed.

No, it is Gigabytes. A byte has 8 bits so you have to multiply the resulting number by 8 to get the bits. As john said in his answer you cant address individual bits, you will have to do bit shifting and masking to get to individual bits.

In the old console days SNES and Megadrive games were measured in MegaBits because by definition an 8MegaBit game sounds bigger than a 1 MegaByte game. In the end most people said 8Megs so again the confusion gave the impression of 8Megabytes for most people. Im not sure if brett is talking about SNES or Megadrive programming but remember 8 Megabits = 1 Megabyte.

the above answer solves it, and if you wish to address more then 4 gb then you can use an offset memory register, that can help you address a wider range.

Related

Why is this question worded like this regarding main memory?

I have this question:
1. How many bits are required to address a 4M × 16 main memory if main memory is word-addressable?
And before you say it, yes I have looked this question up and there have been posts on stackoverflow asking about how to answer it but my question is different.
This may sound like a silly question but I don't understand what it means when it says "How many bits are required to address...".
To my understanding and what I have been taught is that (if we're talking about word addressable) each cell would contain 16 bits in the RAM chip and the length would be 4M-1, with 2^22 words. But I don't understand what it is asking when it says 'How many bits are required...':
The answer says 22 bits would be required but I just don't understand. 22 bits for what? All I know is each word is 16 bits and each cell would be numbered from 0 - 4M-1. Can someone clear this up for me please?
Since you have 4 million cells, you need a number that is able to represent each cell. 22 bits is the size of the address to allow representing 2^22 cels (4,194,304 cells)
In computing, a word is the natural unit of data used by a particular processor design. A word is a fixed-sized piece of data handled as a unit by the instruction set or the hardware of the processor.
(https://en.m.wikipedia.org/wiki/Word)
Using this principle imagine a memory with a word that uses 2 bits only, and it is capable of storing 4 words:
XX|YY|WW|ZZ
Each word in this memory is represented by a number that tells to computer it's position.
XX is 0
YY is 1
WW is 2
ZZ is 3
The smallest binary number length that can represent 3 is a 2 bit binary length right? Now apply the same example to a largest memory. Doesn't matters if the word size is 16 bits or 2 bits. Only the length of words matters

Memory capacity of a RAM [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
If a RAM has 32 bits in its MAR(memory address register) and its MDR (Memory data register) is 16 bits wide, then what is the capacity of RAM.
My probable solution is that it can address upto 2^32 locations.
Your solution is incorrect. The question is what the capacity is, not the number of addressable locations. Your answer should be measured in units of storage (e.g, bits, bytes, or their multiples).
Since this is clearly a homework problem, I'm not going to give an exact answer. But I will point you in the right direction by asking some additional questions:
What is the memory data register used for? (Refer to your textbook if you're not sure.)
What is the capacity of the memory data register? (The answer is in the question. Don't think about it too hard.)
With that in mind, what is the capacity of the memory?
Yes, that sounds right. If a microprocessor or CPU has a memory address register with a size of 32 bits, it can access 232 locations, as 32 binary bits used in combination allow you to handle 232 different values starting from 0 to 4294967295 (232 - 1).

Convert bytes to MB in Perl [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I have a size in bytes. I want to convert this everytime in MB. But my code is giving the wrong answer.
sub sizeConversion {
my $size = shift;
return ($size / (1024 * 1024));
}
my $size = 1024;
my $size_conversion = &sizeConversion($size);
print $size_conversion;
I get the output as:
0.0009765625
But I am supposed to get the output as
0.001024MB
Please help. Thanks in advance.
You get 0.0009765625 because that's the correct answer for what you have defined.
To get 0.001024, you would have to divide 1024 by 1000000
Whether a MB is 2^20 bytes or 10^6 bytes depends on whether you are programming in assembly or selling hard drives. See Wikipedia: Megabyte
According to Wikipedia the official SI unit is 10^6 or 1000000 bytes.
You should know that there are two kinds of Mega Bytes(MB) in the IT world.
(A) 1 MB = 1 million (1,000,000) bytes.
This MB is used to presents capacity of hard disk drives, DVD and BD, and communication capacity in the networks, etc.
(B) 1 MB (more precisely 1 MiB) = bytes can be addressed by 20 address lines = 2^20 (1,048,576) bytes.
This MB is used to presents capacity of semiconductor memory like RAM, ROM.
You may know data in RAM is addressed by several address lines each of them has value 0 or 1. If a memory has 10 address lines and 8 data lines, 2^10(1024) addresses of bytes(8 bits) can be stored. The capacity of such memory was not called '1 kilo and 24 bytes memory' but '1 Kilo bytes memory'. By increase of memory capacity, 2^20 bytes memory became to be called 1 Mega bytes memory.
If you use the word "MB" in sense of (A), you should correct the line in your code
return ($size / (1024 * 1024));
to
return ($size / (1000 * 1000));
The corrected code will give you the answer 0.001024 MB.
If you use the word "MB" in sense of (B), 0.0009765625 MB is correct answer.
There are two kind of MB, so there are two kind of correct answer.
It depends you which is the answer you want get.

Efficient Encoding Schemes [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I want to choose a encoding scheme for data storage. I have very low available memory. which coding should be best to optimally utilize available space.
ANSI, UTF or any other..
Data is the Capital Alphabetics
If you know the frequency distribution of letters, Huffman Coding is a good balance between complexity, speed and efficiency.
If you don't know the distribution of letters or they are random, just store them 5 bits at a time. For example, consider the string "ABCDE". The letter numbers are 0, 1, 2, 3, 4. Converted to binary, this is:
00000 00001 00010 00011 00100
Now you just group every 8 bits into bytes:
00000000 01000100 00110010 0xxxxxxx
You need to store the length too, so that you know that there is no useful data in the last byte's 7 bits.
If code space is of no concern and you just want to pack the strings as well as you can, you could use Huffman coding or Arithmetic coding even with a uniform frequency distribution to pack each character into log2(26) bits on average, which is slightly less than 5 (namely, 4.7 bits).

Operating System: Paging Question

I have a question that I am trying to answer that gives the following situation:
16K Pages
32-bit Virtual Addresses
512MB hard disk, sector-addressable with 16K sectors
8 processes currently running
I am asked:
i) How many process page tables are required?
I think this is a trick question? Surely the answer is just 1.
ii) If a process address register PAR can be up to 32 bits, what is the maxmimum amount of physical memory that can be supported on this machine?
iii) How wide in bits should each entry in a process table be if 64MB physical memory is installed?
Please could anyone give me help/hint with the last two parts as I'm really stuck on them? Thanks!
In case you look on here before the exam later today, it is because it doesn't mean Process address register, it means Page address register!
Try looking at http://cseweb.ucsd.edu/classes/fa03/cse120/Lec08.pdf for some more information including help about segmentation and paging combined
Also, the book in the IC library called Operating Systems concepts with code 005.43SIL says that each process has it's own process page table and can even be segmented itself!
i) I said 8
ii) Well, 32 bits of virtual memory addressing with 14 bits of offset in the page table (2^14 = 16K page length) means there are 18 bits left for the page number. In 32 bits of PAR, this means 14 bits for the page location. If you multiple the amount of page locations by the page size, you get 2^14 * 2^14 = 2^18 which is 256MB of RAM
iii) I got 30 bits. 64MB is 2^26 divided by the page size is 2^26/2^14 = 2^12 which means 12 bits for the page location. From (ii) I calculated that 18 bits are left in the virtual memory address for the page number meaning that it should be 30 bits wide. I also put a comment that since it should be byte-aliged maybe the extra 2 bits can be used so that we know whether it has been written to and whether it is currently being stored on the disk.
Hope this helps!