Professional Documents
Culture Documents
Manasdl
Manasdl
LAB MANUAL
(2022-2023)
Solution:
1. MS-DOS:
Drawbacks:
There’s no standard edition of Linux hence confusing for users and also
becoming familiar with the Linux may be a problem for new users.
More difficult to find applications to support user needs since Linux doesnot
dominate the market.
Since some applications are developed specifically for Windows and Mac,
those might not be compatible with linux and sometimes users might not
have much of a choice to choose between different applications like in
Windows or Mac since most apps are developed foroperating systems that
have a huge user base.
Some hardware may not be incompatible with Linux since it has patchier
support for drivers which may result in malfunction.
There are plenty of forums to resolve Linux issues, but it may not alwaysmatch
the user’s own level of technical understanding.
4. Android Mobile Operating System:
Android is a Google’s Linux based operating system it is designed primarily fortouch
screen mobile devices such as smart phones and tablet computers. The hardware
which can be used to support android is based on three architecturesnamely ARM,
Intel and MIPS design lets users manipulate the mobile devices. intuitively, with finger
movements that mirror common motions, such as pinching,swiping, and tapping
making these applications comfortable for the users.
Features:
The android operating system is an open source operating system
means that it’s free and any one can use it.
Android offers optimized 2D and 3D graphics, multimedia, GSM
connectivity, multi-tasking.
Android OS is known for its friendly user interface and exceptional
customizable according to the user’s taste.
Huge choice of applications for its users since Playstore offer over onemillion
apps.
Software developers who want to create applications for the Android OScan
download the Android Software Development Kit(SDK) to easily develop
apps for android.
Android would consume very little power but deliver extreme
performance since its hardware is based on ARM architecture.
Drawbacks:
The design and coding of intuitive modern user experiences and
interfaces poses a difficulty because of its dependency on Java.
Most apps tend to run in the background even when closed by the user
draining the battery.
Performance is bound to take a hit as multiple programs run
simultaneously in the background at any given time.
Android phones overheat especially when indulged in hardcore
productivity tasks or heavy graphics.
Apps have lower security profiles and make users more susceptible todata
breaches.
Objective:Case study of file systems used in Linux, Unix and windows operating system.
Solution:
Linux file system has a hieíaíchal file stíuctuíe as it contains a íoot diíectoíy and its
subdiíectoíies. All otheí diíectoíies can be accessed fíom the íoot diíectoíy. A paítition
usually has only one file system, but it may have moíe than one file system.
A file system is designed in a way so that it can manage and píovide space foí non- volatile
stoíage data. All file systems íequiíed a namespace that is a naming ando íganizational
methodology. ľhe namespace defines the naming píocess, length of the file name, oí a
subset of chaíacteís that can be used foí the file name. It also defines the logical stíuctuíe
of files on a memoíy segment, such as the use of diíectoíies foí oíganizing the specific
files. Once a namespace is descíibed, a Metadata descíiption must be defined foí that
paíticulaí file.
ľhe data stíuctuíe needs to suppoít a hieíaíchical diíectoíy stíuctuíe; this stíuctuíe is
used to descíibe the available and used disk space foí a paíticulaí block. It also has the
otheí details about the files such as file size, date & time of cíeation, update, and last
modified.
Also, it stoíes advanced infoímation about the section of the disk, such as paítitions
and volumes.
ľhe advanced data and the stíuctuíes that it íepíesents contain the infoímation about
the file system stoíed on the díive; it is distinct and independent of the file system
metadata.
Linux file system contains two-paít file system softwaíe implementation aíchitectuíe.
Consideí the below image:
ľhe file system íequiíes an API (Application píogíamming inteíface) to access the
function calls to inteíact with file system components like files and diíectoíies. API
facilitates tasks such as cíeating, deleting, and copying the files. It facilitates an algoíithm
that defines the aííangement of files on a file system.
ľhe fiíst two paíts of the given file system togetheí called a Linux viítual file system. It
píovides a single set of commands foí the keínel and developeís to access the file
system.
ľhis viítual file system íequiíes the specific system díiveí to give an inteíface to the file
system.
FAT
FAT (File Allocation Table) is one of the simplest FS types, which has been around
since the 1980s. It consists of the FS descriptor sector (boot sectoror superblock), the
block allocation table (referred to as the File AllocationTable) and plain storage space
for storing data. Files in FAT are stored in directories. Each directory is an array of 32-
byte records, each defining a file or its extended attributes (e.g. a long name). A record
attributes the first block of a file. Any next block can be found through the block
allocation table by using it as a linked list.
NTFS
NTFS (New Technology File System) was introduced in 1993 with WindowsNT and is
currently the most common file system for end user computers based on Windows.
Most operating systems of the Windows Server line use this format as well.
ReFS
ReFS (Resilient File System) is the latest development of Microsoftintroduced
with Windows 8 and now available for Windows 10. Its
architecture absolutely differs from other Windows formats and is mainly organized in a
form of the B+-tree. ReFS has high tolerance to failures dueto new features included
into it.
HPFS
HPFS (High Performance File System) was created by Microsoft in
cooperation with IBM and introduced with OS/2 1.20 in 1989 as a filesystem for
servers that could provide much better performance when compared to FAT. In
contrast to FAT, which simply allocates any first free cluster on the disk for the file
fragment, HPFS seeks to arrange the file in contiguous blocks, or at least ensure
that its fragments (referred to as extents) are placed maximally close to each
other.
Experiment-3
Solution:
#include<iostream>
using namespace std;
cout << "Processes "<< " Burst time "<< " Waiting time " << " Turn around time\n";
cout << " " << i+1 << "\t \t" << bt[i] <<"\t \t"<< wt[i] <<"\t\t " << tat[i] <<endl;
}
cout << "Average waiting time = "<< (float)total_wt / (float)n;
cout << "\n Average turn around time = "<< (float)total_tat / (float)n;
}
int main()
{
int processes[] = { 1, 2, 3};
return 0;
}
Outcomes:
Experiment-4
Solution:
#include <bits/stdc++.h>
using namespace std;
#define totalprocess 5
struct process
{
int at,bt,pr,pno;
};
process proc[50];
int service[50];
service[0] = proc[0].at;
wt[0]=0;
for(int i=1;i<totalprocess;i++)
{
service[i]=proc[i-1].bt+service[i-1];
wt[i]=service[i]-proc[i].at;
if(wt[i]<0)
{
wt[i]=0;
}
}
for(int i=0;i<totalprocess;i++)
{
tat[i]=proc[i].bt+wt[i];
}
void findgc()
{
int wt[50],tat[50];
double wavg=0,tavg=0;
get_wt_time(wt);
get_tat_time(tat,wt);
int stime[50],ctime[50];
stime[0] = proc[0].at;
ctime[0]=stime[0]+tat[0];
for(int i=1;i<totalprocess;i++)
{
stime[i]=ctime[i-1];
ctime[i]=stime[i]+tat[i]-wt[i];
}
cout<<"Process_no\tStart_time\tComplete_time\tTurn_Around_Time\tWaiting_Time"<<endl;
for(int i=0;i<totalprocess;i++)
{
wavg += wt[i];
tavg += tat[i];
cout<<proc[i].pno<<"\t\t"<<
stime[i]<<"\t\t"<<ctime[i]<<"\t\t"<<
tat[i]<<"\t\t\t"<<wt[i]<<endl;
}
int main()
{
int arrivaltime[] = { 1, 2, 3, 4, 5 };
int bursttime[] = { 3, 5, 1, 7, 4 };
int priority[] = { 3, 4, 1, 7, 8 };
for(int i=0;i<totalprocess;i++)
{
proc[i].at=arrivaltime[i];
proc[i].bt=bursttime[i];
proc[i].pr=priority[i];
proc[i].pno=i+1;
}
sort(proc,proc+totalprocess,comp);
findgc();
return 0;
}
Outcomes:
Experiment-5
Solution:
#include <bits/stdc++.h>
using namespace std;
struct Process {
int pid;
int bt;
int art;
};
void findTurnAroundTime(Process proc[], int n, int wt[], int tat[]) {
for (int i = 0; i < n; i++)
tat[i] = proc[i].bt + wt[i];
}
rt[shortest]--;
minm = rt[shortest];
if (minm == 0)
minm = INT_MAX;
if (rt[shortest] == 0) {
complete++;
check = false;
finish_time = t + 1;
wt[shortest] = finish_time -
proc[shortest].bt -
proc[shortest].art;
if (wt[shortest] < 0)
wt[shortest] = 0;
}
t++;
}
}
void findavgTime(Process proc[], int n) {
int wt[n], tat[n], total_wt = 0,
total_tat = 0;
findWaitingTime(proc, n, wt);
findTurnAroundTime(proc, n, wt, tat);
cout << "Processes " << " Burst time " << " Waiting time " << " Turn around time";
for (int i = 0; i < n; i++) {
total_wt = total_wt + wt[i];
total_tat = total_tat + tat[i];
cout << " " << proc[i].pid << "\t\t" << proc[i].bt << "\t\t " << wt[i] << "\t\t " << tat[i] << endl;
}
cout << "Average waiting time = " << (float)total_wt / (float)n;
cout << "Average turn around time = " << (float)total_tat / (float)n;
}
int main()
{
Process proc[] = { { 1, 5, 1 }, { 2, 3, 1 }, { 3, 6, 2 }, { 4, 5, 3 } };
int n = sizeof(proc) / sizeof(proc[0]);
findavgTime(proc, n);
return 0;
}
Outcomes:
Experiment-6
Solution:
#include<iostream>
using namespace std;
void findWaitingTime(int processes[], int n,int bt[], int wt[], int quantum)
{
int rem_bt[n];
for (int i = 0 ; i < n ; i++)
rem_bt[i] = bt[i];
int t = 0;
while (1)
{
bool done = true;
for (int i = 0 ; i < n; i++)
{
if (rem_bt[i] > 0)
{
done = false;
if (rem_bt[i] > quantum)
{
t += quantum;
rem_bt[i] -= quantum;
}
else
{
t = t + rem_bt[i];
wt[i] = t - bt[i];
rem_bt[i] = 0;
}
}
}
if (done == true)
break;
}
}
void findTurnAroundTime(int processes[], int n,int bt[], int wt[], int tat[])
{
for (int i = 0; i < n ; i++)
tat[i] = bt[i] + wt[i];
}
Outcomes:
Experiment-7
Solution:
#include <iostream>
using namespace std;
int main()
{
int n, m, i, j, k;
n = 5;
m = 3;
int alloc[5][3] = { { 0, 1, 0 },
{ 2, 0, 0 },
{ 3, 0, 2 },
{ 2, 1, 1 },
{ 0, 0, 2 } };
int max[5][3] = { { 7, 5, 3 },
{ 3, 2, 2 },
{ 9, 0, 2 },
{ 2, 2, 2 },
{ 4, 3, 3 } };
int avail[3] = { 3, 3, 2 };
int f[n], ans[n], ind = 0;
for (k = 0; k < n; k++) {
f[k] = 0;
}
int need[n][m];
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++)
need[i][j] = max[i][j] - alloc[i][j];
}
int y = 0;
for (k = 0; k < 5; k++) {
for (i = 0; i < n; i++) {
if (f[i] == 0) {
int flag = 0;
for (j = 0; j < m; j++) {
if (need[i][j] > avail[j]){
flag = 1;
break;
}
}
if (flag == 0) {
ans[ind++] = i;
for (y = 0; y < m; y++)
avail[y] += alloc[i][y];
f[i] = 1;
}
}
}
}
int flag = 1;
for(int i = 0;i<n;i++)
{
if(f[i]==0)
{
flag = 0;
cout << "The given sequence is not safe";
break;
}
}
if(flag==1)
{
cout << "Following is the SAFE Sequence" << endl;
for (i = 0; i < n - 1; i++)
cout << " P" << ans[i] << " ->";
cout << " P" << ans[n - 1] <<endl;
}
return (0);
}
Outcomes:
Experiment-8
Objective:Write a program to simulate memory allocation strategies (First feed, best feed, worst
feed).
Solution:
#include<bits/stdc++.h>
using namespace std;
void firstFit(int blockSize[], int m,int processSize[], int n)
{
int allocation[n];
memset(allocation, -1, sizeof(allocation));
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
if (blockSize[j] >= processSize[i])
{
allocation[i] = j;
blockSize[j] -= processSize[i];
break;
}
}
}
cout << "First Fit \nProcess No.\tProcess Size\tBlock no.\n";
for (int i = 0; i < n; i++)
{
cout << " " << i+1 << "\t\t"
<< processSize[i] << "\t\t";
if (allocation[i] != -1)
cout << allocation[i] + 1;
else
cout << "Not Allocated";
cout << endl;
}
}
void bestfit(int bsize[], int m, int psize[], int n) {
int alloc[n];
memset(alloc, -1, sizeof(alloc));
for (int i=0; i<n; i++) {
int bestIdx = -1;
for (int j=0; j<m; j++) {
if (bsize[j] >= psize[i]) {
if (bestIdx == -1)
bestIdx = j;
else if (bsize[bestIdx] > bsize[j])
bestIdx = j;
}
}
if (bestIdx != -1) {
alloc[i] = bestIdx;
bsize[bestIdx] -= psize[i];
}
}
cout << "Best Fit \nProcess No.\tProcess Size\tBlock no."<<endl;
for (int i = 0; i < n; i++) {
cout << " " << i+1 << "\t\t" << psize[i] << "\t\t";
if (alloc[i] != -1)
cout << alloc[i] + 1;
else
cout << "Not Allocated";
cout << endl;
}
}
int main()
{
int blockSize[] = {100, 500, 200, 300, 600};
int processSize[] = {212, 417, 112, 426};
int m = sizeof(blockSize) / sizeof(blockSize[0]);
int n = sizeof(processSize) / sizeof(processSize[0]);
Solution:
#include <bits/stdc++.h>
using namespace std;
int predict(int page[], vector<int>& fr, int pn, int index) {
if (j == pn)
return i;
}
if (search(page[i], fr)) {
hit++;
continue;
}
int main() {
int page[] = { 2, 7, 8, 3, 0, 2, 0, 3, 5, 4, 0, 6, 1 };
int pn = sizeof(page) / sizeof(page[0]);
int fn = 3;
opr(page, pn, fn);
return 0;
}
Outcomes:
Experiment-10
Solution:
#include <bits/stdc++.h>
using namespace std;
int size = 8;
int disk_size = 200;
int main()
{
int arr[size] = { 176, 79, 34, 60, 92, 11, 41, 114 };
int head = 50;
string direction = "left";
FCFS(arr, head);
cout<<endl;
cout << "Initial position of head: " << head << endl;
CSCAN(arr, head);
cout<<endl;
cout << "Initial position of head: " << head << endl;
CLOOK(arr, head);
return 0;
}
Outcomes: