Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Procedure: Download the following files from rkson 46 Spring-ms memparts 1. Simp

ID: 3814117 • Letter: P

Question

Procedure: Download the following files from rkson 46 Spring-ms memparts 1. Simple User Menu for File and Directory Access filemenu This script is called filemenu and is designed to present a simple user menu for someone not familiar with basic UNIX commands for file and directory access. When the script is run, it should first change to the home directory of the userrunning the script, independent of the directory from which it is run.The script runs in a continuous loop of displaying the following menu, executing the requested action, and then re-displaying the menu.The menu consists of a display of the full path name of the current working directory and a list of choices for the user as highlighted below (all here means non-hidden) 1) list non-executable files -lists all ordinary non-executable files in the current working directory 2) list executable files -lists all ordinary executable files in the current working directory 3) list subdirectories lists all subdirectories in the current working directory 4) display a directory prompts the user to input a directory name;display the content of the specific directory [NOTE: the requested directory must be a subdirectory of the current directory; otherwise, report that the directory does not exist and repeat the menu displayl 5) display a file promptsthe user to input a file name; displays (more or less) the selected file (must be one selected from the current working directory). If the file does not exist in the current working directory, an error message is displayed, then repeat the menu displ ay.

Explanation / Answer

#include<stdio.h>
#include<stdlib.h>
struct list
{
int page;
int frame;
struct list *next;
}*p;
void add(struct list *q,int page,int frame)
{
if(p==NULL)
{
p=malloc(sizeof(struct list));
p->page=page;
p->frame=frame;
p->next=NULL;
}
else
{
while(q->next!=NULL)
{
q=q->next;
}
q->next=malloc(sizeof(struct list));
q->next->page=page;
q->next->frame=frame;
q->next->next=NULL;
}
}
int search(struct list *q,int page)
{
while(q->page!=page)
{
q=q->next;
}
return q->frame;
}
main()
{
p=NULL;
int pagesize,logicaladdr;
int i,page,frame;
int quotient,offset,physicaladdr;
printf("Enter page table as structure ");
printf("Enter 100 as page number for termination ");
printf("Enter page size");
scanf("%d",&pagesize);
do
{
printf("Enter the page number");
scanf("%d",&page);
if(page!=100)
{
printf("Enter the frame number:");
scanf("%d",&frame);
add(p,page,frame);
}
}
while(page!=100);
printf("Enter logical address");
scanf("%d",&logicaladdr);
quotient=logicaladdr/pagesize;
offset=logicaladdr%pagesize;
physicaladdr=(search(p,quotient)*pagesize)+offset;
printf("CORRESPONDING PHYSICAL ADDRESS IS %d ",physicaladdr);
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote