Question: Can someone please fix this code written in C. This is about a program that simulates a paging system using the aging algorithm. The number

Can someone please fix this code written in C. This is about a program that simulates a paging system using the aging algorithm. The number of page frames is a parameter. The sequence of page references should be read from a file. For a given input file, plot the number of page faults per 1000 memory references as a function of the number of page frames available.

#include #include #include

int main(void) { int arr[20], var1, var2, var3, pageSize, start, arr2[35], arr3[10]; int temp1, temp2, temp3, INDEX, pageSeq, pageFrame, address, index; clrscr(); printf("Enter page size: "); scanf("%d", &pageSize); printf("Enter logical memory in terms of bytes: "); scanf("%d", &var1); printf("Enter physical memory: "); scanf("%d", &var2); printf("Enter user data: "); for(temp1 = 0; temp1 < var1; temp1++) scanf("%d", &arr[temp1]); for(temp1 = 0; temp1 < 32; temp1++) { arr2[temp1]= -1; } for(temp1 = 0; temp1 < var1/pageSize; temp1++) { printf("Enter starting position of every page: "); scanf("%d", &start); arr3[temp1]= start/4; for(temp2= start, temp3 = temp1*pageSize; temp2<(start+pageSize), temp3<(temp1*pageSize)+pageSize) { arr2[temp2]=arr[temp3]; } } for(temp1= 0; temp1 < var2;temp1++); { printf("%d", arr2[temp1]); } printf("Enter data to which mapping address is to be found: "); scanf("%d", &var3); for(temp1= 0; temp1 { if(var3==arr[temp1]) { INDEX= temp1; pageFrame=arr3[pageSeq]; address=(pageFrame*pageSize)+(index%pageSize); } } printf("The physical address for %d is %d", var3, address); getch(); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!