You are on page 1of 20

OPERATING SYSTEM

LAB FILE

SUBMITTED BY: SUBMITTED TO:


KUNDAN TIWARY PRIYANKA SACHDEVA
8614155
CSE (G2)
INDEX

s.no. Experiment Date Signature

1 Study of hardware and software requirements of


different operating systems.

2 Implementation of FCFS (First Come First Serve)


scheduling algorithm.

3 Implementation of SJF (shortest job first)


scheduling algorithm

4 Implementation of priority scheduling algorithm

5 Implementation of Round Robin algorithm

6 Implementation of Worst-Fit algorithm

7 Implementation of Best-Fit algorithm

8 Implementation of Bankers algorithm


1. Study of hardware and software requirements of different operating
systems.
An operating system is a program that acts as an interface between the user and the computer
hardware and controls the execution of all kinds of programs.

Following are some of important functions of an operating System.

Memory Management

Processor Management

Device Management

File Management

Security

Control over system performance

Job accounting

Error detecting aids

Coordination between other software and users

All major computer platforms (hardware and software) require and includes an operating
system.

Examples of popular desktop operating systems include Apple OS X, Linux and its
variants, and Microsoft Windows. So-called mobile operating systems
include Android and iOS. Other classes of operating systems, such as real-time (RTOS),
also exist.

Windows 7 system requirements

1 gigahertz (GHz) or faster 32-bit (x86) or 64-bit (x64) processor*

1 gigabyte (GB) RAM (32-bit) or 2 GB RAM (64-bit)

16 GB available hard disk space (32-bit) or 20 GB (64-bit)

DirectX 9 graphics device with WDDM 1.0 or higher driver


Linux Operating System and Hardware Requirements

Criteria Requirements
Operating System Red Hat Enterprise Linux 4 or 5 with the latest patches and upgrades
CPU Type Pentium 4 or higher; 2 GHz or higher
Memory/RAM 1 GB minimum, up to the system limit
Hard Disk 4 GB minimum

Linux operating system software requirements

WebSphere MQ Explorer requirements. If you want to use the WebSphere MQ Explorer


(available for use with WebSphere MQ for Linux, (x86 and x86-64 platforms) only), your
system requires the following things, as a minimum: 512 MB RAM. 1 GHz processor.

System requirements for UNIX platforms


Following are the minimum system requirements for HP 9000 (8xx), HP Itanium, RISC/6000
AIX, Sun Solaris, and Linux. The software requirements section identifies required software for
specific ECDA products.

Apple computers must meet the following minimal hardware and software requirements.

x86-64 processor (64-bit Mac with an Intel Core 2 Duo, Intel Core i3, Intel Core i5, Intel
Core i7, or Xeon processor)

8 GB of memory

150 GB of internal storage

Network interface card

Mac OS X version 10.7 and above

Java SE 7 runtime (Required by Eclipse. You are prompted to install Java SE 7 runtime
the first time you launchKony Visualizer.
System requirements for UNIX platforms

RISC/6000
Item HP 9000(8xx) AIX Sun Solaris Linux HP Itanium

CPU HP 9000/800 IBM RISC Sun Solaris Intel- Itanium


System/6000 (SPARC) compatible Processor
system Family (IPF)

RAM 256MB, 256MB, 256MB, 256MB, 256MB,


minimum. minimum minimum minimum minimum

Storage Minimum of Minimum of Minimum of Minimum of Minimum of


300MB, and 300MB, and 300MB, and 300MB, and 300MB, and
at least at least at least at least at least
500KB for 500KB for 500KB for 500KB for 500KB for
each locale yo each locale yo each locale yo each locale yo each locale yo
u support u support u support u support u support

Software requirements

Platform HP-UX 11.23 AIX 5.3 Sun Solaris Linux Red HP-UX 11.31
requiremen 2.9 and 2.10 Hat 3.0, 4.0, ia64
ts and 5.0
SuSE 9.0
and 10
2. Implementation of FCFS (First Come First Serve) scheduling algorithm.

#include<stdio.h>
#include<conio.h>
void main()
{
int n,p[10],b[10],i,j,r;
clrscr();
printf(" Enter the number of process:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
j=i;
printf("\n Enter process number:");
scanf("%d",&p[j]);
printf(" Enter brust time:");
scanf("%d",&b[j]);
}

printf("\n*****************************************************************************
***");
printf("\n Displaying the processes");
for(j=1;j<=i;j++)
{
printf("\n\n");
for(r=1;r<=b[j];r++)
{
printf("P%d ",p[j]);
}}
getch();
}
3. Implementation of SJF (shortest job first) scheduling algorithm.

#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,bt[10],p[10],j,r,temp;
clrscr();
printf("please enter the number of processes");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("enter the process number");
scanf("%d",&p[i]);
printf("enter the burst time");
scanf("%d",&bt[i]);
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(bt[j]<bt[i])
{
temp=bt[i];
bt[i]=bt[j];
bt[j]=temp;
temp=p[i];
p[i]=p[j];
p[j]=temp;
}
}
}
for(j=0;j<i;j++)
{
printf("\n");
for(r=0;r<bt[j];r++)
{
printf("p%d \t",p[j]);
}
}

