0% found this document useful (0 votes)
29 views9 pages

DOS Commands and CPU Scheduling in C

The document outlines practical exercises for studying software and hardware requirements of various operating systems (Windows, Linux, Unix) and implementing DOS commands. It includes detailed instructions for accessing the command prompt and executing basic DOS commands, as well as C programs for implementing FCFS and SJF CPU scheduling algorithms. The document provides code examples and expected outputs for both scheduling algorithms.

Uploaded by

Sonika Nagar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views9 pages

DOS Commands and CPU Scheduling in C

The document outlines practical exercises for studying software and hardware requirements of various operating systems (Windows, Linux, Unix) and implementing DOS commands. It includes detailed instructions for accessing the command prompt and executing basic DOS commands, as well as C programs for implementing FCFS and SJF CPU scheduling algorithms. The document provides code examples and expected outputs for both scheduling algorithms.

Uploaded by

Sonika Nagar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Practical 1

Study of software and hardware requirements of various Operating Systems


(Windows/Linux/Unix) and Implementation of DOS commands on command
prompt.
you'll need to understand their software and hardware requirements, and then practice
using the command prompt (or terminal) to execute basic DOS commands.
1. Software and Hardware Requirements:
 Windows:
 Software: A Windows operating system (e.g., Windows 10, 11) is the primary
software requirement.
 Hardware: A computer with a processor (CPU), RAM, storage (hard drive or
SSD), and a basic input/output system (BIOS or UEFI).
 Linux/Unix:
 Software: A Linux distribution (e.g., Ubuntu, Fedora, Debian) or a Unix-based
operating system (e.g., macOS, FreeBSD).
 Hardware: Similar to Windows, a computer with a processor, RAM, storage,
and BIOS/UEFI.
 DOS (Disk Operating System):
 Software: MS-DOS (Microsoft Disk Operating System) was the original
command-line operating system for IBM PC compatible computers, but is now
largely obsolete.
 Hardware: Early IBM PC compatible computers with a 8086 or 8088
processor, floppy disk drives, and a monitor.
2. Implementing DOS Commands on Command Prompt ([Link]):
 Accessing Command Prompt:
 In Windows, you can access it by searching for "cmd" in the Start Menu or by
pressing the Windows key + R, typing "cmd", and pressing Enter.
 Basic DOS Commands:
 dir: Lists files and directories in the current directory.
 cd: Changes the current directory.
 mkdir: Creates a new directory.
 del: Deletes files.
 ren: Renames files or directories.
 cls: Clears the screen.
 exit: Exits the command prompt.
 Examples:
 dir - Lists all files and folders in the current directory.
 cd Documents - Changes the current directory to the "Documents" folder.
 mkdir NewFolder - Creates a new folder named "NewFolder".
 del [Link] - Deletes the file "[Link]".
 ren [Link] [Link] - Renames the file "[Link]" to
"[Link]".
 cls - Clears the screen.
 exit - Closes the command prompt window.
Practical 2
Write a program in C to implement FCFS CPU scheduling Algorithm.

CODE:
#include<stdio.h>
int main()
{
int p[10],at[10],bt[10],ct[10],tat[10],wt[10],i,j,temp=0,n;
float awt=0,atat=0;
printf("enter no of proccess you want:");
scanf("%d",&n);
printf("enter %d process:",n);
for(i=0;i<n;i++)
{
scanf("%d",&p[i]);
}
printf("enter %d arrival time:",n);
for(i=0;i<n;i++)
{
scanf("%d",&at[i]);
}
printf("enter %d burst time:",n);
for(i=0;i<n;i++)
{
scanf("%d",&bt[i]);
}
// sorting at,bt, and process according to at
for(i=0;i<n;i++)
{
for(j=0;j<(n-i);j++)
{
if(at[j]>at[j+1])
{
temp=p[j+1];
p[j+1]=p[j];
p[j]=temp;
temp=at[j+1];
at[j+1]=at[j];
at[j]=temp;
temp=bt[j+1];
bt[j+1]=bt[j];
bt[j]=temp;
} } }
/* calculating 1st ct */
ct[0]=at[0]+bt[0];
/* calculating 2 to n ct */
for(i=1;i<n;i++)
{
//when proess is ideal in between i and i+1
temp=0;
if(ct[i-1]<at[i])
{
temp=at[i]-ct[i-1];
}
ct[i]=ct[i-1]+bt[i]+temp;
}
/* calculating tat and wt */
printf("\np\t A.T\t B.T\t C.T\t TAT\t WT");
for(i=0;i<n;i++)
{
tat[i]=ct[i]-at[i];
wt[i]=tat[i]-bt[i];
atat+=tat[i];
awt+=wt[i];
}
atat=atat/n;
awt=awt/n;
for(i=0;i<n;i++)
{
printf("\nP%d\t %d\t %d\t %d \t %d \t %d",p[i],at[i],bt[i],ct[i],tat[i],wt[i]);
}
printf("\naverage turnaround time is %f",atat);

printf("\naverage wating timme is %f",awt);


return 0;
}
OUTPUT:
Practical 3
Write a program in C to implement SJF CPU scheduling Algorithm.

CODE:
#include<stdio.h>
#include<stdlib.h>
void swap(int *x, int *y)
{
int temp=*x;
*x=*y;
*y=temp;
}
void sortat(int p[], int at[], int bt[], int n)
{
int i, j;
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{ /* sort the process having less arrival*/
if(at[i]>at[j])
{
swap(&p[i], &p[j]);
swap(&at[i], &at[j]);
swap(&bt[i], &bt[j]);
}
/* if two processes have the same arrival time than sort them having less burst time */
else if(at[i]==at[j])
{
if(bt[i]>bt[j])
swap(&p[i], &p[j]);
swap(&at[i], &at[j]);
swap(&bt[i], &bt[j]);
}}}}
/* calculate turnaround time and waiting time */
void tatwt( int ct[], int at[], int bt[], int tat[], int wt[], int n)
{
int i;
for(i=0;i<n;i++)
{
tat[i]=ct[i]-at[i];
wt[i]=tat[i]-bt[i];
}}
int main()
{
int *p, *at, *bt, *tat, *wt, *ct, pos, i, j, min=1000, n;
float awt=0, atat=0;
printf("\nenter the number of process:");
scanf("%d", &n);
p=(int*)malloc(n*sizeof(int));
at=(int*)malloc(n*sizeof(int));
bt=(int*)malloc(n*sizeof(int));
ct=(int*)malloc(n*sizeof(int));
wt=(int*)malloc(n*sizeof(int));
tat=(int*)malloc(n*sizeof(int));
printf("enter the process");
for(i=0;i<n;i++)
{
scanf("%d",&p[i]);
}
printf("enter the arrival time");
for(i=0;i<n;i++)
{
scanf("%d",&at[i]);
}
printf("enter the burst time");
for(i=0;i<n;i++)
{
scanf("%d",&bt[i]);
}
sortat(p, at, bt, n);
ct[0]=at[0] + bt[0];
for(i=1; i<n; i++)
{
for(j=i; j<n; j++)
{
if(at[j]<=ct[i-1])
{
if(bt[j]<min)
{
min=bt[j];
pos=j;
} } }
swap(&p[i], &p[pos]);
swap(&at[i], &at[pos]);
swap(&bt[i], &bt[pos]);
min=1000;
ct[i]=ct[i-1]+bt[i];
}
tatwt(ct, at, bt, tat, wt, n);
printf("\np\t at\t bt\t ct\t tat\t wt");
for(i=0;i<n;i++)
{
printf("\n%d\t %d\t %d\t %d\t %d\t %d",p[i], at[i], bt[i], ct[i], tat[i], wt[i]);
}
for(i=0;i<n;i++)
{
atat+=tat[i];
awt+=wt[i];
}
// average turnaround time and average waiting time
atat=atat/n;
awt=awt/n;
printf("\n avg tat=%.2f and avg wt=%.2f",atat, awt);
return 0;
}
OUTPUT:

Common questions

Powered by AI

In FCFS, the average waiting time is calculated based on processes completing in the order of arrival, which may result in longer wait times for processes with smaller burst times arriving after longer processes. SJF minimizes waiting time by prioritizing shorter burst times, reducing the average waiting time as a whole, because processes with larger burst times wait until all shorter jobs are completed .

The sorting procedure in the FCFS CPU scheduling program arranges the processes by their arrival time. This ensures that processes are executed in the order they arrive, allowing the calculation of completion time based on their burst time sequentially without gaps unless there is idle time between arrivals .

DOS commands in Command Prompt include operations like 'dir' to list directories, 'cd' to change directories, and 'del' to delete files. These are simpler and were developed for MS-DOS systems. In contrast, UNIX commands in a terminal, such as 'ls', 'cd', and 'rm', typically offer more functionality with options and flags for detailed outputs. Linux shells provide scripting capabilities and redirection features that exceed those available in DOS .

While both require a modern processor, RAM, and storage hardware, UNIX-based systems rely on a Linux distribution or a Unix-based operating system such as macOS or FreeBSD as their software requirement, whereas Windows systems require a Windows OS like Windows 10 or 11. Unix-based systems typically emphasize command-line interfaces and scripting more heavily, which impacts how software is managed and executed .

Failing to sort processes by arrival or burst time in scheduling algorithms like SJF can lead to increased waiting times and inefficiencies. Correct sorting ensures that processes are executed optimally to minimize waiting times. Without it, the scheduling may mimic FCFS behavior or prioritize inefficient sequences, thereby negating the advantages of SJF in optimizing throughput and minimizing latency .

While the fundamental hardware requirements like CPU and RAM are similar, Linux systems often require compatibility with open-source drivers and may need configurations for kernel-level operations. Unlike Windows, which often has proprietary drivers and specific hardware guidelines, Linux users may focus on compatibility with open-source software and personalized configurations for optimal performance .

The swap function is used to interchange the position of elements in arrays, such as process IDs, arrival times, and burst times, to reorder the processes based on criteria like arrival time or burst time. This reordering is crucial for the Shortest Job First (SJF) CPU scheduling algorithm, which executes processes based on minimal burst time .

To access the command prompt in Windows, you can search for 'cmd' in the Start Menu or press the Windows key + R, type 'cmd', and press Enter. Three basic DOS commands are 'dir' to list directory contents, 'cd' to change the directory, and 'mkdir' to create a new directory .

Using MS-DOS in modern computing is largely impractical due to its outdated technology, limited hardware support, and lack of modern features like multitasking and advanced user interfaces. It lacks the advanced security, internet capabilities, and automation features provided by modern operating systems like Windows, Linux, or macOS, which makes it unsuitable for contemporary professional and personal computing needs .

A modern Windows operating system, such as Windows 10 or 11, requires a computer with a processor (CPU), RAM, storage (hard drive or SSD), and a BIOS or UEFI for basic input/output operations .

You might also like