Does the 64-bit processor always perform better than 32-bits?
Abstract: What do you think about the question? Does the 64-bits always do better? The answer is NO.

When we talk about 64 bit vs. 32 bit we mean two things
- Memory addressing, 32 bit can address about 4GB of memory(it has 32 address lines, and each line can represent 0 and 1), or more with extensions. 64 bit can address a vastly larger amount, about 16 exabytes, which is 16 million terabytes, which is a vast amount of memory.
- The same thing for integer numbers, a 32-bit computer can process amounts up to about 4 billion, a 64-bit processor can process numbers up to 18,446,744,073,709,551,615.
So if you're dealing with numbers under 4 billion, and address memory of fewer than 4 GB, 64-bit processors won't actually make any difference to you.
64-bit is about the size, not speed.
Copied from https://www.quora.com/Why-is-a-64-bit-CPU-faster-than-32-bit-CPU
What's virtual memory work for?
Background: Before the virtual memory came out, there is only have physical memory concept. In physical memory, here is a largely entire memory space, and people research algorithm for memory management. Something you may already know like first-fit, Best fit, worst fit, buddy's system, etc. Then we find a better thing to meet people's ambitions, it's virtual memory. By using virtual memory, we can abstract a memory for every process to guarantee security and independence, and make full use of physical fragments.
First fit algorithm
#include<bits/stdc++.h>
using namespace std;
void firstfit(int blockSize[], int m, int processSize[], int n){
int allocation[n];
memset(allocation, -1, sizeof(allocation));
for(int i=0; i<n; i++)
{
for(int j=0; j<m; j++)
{
if(blockSize[j]>=processSize[i])
{
allocation[i] = j;
blockSize[j] -= processSize[i];
break;
}
}
}
cout << "\nProcess No.\tProcess Size\tBlock no.\n";
for(int i=0; i<n; i++){
cout<<" "<< i+1<<"\t\t" << processSize[i]<<"\t\t";
if(allocation[i]!=-1)
cout << allocation[i]+1;
else
cout << "Not allocated";
cout << endl;
}
}
//Driver code
int main(){
int blockSize[] = {100, 500, 200, 300, 600};
int processSize[] = {212, 417, 112, 426};
int m = sizeof(blockSize) / sizeof(blockSize[0]);
int n = sizeof(processSize) / sizeof(processSize[0]);
firstfit(blockSize, m, processSize, n);
return 0;
}

浙公网安备 33010602011771号