Operating System Programs
Operating System Programs
LAB FILE
Memory Management
Processor Management
Device Management
File Management
Security
Job accounting
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.
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
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
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
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("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();
}