Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(){
- int ms,ps,nop,np,x,y,offset,rempages,i,j,pa;
- int s[10], ft[10][20];
- printf("\nEnter the size of memory : ");
- scanf("%d",&ms);
- printf("Enter the size of a page : ");
- scanf("%d",&ps);
- nop = ms/ps;
- printf("No of pages available : %d",nop);
- rempages = nop;
- printf("\nEnter no. of processes : ");
- scanf("%d",&np);
- for(i=0;i<np;i++){
- printf("Enter no. of pages required for p[%d] : ",i);
- scanf("%d",&s[i]);
- if(s[i]>rempages){
- printf("Memory is FULL\n");
- break;
- }
- rempages = rempages - s[i];
- printf("Enter the page table for p[%d] : ",i);
- for(j=0; j<s[i]; j++){
- scanf("%d",&ft[i][j]);
- }
- }
- printf("Enter the Logical address to find physical address\n");
- printf("Enter the process no. page no. and offset : ");
- scanf("%d %d %d",&x,&y,&offset);
- if(x>np||y>=s[i]||offset>=ps){
- printf("\nInvalid process no. or page no. or offset");
- }else{
- pa = ft[x][y]*ps + offset;
- printf("The Physical Address is : %d", pa);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement