MCA 1 Sem OS Practical Assignments Solution 2022-23
MCA 1 Sem OS Practical Assignments Solution 2022-23
SSIT, Ratlam
MCA 1st Sem.
MCA-103 : Operating System and Architecture
Practical Assignments
DOS Commands
DOS Commands are instructions to perform tasks on files and directories very useful to
Windows users. DOS commands are case insensitive. And as you already know, file is
the area where we store group of information or data, and collection of group of files is
called a directory.
In MS-DOS the file name follow 8dot3 format and is divided into two parts – primary
name and secondary name. Primary name is up to 8 characters long and secondary name
is up to 4 characters with dot. For example, in the file-name Logo.jpg, Logo is the
primary name and .jpg is the secondary name. Secondary names are fixed for particular
type of file, meaning for system files the secondary name is designated as .sys, for text
files it is .txt and so on. To name a file or directory special characters like < > , . / * ? | &
Space are not allowed. Here is the list of some of the important types of files with their
default secondary names:
1. Internal Commands
These are for performing basic operations on files and directories and they do not
need any external file support.
2. External Commands
These external commands are for performing advanced tasks and they do need
some external file support as they are not stored in COMMAND.COM
There are also Batch commands or Batch files which are text files that contain a list of
internal and/or external commands which are executed in sequence when the batch file is
executed. AUTOEXEC.BAT gets executed automatically on booting.
In MS-DOS, keyboard shortcuts involving handy ones like Functional keys, arrows, pipe
character (” | “), asterisk (*), ?, [] and ESC are of great help for recalling to searching to
clearing command line etc., Here are few of them:
1. DATE
This command is used to display the system current date setting and prompt you to
enter a new date.
The syntax is: DATE [/T | date]
If you type DATE without parameters then it displays current date and prompts to
enter new date. We should give new date in mm-dd-yy format. If you want to keep
the same date just Press ENTER. DATE command with /T switch tells the
command to just output the current system date, without prompting for a new date.
2. TIME
This command is used to displays or set the system time.
The syntax is: TIME [/T | time]
Same as DATE command, typing TIME with no parameters displays the current
time and a prompt for a new one. Press ENTER to keep the same time. TIME
command used with /T switch tells the command to just output the current system
time, without prompting for a new time.
3. COPY CON
It is used to create a file in the existing directory. Here CON is a DOS reserved
word which stands for console.
Syntax is: COPY CON filename
after that press Enter and start typing your text and after you’re done typing your
text, to save and exit hit F6 key.
4. TYPE
This command is used to display the contents of a text file or files. The syntax is:
TYPE [drive:][path]filename
Now, lets try to display the contents of the file named filename we’ve created
earlier using COPY CON command.
5. CLS
It is used to clear the screen. Syntax is
CLS
6. REN
This command is used to change/modify the name of a file or files.
Syntax is:
REN [drive:] [path] filename1 filename2.
Here, filename1 is source file for which you wanted to change the name, and
filename2 will obviously becomes your new file name. Also note that you cannot
specify a new drive or path for your destination file.
7. DIR
This command displays a list of files and subdirectories in a directory. Syntax is:
DIR
DIR [drive:] [path] [filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L]
[/N] [/O[[:]sortorder]] [/P] [/Q] [/S] [/T[[:]timefield]] [/W] [/X] [/4]
Here,
[drive:][path]
[filename] Specifies drive, directory, and/or files to list.
Display in new long list format where filenames are on the far
/N right.
This sorts and displays the list based on time field specified. C
T:timefield for Creation, A for Last Access, W for Last Written
8. PATH
This command displays the path that how we have come to the present position or
sets a search path for executable files.
Its Syntax is
PATH [[drive:]path[;…][;%PATH%]]
Typing PATH without any parameters displays the current path under current
directory. Typing PATH ; clears all search-path settings and direct cmd.exe to
search only in the current directory. And including %PATH% in the new path
setting causes the old path to be appended to the new setting.
9. VER
This command displays the version of the Microsoft Windows running on your
computer.
Syntax: VER
10. VOL
It displays the disk volume label and serial number, if they exist for the drive
specified. If no drive is specified it displays for the active drive.
Syntax is
VOL [drive:]
11. DEL/ERASE
Used to delete one or more files.
Syntax is
DEL [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
Here,
tr>
names Specifies a list of one or more files or directories. Wildcards * and ? may be
/P
/ Delete files based on specified attribute. The attributes are: R for Read-only
A:attribute files, S for System files, H for Hidden files, A for files ready for archiving
s and – Prefix meaning not.
12. COPY
This command is useful in copying one or more files to another file or location.
Syntax is
COPY [/D] [/V] [/N] [/Y | /-Y] [/Z] [/A | /B ] source [/A | /B] [+ source
[/A | /B] [+ …]] [destination [/A | /B]]
The different switches that can be used with this command as follow along with
their use.
source It specifies the file or files to be copied.
destinatio
n This specifies the directory and/or filename for the new file or files.
Specifying this switch uses short filename, if available, when copying a file
/N with a non-8dot3 file name.
For appending multiple files for source use wildcard or file1+file2+file3 format and
make sure to specify a single file for destination.
delete.
Syntax is
RD [/S] [/Q] [drive:]path
Here, using the switch /S removes a directory tree meaning it removes all
directories and files in the specified directory in addition to the directory
itself. And using /Q is the quiet mode that doesn’t asks for ok approval to
remove a directory tree.
14. PROMPT
This changes the cmd.exe command prompt. By default the prompt is always set to
the name of current drive followed by > sign.
$B | (pipe character)
$C ( (Left parenthesis)
$D Current date
$F ) (Right parenthesis)
1. EDIT
This command is used to modify or change the data of a file.
Syntax is
EDIT [/B] [/H] [/R] [/S] [filename(s)]
Using switch /B you can force the edit in monochrome mode. /H displays the
maximum number of lines possible for your system hardware. Whereas using /R
and /S one can load files in read-only mode and force the use of short filenames
respectively. [filename(s)] is used to specify file(s) to go edit. You can use
wildcards (* and ?) to specify multiple files.
2. XCOPY
This command is used to copy files and directory trees from one disk to another
disk.
Syntax is
XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V]
[/W] [/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U] [/K] [/N] [/O]
[/X] [/Y] [/-Y] [/Z] [/EXCLUDE:file1[+file2][+file3]…]
3. LABEL
It is used to create, change, or delete the volume label of a disk.
Syntax is
LABEL [drive:] [label]
LABEL [/MP] [volume] [label]
Here, [drive:] is for secifying the drive letter of a drive to be labelled and [label]
specifies the label of the volume disk. [/MP] is used to specify that the volume
should be created as a mount point and [volume] is used to specify volume name,
usually mentioned after drive letter followed by colon and then giving volume
name required.
4. DISKCOPY
This command copies the contents of one floppy from the source drive to a
formatted or un-formatted floppy disk in the destination drive. This command
copies the data from particular position on the source disk to exactly the same
position on the destination disk. Syntax
Diskcopy A: B:
copies contents of A: to B: drive. This command can be used with /V switch which
verifies that the disk is copied correctly.
5. CHKDSK
This command is used to check a disk and display a status report with properties of
disk like serial number, volume label, memory and other properties along with
errors on the disk if any.
Syntax is
CHKDSK [volume path] [/F] [/V] [/R] [/X] [/I] [/C] [/L[:size]]
[volume path] is where you specify the drive letter followed by a colon and volume
name to be checked. using /F switch allows you to fix errors on the disk. /V display
full path and/or cleanup message if any. /R is used in tandem with /F and used to
locate bad sectors and recover readable information. If you wanted to perform a less
vigorous check of index entries on the disk then the right option is to use /I or /C
rather then /R as they skip checking of cycles on the volume and helps in reducing
the amount of time required to run chkdsk. Using /X forces the volume to dismount
first before checking is performed. /L:size is all about specifying the log file size in
kilobytes.
6. TREE
This command is very useful to view the list of directories and subdirectories
present on the disk in graphical form. If you wanted to include files also with
directories and subdirectories, then you’ll have to give the command line as tree/f
which presents the tree view of all the content on your disk. Here is the syntax for
this command with allowed switches:
TREE [drive:path] [/F] [/A]
In case you wanted use ASCII instead of extended characters, then go ahead
include /A in the command line.
7. DELTREE
This command is used to remove a directory along with its contents.
Syntax is
deltree [drive:path]
here, [drive:path] specifies the directory name to be deleted. All the subdirectories
and files in this directory will be deleted without prompt and there’s not getting
back. So, keep caution while using this command.
8. DOSKEY
This command is generally used to edits command lines and recalls commands.
Syntax is
DOSKEY [/REINSTALL] [/HISTORY] [text]
Here, /REINSTALL installs new copy of doskey, /HISTORY is used to display all
previously given commands stored in memory. And [text] specifies the commands
you want to record.
9. FIND
This command searches for a specific text string in a file or files. Syntax is
FIND [/V] [/C] [/N] [/I] [/OFF] “string” [[drive:][path]filename[ …]]
The basic essential elements in the command line for find are – the string enclosed
in ” ” and [[drive:][path]filename(s)]. String specifies the text string to find in the
file and [[drive:][path]filename(s)] specifies the file or files where the text string
search is to be done. If a path is not specified, FIND searches the text typed at the
prompt or piped from another command. When you append /OFF in the command
line, it searches and finds even those files with offline attribute set. Apart from
searching the text string, this command is useful in:
10. SORT
This command is used to arrange the data of a file in alphabetical order (A-Z, 0-9)
or reverse alphabetical order.
Syntax is
SORT [/R] [[drive1:][path1]filename1] [/T [drive2:][path2]] [/O [drive3:]
[path3]filename3]
/R in command line reverses the sort order; that is, the data of the specified file
sorts sorts Z to A, then 9 to 0. [drive1:][path1]filename1 specifies the file to be
sorted. /T [drive2:][path2] is used in cases of data overflow in main memory and it
specifies the path of the directory to hold the sort’s working storage.
And /O [drive3:][path3]filename3 specifies the file where the sorted input is to be
stored.
11. FORMAT
This command creates a new root directory and a File Allocation Table (FAT) for
the disk. In order for MS-DOS to be able to use a new disk you must use this
command to format the disk.
C:DOS>Format A: /U
This command specifies an Unconditional Format which destroys all existing data
and prevents you from later unformatting the disk.
FORMAT with /Q switch
This can be used only with the previously formatted disk. This deletes FAT, Root
directory and data of disk but doesn’t scan for the bad errors. This is generally used
for Quick formatting.
Warning As Format command deletes all existing data, use this command with
extreme caution. Any disk formatted (except with /U switch) may be later
unformatted using the UNFORMAT command.
12. BACKUP
The Backup command backs up one or more files from one disk to another. You
can backup files onto either a hard disk or on a floppy disk. Syntax is
BACKUP Source Destination
Here source specifies the location of files to be backed up and destination drive
specifies the drive on which you want to store the backup files. The backed-up files
are stored in backup.nnn and control.nnn files where nnn represents the backup disk
number.
13. RESTORE
The RESTORE command restores files that were backed up by using BACKUP
command. Syntax:
RESTORE drive1 drive2:path
Here drive1 specifies the drive on which backup files are stored.
drive2:path specifies the path to which those backup files will be restored.
► Using backup command with /S switch is used to restore all backup files to their
original directories and sub-directories.
Starting with Windows 8.0, Windows Explorer has been called File Explorer.
Windows Explorer replaced the programs File Manager and Program Manager
that were used before Windows 95. In addition to file management,
Windows Explorer also provides shell services as well as manages the
desktop, the Start menu and the taskbar.
Windows Explorer should not be confused with Internet Explorer. The former
is a file browser, whereas the latter is a Web browser. There are different
ways to run Windows Explorer: one is by holding down the Windows button
on the keyboard (the button with the Windows logo) and then pressing the
"E" key. Another way is by clicking the Start menu and then "Run" and then
typing in "explorer" in the dialog box that appears.
If you repeat any of the options below, you can open two or more
separate Explorer windows.
Press Windows key+E (hold down the Windows key and press E).
Click Start and select Run (or press Windows key+R),
type explorer or explorer.exe, and press Enter.
If displayed on the Windows desktop, click or double-click the My
Computer icon (named Computer in Windows Vista & 7, and This PC in
Windows 8 & 10).
In Windows 10
Press the Windows key+X to open the Power User Tasks Menu, then select File
Explorer (or press E).
Click Start, select Windows System, then File Explorer.
Right-click the bottom-left corner of the screen to open the Power User
Tasks Menu and select File Explorer (or press E).
Toolbar - A quick menu for navigating around File Explorer. You can
customize what is shown here by clicking Customize Quick Access
Toolbar.
Ribbon - Each section of the Ribbon, Home, Share, and View, has multiple
options for accessing features and executing actions in File Explorer. For
example, Home has standard features like copy and paste, and adding a
new folder.
Back, Forward, Up - Pressing Back takes you to the last folder you were
viewing. Pressing Forward, moves to the next folder. Pressing Up takes you
to the drive or folder location of the object you're viewing, or to the Desktop
folder, depending on your location in File Explorer.
Left Pane - Shows all the main devices and drives that are connected to
your computer. It also shows the network your computer is connected to, if
any.
Status Bar - Shows the number of files or folders in each location and each
file or folder's size.
Address Bar - Shows your current location in File Explorer. You can also use
this to type a drive or file you want to access.
Search Bar - Allows you to search for a drive, folder, or file name.
File List - Displays the current list of files in the selected drive or folder.
Open a document
Open a program
In the Search tab, you can find files or folders on your computer. Press
the F3 shortcut key to open search at any time while in Windows
Explorer.
Using Windows Explorer, you can also perform any of the system tasks
listed below.
In Windows 7, Windows 8, and Windows 10, you can use the search
box in the top-right corner of the Control Panel window to find the area
you're looking to adjust. For example, type firewall to search for
the Firewall settings in the Control Panel.
There are several ways to open the Control Panel in Windows 10.
1. The Cortana search bar is on the left side of the taskbar, next to
Start Menu button. Click the search bar to place your cursor in this
box.
2. Type the word control. Cortana lists best matches above as you
type. In this list, select Control Panel.
The control command may be used to open the Control Panel. For
instance:
1. Open the Run box by pressing Win+R (hold down the Windows key on
your keyboard, then press the R key).
As mentioned below, you can also run the control command from the
Windows 10 Command Prompt.
If you are having trouble finding a specific icon, there is a search box
in the top-right corner of the Control Panel window.
3. You may see a window similar to the following image. You may also
see the expanded version of the Control Panel, with icons for all the
various utilities available in the Control Panel.
5. To implement the CPU Scheduling Algorithm FCFS (First Come First Serve).
In Multiprogramming systems, the Operating system schedules the processes on the CPU to
have the maximum utilization of it and this procedure is called CPU scheduling. The Operating
System uses various scheduling algorithm to schedule the processes.
In this scheduling algorithm we allocate CPU to process that comes first in the
ready queue. That is, the process that comes first in the ready queue will
gets the CPU first. So it's called first come first serve algorithm.
It is Non preemptive it means in FCFS Scheduling once the CPU has been
allocated to a process , the process keeps the CPU until it releases the CPU
either by terminating or by requesting I/O.
Advantage:-
Easy to implement
Easy to understand
The simplest form of a CPU scheduling algorithm
Disadvantage:-
C program:-
Here I am going to give to two solution .In the first Code we will just use
Array and in the second Code we will use structure .
In this code we simply declare Some array for the arrival time , Burst time ,
Waiting time, and turn around time .
First we take a input from the user which is number of process in the Ready
queue. then After we take Arrival time and Burst time of all the process one by
one. Aftet that we will calculate the waiting time and Turn Around time of all
the process and store it in the Array WT and TT respectively .
#include<stdio.h>
int main()
{
int AT[10],BT[10],WT[10],TT[10],n;
int burst=0,cmpl_T;
float Avg_WT,Avg_TT,Total=0;
printf("Enter number of the process\n");
scanf("%d",&n);
printf("Enter Arrival time and Burst time of the process\n");
printf("AT\tBT\n");
for(int i=0;i<n;i++)
{
scanf("%d%d",&AT[i],&BT[i]);
}
cmpl_T=0;
Total=0;
for(int i=0;i<n;i++)
{
cmpl_T+=BT[i];
TT[i]=cmpl_T-AT[i];
Total+=TT[i];
}
Avg_TT=Total/n;
// printing of outputs
Output:-
Enter number of process
3
Enter Arrival time and Burst time of the process
At BT
0 2
1 4
2 3
Process , Waiting_time , TurnA_time
1 0 2
2 1 5
3 4 7
Average waiting time is : 1.666667
Average turn around time is : 4.666667
Here we are going discuss all things about the SJF scheduling algorithm i.e what is SJF , what are
the advantage of SJF , what is disadvantage of SJF ,Code of SJF.
As it is clear by the name of this scheduling algorithm the job which has the
less burst time will get the CPU first. it is the best method to minimize the
waiting time.
Characteristics:-
Code:-
logic:-
1. After taking the input first we sort the input on the basis of Arrival time (i.e
the process which have less Arrival time will come first).
Here one more things we will do. we will check that the arrival time of all the
processes are different or not. (Example:- if all the processes comes at the
same time then we don't need to sort the array on the basis of arrival time ) .
for checking this we will use check_ar.
2. After doing this if processes are arrived at the different time then we can
easily calculate the waiting and turnaround time for the first process. and for
other process first we will find the minimum burst time of the process which
are arrived at cmp_time (completion time of the previous process) .
//Driver function
int main()
{
int n,check_ar=0;
int Cmp_time=0;
float Total_WT=0,Total_TAT=0,Avg_WT,Avg_TAT;
printf("Enter the number of process \n");
scanf("%d",&n);
printf("Enter the Arrival time and Burst time of the process\n");
printf("AT BT\n");
for(int i=0;i<n;i++)
{
scanf("%d%d",&a[i].AT,&a[i].BT);
a[i].id=i+1;
// here we are checking that arrival time
// of the process are same or different
if(i==0)
check_ar=a[i].AT;
if(check_ar!=a[i].AT )
check_ar=1;
}
// if process are arrived at the different time
// then sort the process on the basis of AT
if(check_ar!=0)
{
for(int i=0;i<n;i++)
{
for(int j=0;j<n-i-1;j++)
{
if(a[j].AT>a[j+1].AT)
{
swap(&a[j].id,&a[j+1].id);
swap(&a[j].AT,&a[j+1].AT);
swap(&a[j].BT,&a[j+1].BT);
}
}
}
}
if(check_ar!=0)
{
a[0].WT=a[0].AT;
a[0].TAT=a[0].BT-a[0].AT;
Cmp_time=a[0].TAT;
Total_WT=Total_WT+a[0].WT;
Total_TAT=Total_TAT+a[0].TAT;
for(int i=1;i<n;i++)
{
int min=a[i].BT;
for(int j=i+1;j<n;j++)
{
if(min>a[j].BT && a[j].AT<=Cmp_time)
{
min=a[j].BT;
swap(&a[i].id,&a[j].id);
swap(&a[i].AT,&a[j].AT);
swap(&a[i].BT,&a[j].BT);
}
}
a[i].WT=Cmp_time-a[i].AT;
Total_WT=Total_WT+a[i].WT;
// completion time of the process
Cmp_time=Cmp_time+a[i].BT;
}
}
}
a[i].WT=Cmp_time-a[i].AT;
Avg_WT=Total_WT/n;
Avg_TAT=Total_TAT/n;
Output:-
Enter the number of process
4
Enter the Arrival time and Burst time of the process
AT BT
0 2
2 3
2 4
3 3
The process are
ID WT TAT
1 0 2
2 0 3
4 2 5
3 6 10
Avg waiting time is:- 2.000000
Avg turn around time is:- 5.000000
Code:-
#include<stdio.h>
struct process
{
int id,AT,BT,WT,TAT;
};
{
int n;
n=queue[front];
front=front+1;
return n;
}
int main()
{
int n,TQ,p,TIME=0;
int temp[10],exist[10]={0};
float total_wt=0,total_tat=0,Avg_WT,Avg_TAT;
printf("Enter the number of the process\n");
scanf("%d",&n);
printf("Enter the arrival time and burst time of the process\n");
printf("AT BT\n");
for(int i=0;i<n;i++)
{
scanf("%d%d",&a[i].AT,&a[i].BT);
a[i].id=i;
temp[i]=a[i].BT;
}
printf("Enter the time quantum\n");
scanf("%d",&TQ);
// logic for round robin scheduling
{
insert(i);
exist[i]=1;
}
}
// if process is completed
if(a[p].BT==0)
{
a[p].TAT=TIME-a[p].AT;
a[p].WT=a[p].TAT-temp[p];
total_tat=total_tat+a[p].TAT;
total_wt=total_wt+a[p].WT;
}
else
{
insert(p);
}
}
Avg_TAT=total_tat/n;
Avg_WT=total_wt/n;
Output:-
Enter the number of the process
3
Enter the arrival time and burst time of the process
AT BT
0 5
2 7
4 6
Enter the time quantum
3
ID WT TAT
0 3 8
1 9 16
2 7 13
Average waiting time of the processes is : 6.333333
Average turn around time of the processes is : 12.333333
Below is the source code for C Program to input values into an array and display
them which is successfully compiled and run on Windows System to produce
desired output as shown below :
#include<stdio.h>
#include<conio.h>
void main()
int x,n,p[10],pp[10],pt[10],w[10],t[10],awt,atat,i;
scanf("%d",&n);
for(i=0;i<n;i++)
printf("\nProcess no %d : ",i+1);
scanf("%d %d",&pt[i],&pp[i]);
p[i]=i+1;
for(i=0;i<n-1;i++)
for(int j=i+1;j<n;j++)
if(pp[i]<pp[j])
x=pp[i];
pp[i]=pp[j];
pp[j]=x;
x=pt[i];
pt[i]=pt[j];
pt[j]=x;
x=p[i];
p[i]=p[j];
p[j]=x;
w[0]=0;
awt=0;
t[0]=pt[0];
atat=t[0];
for(i=1;i<n;i++)
w[i]=t[i-1];
awt+=w[i];
t[i]=w[i]+pt[i];
atat+=t[i];
printf("\n\n Job \t Burst Time \t Wait Time \t Turn Around Time Priority \n");
for(i=0;i<n;i++)
awt/=n;
atat/=n;
getch();
OUTPUT
Process no 1 : 3
Process no 2 : 4
Process no 3 : 5
Process no 4 : 6
4 6 0 6 4
3 5 6 11 3
2 4 11 15 2
1 3 15 18 1
The End