//PROGRAM FOR SHORTEST-JOB-FIRST(SJF) "CPU SCHEDULING ALGORITHM" WITH PRE_EMPTION
#include<stdio.h>
#include<conio.h>
int main()
{
int n,at[10], bt[10], ct[10], wt[10], tn =0, c, ta[10],tat[10];
//at-ArritvalTime::br-BurstTime::ct-CompletionTime::ta-TemporaryArray
//wt-WaitingTime::tat-TurnAroundTime::tn-CurrentTime(TimeNow)
// int i, j, k, tot, pc=0, pointer = 0, lp=-1;//lp-Last-executedProcess
int i, k, tot, pc=0, pointer = 0, lp=-1;//lp-Last-executedProcess
char pn[10][10];
printf("Enter the number of processes: ");
scanf("%d",&n);
printf("Enter <ProcessName> <ArrivalTime> <BurstTime>\n");
for(i=0;i<n;i++)
scanf("%s%d%d",&pn[i],&at[i],&bt[i]);
for(i=0; i<n; i++)
{
ct[i] = -1;
ta[i] = bt[i];
}
while(pc!=n)
{
k=0;
c = 0;
for(i=0; i<n; i++)
{
if(ct[i]<0 && at[i]<=tn)
c++;
}
if(c==0)
tn++;
else
{
pointer = 0;
while(at[pointer]>tn || ct[pointer]>0)
pointer++;
for(k=pointer+1; k<n; k++)
if( (at[k]<=tn && ct[k]<0) &&
( (bt[pointer]==bt[k] && k==lp) || bt[pointer]>bt[k] ) )
pointer = k;
if(ct[pointer]<0)
{
bt[pointer]--;
tn++;
if(bt[pointer]==0)
{
ct[pointer] = tn;
wt[pointer] = ct[pointer] - ( at[pointer]+ ta[pointer] );
tat[pointer] = ct[pointer] - at[pointer];
pc++;
}
}
lp = pointer;
}
}
printf("\nPN\tAT\tBT\tCT\tWT\tTAT\n");
for(i=0;i<n;i++)
printf("%s\t%d\t%d\t%d\t%d\t%d\n",pn[i],at[i],ta[i],ct[i],wt[i],tat[i]);
return 0;
}
/* SAMPLE OUTPUT
Enter the number of processes: 6
Enter <ProcessName> <ArrivalTime> <BurstTime>
p1 3 1
p2 1 4
p3 10 6
p4 25 10
p5 1 3
p6 12 3
PN AT BT CT WT TAT
p1 3 1 5 1 2
p2 1 4 9 4 8
p3 10 6 19 3 9
p4 25 10 35 0 10
p5 1 3 4 0 3
p6 12 3 15 0 3
*/
Thursday 7 April 2016
SJF CPU Scheduling Algorithm (Preemptive)
SJF CPU Scheduling Algorithm (Non-Preemptive)
//PROGRAM FOR SHORTEST-JOB-FIRST(SJF) "CPU SCHEDULING ALGORITHM" WITHOUT PRE_EMPTION
#include<stdio.h>
#include<conio.h>
int main()
{
int at[10], bt[10], ct[10], wt[10], ta[10], tat[10];
//at-ArritvalTime::br-BurstTime::ct-CompletionTime::ta-TemporaryArray
//wt-WaitingTime::tat-TurnAroundTime::tn-CurrentTime(TimeNow)
int n, i, k, pc=0, pointer = 0, tn =0, c;//pc-ProcessesCompleted
char pn[10][10]; //pn-ProcessName
printf("Enter the number of processes: ");
scanf("%d",&n);
printf("Enter <ProcessName> <ArrivalTime> <BurstTime>\n");
for(i=0;i<n;i++)
scanf("%s%d%d",&pn[i],&at[i],&bt[i]);
for(i=0; i<n; i++)
{
ct[i] = -1;
ta[i] = bt[i];
}
while(pc!=n)
{
c = 0;
for(i=0; i<n; i++)
if(ct[i]<0 && at[i]<=tn)
c++;
if(c==0)
tn++;
else
{
pointer = 0;
while(at[pointer]>tn || ct[pointer]>0)
pointer++;
for(k=pointer+1; k<n; k++)
if(at[k]<=tn && ct[k]<0 && bt[pointer]>bt[k])
pointer = k;
if(ct[pointer]<0)
{
tn=tn+bt[pointer];
bt[pointer] = 0;
ct[pointer] = tn;
wt[pointer] = ct[pointer] - ( at[pointer]+ ta[pointer] );
tat[pointer] = ct[pointer] - at[pointer];
pc++;
}
}
}
printf("\nPN\tAT\tBT\tCT\tWT\tTAT\n");
for(i=0;i<n;i++)
printf("%s\t%d\t%d\t%d\t%d\t%d\n",pn[i],at[i],ta[i],ct[i],wt[i],tat[i]);
return 0;
}
/* EXAMPLE OUTPUT
Enter the number of processes: 6
Enter <ProcessName> <ArrivalTime> <BurstTime>
p1 3 2
p2 6 5
p3 1 1
p4 6 2
p5 15 3
p6 20 10
PN AT BT CT WT TAT
p1 3 2 5 0 2
p2 6 5 13 2 7
p3 1 1 2 0 1
p4 6 2 8 0 2
p5 15 3 18 0 3
p6 20 10 30 0 10
*/
//ANOTHER PROGRAM for the same problem
//PROGRAM FOR SHORTEST-JOB-FIRST(SJF) "CPU SCHEDULING ALGORITHM" WITH NO-PRE_EMPTION & ARRIVAL TIMES
#include<stdio.h>
#include<string.h>
int main(void)
{
//VARIABLE DECLARATION
char pn[20][20], c[20][20]; //PN-PROGRAM NAMES C-A TEMPORARY ARRAY
int n,i,j,at[20], bt[20], wt[20],ct[20],tat[20]; //bt-BURST TIME ; wt-WAITING TIME; tat-TURN AROUND TIME
int temp1, temp2, count=0,twt=0;//,tat=0;
printf("Enter number of processes:");
scanf("%d", &n);
printf("Enter PN, AT, BT:\n");
//TAKING INPUT VALUES i.e., PROCESS-NAMES, ARRIVAL-TIMES AND BURST-TIMES
for(i=0; i<n; i++)
scanf("%s%d%d",&pn[i],&at[i],&bt[i]);
//SCHEDULING THE PROCESSES ACCORDING TO SJF
for(i=0 ; i<n; i++)
{
for(j=i+1; j<n; j++)
if (
//IF THERE IS NO PROCESS IN MAIN MEMORY,
//SORT PROCESSES ACCORDING TO ARRIVAL TIMES &
//IF WE GOT PROCESSES WITH SAME ARRIVAL TIME SORT THEM BY BURST TIMES
( (i==0||count<1)&&(at[i]>at[j]||(at[i]==at[j]&&bt[i]>bt[j])) )
//IF WE GOT ONLY ONE PROCESS IN MAIN MEMORY AFTER COMPLETION OF THE CURRENT PROCESS
|| (count == 1 && ct[i-1]>=at[j])
//IF WE GOT MORE THAN ONE PROCESS IN MAIN MEMORY, SORT THEM BY BURST TIMES
|| ((ct[i-1]>=at[j]&&bt[i]>bt[j]))// || (ct[i-1]<at[i]&&ct[i-1]>=at[j]))
)
//SWAPPING PROCESSES
{
temp1 = bt[i];
temp2 = at[i];
bt[i] = bt[j];
at[i] = at[j];
bt[j] = temp1;
at[j] = temp2;
strcpy(c[i],pn[i]);
strcpy(pn[i],pn[j]);
strcpy(pn[j],c[i]);
}
if(i==0 || count<1)
ct[i] = at[i] + bt[i];
else
ct[i] = ct[i-1] + bt[i];
wt[i] = ct[i] - (at[i] + bt[i]);
tat[i] = ct[i] - at[i];
count = 0 ;
for(j=i+1; j<n; j++)
if(ct[i]>=at[j])
count++;
}
//PRINTING THE VALUES AFTER ALL PREOCESSES COMPLETED
printf("S.N.\tProcess-Name\tArrival-Time\tBurst-Time\tCT\tWT\tTAT\n");
for(i=0; i<n; i++)
printf("%d\t\t%s\t\t%d\t\t%d\t%d\t%d\t%d\n",(i+1),pn[i],at[i],bt[i],ct[i],wt[i],tat[i]);
} //END OF MAIN
/* EXAMPLE OUTPUT
Enter number of processes:6
Enter PN, AT, BT:
p1 3 2
p2 6 5
p3 1 1
p4 6 2
p5 15 3
p6 20 10
S.N. Process-Name Arrival-Time Burst-Time CT WT TAT
1 p3 1 1 2 0 1
2 p1 3 2 5 0 2
3 p4 6 2 8 0 2
4 p2 6 5 13 2 7
5 p5 15 3 18 0 3
6 p6 20 10 30 0 10
*/
FCFS
FCFS CPU Scheduling Algorithm
//PROGRAM FOR FIRST-COME-FIRST-SERVE "CPU SCHEDULING ALGORITHM"
#include<stdio.h>
#include<string.h>
int main(void)
{
//VARIABLE DECLARATION
char pn[20][20], c[20][20]; //PN-PROGRAM NAMES
int n,i,j,at[20], bt[20], wt[20],tat[20], ct[20]; //bt-BURST TIME ; wt-WAITING TIME; tat-TURN AROUND TIME
int twt=0, ttat=0, temp1, temp2;
printf("Enter number of processes:");
scanf("%d", &n);
//TAKING INPUT VALUES i.e., PROCESS-NAMES, ARRIVAL-TIMES AND BURST-TIMES
printf("Enter <Process-name> <Arrival-time> <Burst-time> for processes:\n", (i+1));
for(i=0; i<n; i++)
scanf("%s%d%d",&pn[i],&at[i],&bt[i]);
//SORT THE PROCESSES ACCORDING TO ARRIVAL TIMES
for(i=0;i<n;i++)
{
for(j=i+1; j<n;j++)
{
if(at[i]>at[j])
{
temp1 = bt[i];
temp2 = at[i];
bt[i] = bt[j];
at[i] = at[j];
bt[j] = temp1;
at[j] = temp2;
strcpy(c[i],pn[i]);
strcpy(pn[i],pn[j]);
strcpy(pn[j],c[i]);
}
}
if(i==0) ct[0]=at[0]+bt[0];
if(i>0)
{
if(at[i]>ct[i-1])
ct[i]=at[i]+bt[i];
else
ct[i]=ct[i-1]+bt[i];
}
}
//CALCULATING WAITING TIME & TAT
wt[0]=0;
tat[0]=ct[0]-at[0];
for(i=1;i<n;i++)
{
tat[i] = ct[i]-at[i];
wt[i] = tat[i]-bt[i];
twt += wt[i];
ttat += tat[i];
}
//PRINTING THE VALUES AFTER ALL PREOCESSES COMPLETED
printf("S.N.\tPN\tAT\tBT\tCT\tWT\tTAT\n");
for(i=0; i<n; i++)
printf("%d\t%s\t%d\t%d\t%d\t%d\t%d\n",(i+1),pn[i],at[i],bt[i],ct[i],wt[i],tat[i]);
printf("Total waiting time:%d\n", twt);
printf("Total Turn Around Time:%d", ttat);
}
Friday 1 April 2016
CCNA
Cisco’s Networking Academy offers you the skills and knowledge
required for home and small business networking. After completing this
course you will have the opportunity to sit for the newly revised
CCNA-ENT (Cisco Certified Network Associate, Entry-level Network
Technician) industry exam.
You are asking for the CCNA Course syllabus. Here I am uploading a file that contains the CCNA Course syllabus. This is as follows:
Class Expectations
Enter Prepared
Use Technology Responsibly
Behave Maturely
Lab Policies
Leave Things As You Found Them (or Better)
Maintain Privacy, Security, and Independence
Leave Food and Drink Outside
You can download CCNA Course syllabus from here. This is as follows:
CCNA Course syllabus
CCNA Course E-book
in a pdf atteched for more detail..............
You are asking for the CCNA Course syllabus. Here I am uploading a file that contains the CCNA Course syllabus. This is as follows:
Class Expectations
Enter Prepared
Use Technology Responsibly
Behave Maturely
Lab Policies
Leave Things As You Found Them (or Better)
Maintain Privacy, Security, and Independence
Leave Food and Drink Outside
You can download CCNA Course syllabus from here. This is as follows:
CCNA Course syllabus
CCNA Course E-book
in a pdf atteched for more detail..............
Cisco
Subscribe to:
Posts (Atom)