Operating Systems
CPU Scheduling Algorithms
- First Come First Serve (FCFS)
- Shortest Job First (SJF) [No pre-emption, with arrival times] Shortest Job First (SJF) [Pre-emptive, with arrival times]
- Round Robin
- Priority
Page Replacement Algorithms
CPU Scheduling Algorithms
Page Replacement Algorithms
//FIFO PAGE REPLACEMENT ALGORITHM
#include <stdio.h>
#include <conio.h>
int main()
{
int n, rss, fa[20], rsa[50]; //n-No_of_Frames
//rss->Reference_String_Size::fa->Frame_Array
//rsa->Reference_String_Array::ta->Temporary_Array
int i,j,k,pfc=0,npf, cp=0;
//cp->Current_Position :: ff->Frames_Filled ::pfc->Page_Fault_Count
//npf:NO_Page_Faults [0-False, 1-True]
printf("Enter number of frames: ");
scanf("%d", &n);
printf("Enter number of pages in reference string: ");
scanf("%d", &rss);
printf("Enter Reference string:\n");
for(i=0; i<rss; i++)
scanf("%d",&rsa[i]);
for(i=0;i<n;i++)
fa[i]=-1;
printf("\nCURRENT_PAGE\t\tPAGES_IN_FRAME\t\tPAGE_FAULT_OCCURED?\n");
for(i=0; i<rss; i++)
{
printf("\n\t%d\t\t",rsa[i]);
npf=0;
for(j=0;j<n;j++) //Checking for the page in FRAME ARRAY
{
if(fa[j]==rsa[i])
{
npf = 1;
printf("\t\t\t\tNO");
break;
}
}
if(npf==0) // if page fault occurs
{
pfc++;
fa[cp] = rsa[i];
cp=(cp+1)%n;
for(j=0;j<n;j++)
printf("%d\t",fa[j]);
printf("\tYES");
}
}
printf("\nTotal no of pagefaults: %d",pfc);
return 0;
}
LRU Page Replacement Algorithm
//LRU PAGE REPLACEMENT ALGORITHM
#include <stdio.h>
#include <conio.h>
int main()
{
int n, rss, fa[20], rsa[50], ta[20]; //n-No_of_Frames
//rss->Reference_String_Size::fa->Frame_Array
//rsa->Reference_String_Array::ta->Temporary_Array
int i,j,k,pfc=0,npf, cp;
//cp->Current_Position ::pfc->Page_Fault_Count
//npf:NO_Page_Faults [0-False, 1-True]
printf("Enter number of frames: ");
scanf("%d", &n);
printf("Enter number of pages in reference string: ");
scanf("%d", &rss);
printf("Enter Reference string:\n");
for(i=0; i<rss; i++)
scanf("%d",&rsa[i]);
for(i=0;i<n;i++)
fa[i]=-1;
for(i=0;i<n;i++)
ta[i]=n-(i+1);
printf("\nCURRENT_PAGE\t\tPAGES_IN_FRAME\t\tPAGE_FAULT_OCCURED?\n");
for(i=0; i<rss; i++)
{
printf("\n\t%d\t\t",rsa[i]);
npf=0;
for(j=0;j<n;j++) //Checking for the page in FRAME ARRAY
{
if(fa[j]==rsa[i])
{
npf = 1;
for(k=0;k<n;k++)
ta[k]++;
ta[j]=0;
printf("\t\t\t\tNO");
break;
}
}
if(npf==0) // if page fault occurs
{
pfc++;
cp=0;
for(j=1;j<n;j++)
if(ta[cp]<ta[j])
cp=j; //cp->current position
fa[cp] = rsa[i];
for(k=0;k<n;k++)
ta[k]++;
ta[cp]=0;
for(j=0;j<n;j++)
printf("%d\t",fa[j]);
printf("\tYES");
}
}
printf("\nTotal no of pagefaults: %d",pfc);
return 0;
}
Optimal Page Replacement Algorithm
//OPTIMAL PAGE REPLACEMENT ALGORITHM
#include <stdio.h>
#include <conio.h>
int main()
{
int n, rss, fa[20], rsa[50], ta[20]; //n-No_of_Frames
//rss->Reference_String_Size::fa->Frame_Array
//rsa->Reference_String_Array::ta->Temporary_Array
int i,j,k, d,pfc=0,npf, cp,ff=0;
//d-distance[How soon a page will be used again?]
//cp->Current_Position :: ff->Frames_Filled ::pfc->Page_Fault_Count
//npf:NO_Page_Faults [0-False, 1-True]
printf("Enter number of frames: ");
scanf("%d", &n);
printf("Enter number of pages in reference string: ");
scanf("%d", &rss);
printf("Enter Reference string:\n");
for(i=0; i<rss; i++)
scanf("%d",&rsa[i]);
for(i=0;i<n;i++)
{
fa[i]=-1;
ta[i]=999;
}
printf("\nCURRENT_PAGE\t\tPAGES_IN_FRAME\t\tPAGE_FAULT_OCCURED?\n");
for(i=0; i<rss; i++)
{
printf("\n\t%d\t\t",rsa[i]);
npf=0;
for(j=0;j<n;j++) //Checking for the page in FRAME ARRAY
{
if(fa[j]==rsa[i])
{
npf = 1;
printf("\t\t\t\tNO");
break;
}
}
if(npf==0) // if page fault occurs
{
pfc++;
if(ff<n)
{
fa[ff]=rsa[i];
ff++;
}
else
{
for(k=0;k<n;k++)
ta[k]=999;
for(k=0; k<n; k++) //finding how near a page is
{
d = 0; // d-> distance
for(j=i+1;j<rss;j++)
{
if(fa[k]==rsa[j])
{
ta[k]=d;
break;
}
else
d++;
}
}
cp=0;
for(j=1;j<n;j++)
{
if(ta[cp]<ta[j])
cp=j; //cp->current position
}
fa[cp] = rsa[i];
}
for(j=0;j<n;j++)
printf("%d\t",fa[j]);
printf("\tYES");
}
}
printf("\nTotal no of pagefaults: %d",pfc);
return 0;
}
S.No | Name of the Subject | Youtube links | Online Resources | Youtube |
1 | Computer Programming | C link |
S.No | Name of the Subject | Online Resources | Youtube | |
1 | Data Structures | DS link |
S.No | Name of the Subject | Online Resources | Youtube | |
1 | Mathematical Foundations of Computer | MFCS link | ||
2 | Advanced Programming in C++ and Java | C++ link JAVA link |
S.No | Name of the Subject | Online Resources | Youtube | |
1 | Digital Logic Design & Computer Organization | DLD Link CO link | ||
2 | Database Management Systems | DBMS link DBMS link | ||
3 | OOPS Through PYTHON | PP link | ||
4 | Operating Systems | OS link | ||
5 | Design and Analysis of Algorithms | DAA link |
S.No | Name of the Subject | Online Resources | Youtube | |
1 | Principles of Programming Languages | PPL link | ||
2 | SOFTWARE ENGINEERING | SE link | ||
3 | OPERATING SYSTEM | |||
4 | DATA COMUNICATION &COMPUTER NETWORK | DCN Link | ||
5 | COMPUTER FORENSICS | CF Link | ||
6 | MICROPROCESSOR&INTERFACE |
S.No | Name of the Subject | Online Resources | Youtube | |
1 | Object Oriented Analysis & Design | OOAD link | ||
2 | Compiler Design | CD link | ||
3 | Network Security | NS Link | ||
4 | Web Technologies | WT link1 WT link2 WT link3 | ||
5 | MANAGERIAL ECO.&FINANCIAL ANA. | |||
6 | VLSI Design |
S.No | Name of the Subject | Online Resources | Youtube | |
1 | SOFTWARE TESTING METHODOLOGY | SE link | ||
2 | LINUX PROGRAMMING | |||
3 | COMPUTER GRAGHICS | CG link | ||
4 | CLOUD COMPUTING | CC Link | ||
5 | DATA WAREHOUSING &DATA MINING | DWDM link | ||
6 | INFORMATION RETRIVAL SYSTEM |
S.No | Name of the Subject | Online Resources | Youtube | |
1 | Scripting Languages | SL Link1 SL Link2 | ||
2 | Storage Area Network | SAN Link |
“We show that Shor’s algorithm, the most complex quantum algorithm known to date, is realizable in a way where, yes, all you have to do is go in the lab, apply more technology, and you should be able to make a bigger quantum computer.”
“It might still cost an enormous amount of money to build — you won’t be building a quantum computer and putting it on your desktop anytime soon — but now it’s much more an engineering effort, and not a basic physics question.” ~Isaac Chuang, professor of physics and professor of electrical engineering and computer science at MIT
“That way, we know exactly where that atom is in space,”
“Then we do that with another atom, a few microns away — [a distance] about 100th the width of a human hair. By having a number of these atoms together, they can still interact with each other, because they’re charged. That interaction lets us perform logic gates, which allow us to realize the primitives of the Shor factoring algorithm. The gates we perform can work on any of these kinds of atoms, no matter how large we make the system.”
“In future generations, we foresee it being straightforwardly scalable, once the apparatus can trap more atoms and more laser beams can control the pulses. We see no physical reason why that is not going to be in the cards.”