getch ();
}
4. Implementation of priority scheduling algorithm.
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,temp,n,time[10],process[10],temp1,p[10];
clrscr();
printf("\n Enter the number of processes: ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\n Enter process number: ");
scanf("%d",&process[i]);
printf("\n Enter Brust time: ");
scanf("%d",&time[i]);
printf("\n Enter priority: ");
scanf("%d",&p[i]);
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(p[j]<p[i])
{
temp=p[i];
temp1=process[i];
p[i]=p [j];
process[i]=process[j];
p[j]=temp;
process[j]=temp1;
temp=time[i];
time[i]=time[j];
time[j]=temp;

}}}
printf("\n Displaying the processes\n");
printf("------------------------------------------------------------------------------");
for(i=0;i<n;i++)
{
printf("\n");
for(j=0;j<time[i];j++)
{
printf("P%d ",process[i]);
}
}
getch();
}
5. Implementation of Round Robin algorithm.

#include<stdio.h>
#include<conio.h>
void main()
{
int n,time[100],name[100],max;
int btime,i,k;
clrscr();
printf("enter the no of processes: ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("enter the process no: ");
scanf("%d",&name[i]);
printf("enter the burst time: ");
scanf("%d",&time[i]);
max=0;
if(max<time[i])
{
max=time[i];
}
}
printf("enter Quantum no: ");
scanf("%d",&btime);

for(i=0;i<max;i++)
{
printf("\nround %d: ",i+1);
printf("");
for(k=0;k<n;k++)
{
int j=btime;
while(time[k]>0 && j>0)
{
printf("\tP%d",name[k]);
time[k]--;
j--;
} } }
getch();
}
6. Implementation of Worst-Fit algorithm.

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,temp,a,b,h[10],m[10],n[10];
clrscr();
printf("\nEnter the number of Processes: ");
scanf("%d",&a);
printf("\nEnter the number of Memory Blocks ");
scanf("%d",&b);
for(i=0;i<a;i++)
{
printf("\nEnter the size for process P%d ",i+1);
scanf("%d",&h[i]);
}
for(i=0;i<b;i++)
{
printf("\nEnter the size for memory block %d ",i+1);
scanf("%d",&m[i]);
}
for(i=0;i<b;i++)
{
for(j=i+1;j<b;j++)
{
if(m[j]>m[i])
{
temp=m[i];
m[i]=m[j];
m[j]=temp;
}
}
}
for(i=0;i<a;i++)
{
if(h[i]<=m[i])
n[i]=1;
else
n[i]=0;
}
for(i=0;i<a;i++)
{
if(n[i]==1)
{
printf("\nProcess P%d is allocated in memory block %d\n",i+1,i+1);
}
else
printf("\nNot enough space for Process P%d\n",i+1);
}
getch();
}
7. Implementation of Best-Fit algorithm.

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,mem[30],n,pro[30],m,temp,k,avail[5],t;
clrscr();
printf( "enter the no. of partition of memory:");
scanf("%d",&n);
printf("partitions in memory");
for(i=0;i<n;i++)
{
scanf("%d",&mem[i]);
}
printf("enter the no of process to be placed in memory:");
scanf("%d",&m);
printf("processes are");
for(j=0;j<m;j++)
{
scanf("%d",&pro[j]);
}
for(i=0;i<n;i++)
{
t=i;
for(j=i+1;j<m;j++)
{
if(mem[t]>mem[j])
{
temp=mem[j];
mem[j]=mem[t];
mem[t]=temp;
}
}
}
for(i=0;i<n;i++)
{
printf("Your entered memory blocks are: %d\n",mem[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
if(pro[i]<=mem[j])
{
printf(" the process %d is placed in memory %d\n",pro[i],mem[j]);
k=j;
mem[k]=0;
avail[i]=pro[i];
break;
}
}
}
for(i=0;i<n;i++)
{
if(pro[i]!=avail[i])
{
printf(" the process %d cannot be placed\n",pro[i]);
}
}
getch();
}
8. Implementation of Bankers algorithm.

#include<stdio.h>
#include<conio.h>
void main()
{
int p,r,i,j,l,k=0,count1=0,count2=0;
int avail[10],max[10][10],allot[10][10],need[10][10],completed[10];
clrscr();
printf("Enter No. of Process:-");
scanf("%d",&p); //Entering No. of Processes
printf("Enter No. of Resources:-");
scanf("%d",&r); //No. of Resources

for(i=0;i<p;i++)
completed[i]=0; //Setting Flag for uncompleted Process

printf("Enter No. of Available Instances\n");


for(i=0;i<r;i++)
{
scanf("%d",&l);
avail[i]=l; // Storing Available instances
}
printf("Enter Maximum No. of instances of resources that a Process need:\n");
for(i=0;i<p;i++)
{
printf("For P[%d]",i);
for(j=0;j<r;j++)
{
scanf("%d",&l);
max[i][j]=l;
}
}
printf(" Enter no. of instances already allocated to process of a resource:\n");
for(i=0;i<p;i++)
{
printf(" For P[%d]",i);
for(j=0;j<r;j++)
{
scanf("%d",&l);
allot[i][j]=l;

need[i][j]=max[i][j]-allot[i][j]; //calculating Need of each process


}
}
printf(" Safe Sequence is:- \t");
while(count1!=p)
{
count2=count1;
for(i=0;i<p;i++)
{
for(j=0;j<r;j++)
{
if(need[i][j]<=avail[j])
k++;
}

if(k==r && completed[i]==0 )

printf("P[%d]\t",i);
completed[i]=1;
for(j=0;j<r;j++)
{
avail[j]=avail[j]+allot[i][j];
}
count1++;

}
k=0;
}

if(count1==count2)

{
printf("\t\t Stop ..After this.....Deadlock \n");
}
getch();
}

You might also like