Professional Documents
Culture Documents
Os Labmanual Bcaiv
Os Labmanual Bcaiv
BCA
(IInd YEAR -IVSEM)(2022-23)
Code: 21BCA481
1. How do you modify the attributes of a file using the command prompt?
2. List the internal and external DOS commands with the help of examples.
AIM: List the internal and external DOS commands with the help of examples.
DOS (Disk Operating System) is a command-line interface used in older Microsoft operating systems,
such as MS-DOS and Windows 95/98. It consists of both internal and external commands that perform
various tasks and functions.
Here is a list of some commonly used internal and external DOS commands with examples:
Internal Commands:
1. CD (Change Directory) - Changes the current directory.
Example: `cd \Windows\System32` - Changes the current directory to the System32 folder
in the Windows directory.
2. DIR (Directory) - Displays a list of files and folders in the current directory.
Example: `dir /w` - Displays a list of files and folders in the current directory in a wide format.
3. COPY - Copies one or more files from one location to another.
Example: `copy C:\Data\File.txt D:\Backup\File.txt` - Copies the file named "File.txt" from
the "C:\Data" directory to the "D:\Backup" directory.
4. DEL (Delete) - Deletes one or more files.
Example: `del C:\Data\File.txt` - Deletes the file named "File.txt" from the "C:\Data" directory.
5. MD (Make Directory) - Creates a new directory.
Example: `md C:\NewFolder` - Creates a new directory named "NewFolder" in the "C:\"
directory.
External Commands:
1. FORMAT - Formats a disk or drive.
Example: `format C:` - Formats the C: drive.
2. XCOPY - Copies one or more files or directories, including subdirectories.
Example: `xcopy C:\Data D:\Backup /E /H /Y` - Copies the "Data" directory and all its
subdirectories to the "Backup" directory on the D: drive, including hidden files, and
overwriting existing files without prompting.
3. CHKDSK (Check Disk) - Checks the disk for errors.
Example: `chkdsk C: /F` - Checks the C: drive for errors and fixes any errors found.
4. TREE - Displays the directory structure of a drive or path.
Example: `tree C:\Windows\System32` - Displays the directory structure of the System32
folder in the Windows directory.
5. NET - Displays or modifies network settings.
Example: `net view` - Displays a list of all shared resources on the network.
EXPERIMENT NO. 3
AIM:- Linux command “rmdir/s foldername” to delete folder having files in it.
@echo off
Set /p folder_name=”Enter the name of the folder you want to delete : ”
If exist %folder_name% (
echo Deleting %folder_name% and all its contents…
rmdir /s /q %folder_name%
echo Folder %folder_name% deleted successfully.
)
else
(
echo Folder %folder_name% does not exist.
)
EXPERIMENT 5.
AIM: Write a program in Linux that takes two numbers as input and displays their
sum on the screen.
Calculating the sum of two integers (Numbers) in a shell script is pretty simple as in other
programming languages.
Here is an example of a shell script,which takes input from the user at run time. Then
calculate the sum of given numbers and store to a variable and show the results.
SOURCE CODE :
#include<stdio.h>
main()
{
intf[50],i,st,j,len,c,k;
clrscr();
for(i=0;i<50;i++)
f[i]=0;X:
printf("\n Enter the starting block & length of file");
scanf("%d%d",&st,&len);
for(j=st;j<(st+len);j++)
if(f[j]==0)
{
printf("\n%d->%d",j,f[j]);
}
else
{
printf("Block already allocated");
break;
}
if(j==(st+len))
printf("\nthe file is allocated to disk");
printf("\n if u want to enter more files?(y-1/n-0)");
scanf("%d",&c);
if(c==1)
gotoX;
else
exit();
getch();
{
}
OUTPUT:
Enterthestartingblock&lengthoffile
4104->1
5->1
6->1
7->1
8->1
9->1
10->1
11->1
12->1
13->1
The file is allocated to disk.
EXPERIMENT NO :7
DESCRIPTION:
In the chained method file allocation table contains a field which points to starting block of
memory .From it for each block pointer is kept on ext successive block .Hence, there is no
external fragmentation.
SOURCE CODE :
#include<stdio.h>main()
{
intf[50],p,i,j,k,a,st,len,n,c;
clrscr();
for(i=0;i<50;i++)f[i]=0;
printf("Enterhowmanyblocksthatarealreadyallocated");
scanf("%d",&p);printf("\nEntertheblocksno.sthatarealreadyallocated");
for(i=0;i<p;i++)
{
scanf("%d",&a);
f[a]=1;
}
X:
printf("Enterthestartingindexblock&length");
scanf("%d%d",&st,&len);k=len;
for(j=st;j<(k+st);j++)
{
if(f[j]==0)
{f[j]=1;
printf("\n%d->%d",j,f[j]);
}
else
{
printf("\n%d>fileisalreadyallocated",j)
k++;
}
}
printf("\n If u want to enter one more
file?(yes1/n0)");
scanf("%d",&c);
if(c==1)
gotoX;
else
xit();
getch();}
OUTPUT:
Enter how many blocks that are already allocated 3
Enter the blocks no. that are already allocated 479
Enter the starting index block & length 37
3->1
4->1 file is already allocated5->1
6->1
7->1
file is already allocated
8->1
9->1
File is already allocated
10->1
11->1
12->1
EXPERIMENT NO. O8:
Banker‘sAlgorithm:
Bankers algorithm in Operating System is used to avoid deadlock and for resource allocation safely to
each process in the system. As the name suggests, it is mainly used in the banking system to check
whether the loan can be sanctioned to a person or not.
SOURCE CODE :
#include<stdio.h>
#include<conio.h>
Void main()
{
Char job[10][10];
Int time[10],avail,tem[10],temp[10];
Int safe[10];
Int ind=1,i,j,q,n,t;
clrscr();
printf("Enter no of jobs:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter name and time:");
scanf("%s%d",&job[i],&time[i]);
}
printf("Enter the avail able resources:");
scanf("%d",&avail);
for(i=0;i<n;i++)
{
temp[i]=time[i];
tem[i]=i;
}
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
{
if(temp[i]>temp[j])
{
t=temp[i];
temp[i]=temp[j];
temp[j]=t
;t=tem[i];
tem[i]=tem[j];
tem[j]=t;
}
}
for(i=0;i<n;i++)
{
q=tem[i];
if(time[q]<=avail)
{
safe[ind]=tem[i];
avail=avail-tem[q];
//printf("%s",job[safe[ind]]);
ind++;
}
else
{
printf("Nosafesequence\n");
}
}
printf("Safesequenceis:");
for(i=1;i<ind;i++)
printf("%s%d\n",job[safe[i]],time[safe[i]]);
getch();
}
OUTPUT:
Enter no of jobs:4
Enter name and time:A1 Enter name and time:B4 Enter name and time:C2 Enter name and time:D3
Enter the available resources:20 Safe sequence is:A1,C2,D3,B4.
EXPERIMENTNO: - 9
SOURCE CODE :
#include<stdio.h>
#include<conio.h>
intfr[3];
void main()
{
Void display();
Int i,j,page[12]={2,3,2,1,5,2,4,5,3,2,5,2};
Int flag1=0,flag2=0,pf=0,frsize=3,top=0;
clrscr();
for(i=0;i<3;i++)
{
fr[i]=-1;
}
for(j=0;j<12;j++)
{
flag1=0;
flag2=0;
for(i=0;i<12;i++)
{
If (fr[i]==page[j])
{
flag1=1;
flag2=1;
break;
}
}
if(flag1==0)
{
for(i=0;i<frsize;i++)
{
if(fr[i]==-1)
{
fr[i]=page[j];
flag2=1;
break;
}}}
if(flag2==0)
{
fr[top]=page[j];
top++;
pf++;
if(top>=frsize)top=0;
}
display();
}
printf("Number of page faults:%d",pf);
getch();
}
Void display()
{
Int i;
printf("\n");
for(i=0;i<3;i++)
printf("%d\t",fr[i]);
}
OUTPUT:
2 -1-1
23-1
23-1
23 1
53 1
52 1
52 4
52 4
32 4
32 4
35 4
35 2
Number of page faults:
EXPERIMENT NO :. 10
SOURCE CODE :
#include<studio.h>
#include<conio.h>
Structpstruct
{
intfno;
intpbit;
}
ptable[10];
int pmsize,lmsize,psize,frame,page,ftable[20],
frameno;voidinfo()
}
Void assign()
{
int;
for(i=0;i<page;i++)
{
ptable[i].fno=-1;
ptable[i].pbit=-1;
}
for(i=0;i<frame;i++)
ftable[i]=32555;
for(i=0;i<page;i++)
{
printf("\n\n Enter the Frame number where page%dmust be placed:",i);
scanf("%d",&frameno);
ftable[frameno]=i;
if(ptable[i].pbit=1)
{
ptable[i].fno=frame no;
ptable[i].pbit=1;
}
}
getch();
clrscr();
printf("\n\nPAGETABLE\n\n");
printf("Page Address Frame No. Presence Bit\n\n");
for(i=0;i<page;i++)
printf("%d\t\t%d\t\t%d\n",i,ptable[i].fno,ptable[i].pbit);
printf("\n\n\n\tFRAME TABLE\n\n");
printf("Frame Address Page No\n\n");
for(i=0;i<frame;i++)
printf("%d\t\t%d\n",i,ftable[i]);
}
Void cphyaddr()
{
intladdr,paddr,disp,phyaddr,baddr;
getch();
clrscr();
printf("\n\n\n\tProcess to create the Physical Address\n\n");
printf("\n Enter the Base Address:");
scanf("%d",&baddr);
printf("\nEnter the Logical Address:");
scanf("%d",&laddr);
paddr=laddr/ psize;
disp=laddr%psize;
if(ptable[paddr].pbit=1)
phyaddr=baddr+(ptable[paddr].fno*psize)+disp;
printf("\nThe Physical Address where the instruction present:%d",phyaddr);
}
Void main()
{
clrscr();
info();
assign();
cphyaddr();
getch();
}
OUTPUT:
PAGETABLE
0 5 1
1 6 1
2 7 1
3 2 1
FRAMETABLE
Process to create the Physical Address Enter the Base Address: 1000
Enter the Logical Address:3
The Physical Address where the instruction present:1013