SlideShare a Scribd company logo
1 of 7
Download to read offline
CODE:
#include
#include
struct task{//process
int id;//pid
int bt;//burst time
int at;//arrival time
int pr;//priority
};
typedef struct task Task;
typedef Task *TaskPtr;
struct qnode{//a node in the run/ready queue
Task data;//process
struct qnode *nextPtr;
};
typedef struct qnode Qnode;
typedef Qnode *QnodePtr;
void enqueue(QnodePtr *headPtr, QnodePtr *tailPtr,Task task);
Task dequeue(QnodePtr *headPtr, QnodePtr *tailPtr);
int isEmpty(QnodePtr headPtr);
void enqueue(QnodePtr *headPtr, QnodePtr *tailPtr,Task task){
QnodePtr newNodePtr = malloc( sizeof( Qnode));
if(newNodePtr !=NULL){
newNodePtr->data = task;
newNodePtr->nextPtr = NULL;
}
QnodePtr current = *headPtr, prev = NULL;
while(current!=NULL && task.bt>=(current->data).bt){
prev = current;
current = current->nextPtr;
}
if(prev==NULL){
newNodePtr->nextPtr= *headPtr;
*headPtr=newNodePtr;
}
else{
newNodePtr->nextPtr=prev->nextPtr;
prev->nextPtr=newNodePtr;
}
if(newNodePtr->nextPtr==NULL){
*tailPtr = newNodePtr;
}
}
Task dequeue(QnodePtr *headPtr, QnodePtr *tailPtr){
Task value;
QnodePtr tempPtr;
value = (*headPtr)->data;
tempPtr = *headPtr;
*headPtr = (*headPtr)->nextPtr;
if(*headPtr == NULL){
*tailPtr = NULL;
}
free (tempPtr);
return value;
}
int isEmpty(QnodePtr headPtr){
return headPtr == NULL;
}
///////////////////////////////////////////////
struct event{//an event event
int type;//event type 0:arrival, 1: departure
int time;//event time
Task task;//the process
};
typedef struct event Event;
typedef Event *EventPtr;
struct eventQnode{//an node in the events list
Event data;//the event
struct eventQnode *nextPtr;
};
typedef struct eventQnode EventQnode;
typedef EventQnode *EventQnodePtr;
void enqueueevent(EventQnodePtr *headPtr, EventQnodePtr *tailPtr,Event e);
Event dequeueevent(EventQnodePtr *headPtr, EventQnodePtr *tailPtr);
int isEmptyEQ(EventQnodePtr headPtr);
void displayEvents(EventQnodePtr currentPtr);
void enqueueevent(EventQnodePtr *headPtr, EventQnodePtr *tailPtr,Event se){
EventQnodePtr newNodePtr = malloc( sizeof( EventQnode));
if(newNodePtr !=NULL){
newNodePtr->data = se;
newNodePtr->nextPtr = NULL;
}
EventQnodePtr current = *headPtr, prev = NULL;
while(current!=NULL && se.time>(current->data).time){//find the insert position in order of
time
prev = current;
current = current->nextPtr;
}
while(current!=NULL && se.time==(current->data).time && se.type<(current-
>data).type){//then find the insert position in order of event's type
prev = current;
current = current->nextPtr;
}
if(prev==NULL){
newNodePtr->nextPtr= *headPtr;
*headPtr=newNodePtr;
}
else{
newNodePtr->nextPtr=prev->nextPtr;
prev->nextPtr=newNodePtr;
}
if(newNodePtr->nextPtr==NULL){
*tailPtr = newNodePtr;
}
}
Event dequeueevent(EventQnodePtr *headPtr, EventQnodePtr *tailPtr){
Event value;
EventQnodePtr tempPtr;
value = (*headPtr)->data;
tempPtr = *headPtr;
*headPtr = (*headPtr)->nextPtr;
if(*headPtr == NULL){
*tailPtr = NULL;
}
free (tempPtr);
return value;
}
int isEmptyEQ(EventQnodePtr headPtr){
return headPtr == NULL;
}
void displayEvents(EventQnodePtr currentPtr){
if(currentPtr==NULL)
printf("The event list is empty ... ");
else{
printf("The event list is: ");
Event tempevent;
while(currentPtr!=NULL){
printf(" time: %d, type : %d : task(id:%d,bt:%d) ",
(currentPtr->data).time, (currentPtr->data).type, (currentPtr->data).task.at,(currentPtr-
>data).task.bt);
currentPtr=currentPtr->nextPtr;
}
}
}
///////////////////////////////////////////////
const int MAXTASKS = 10;
const int MAXBURSTTIME = 70;
const int IAT = 30;
void main(){
QnodePtr rqheadPtr=NULL, rqtailPtr=NULL;//the run/ready queue
EventQnodePtr eventsQheadPtr=NULL, eventsQtailPtr=NULL;//the event queue/list
Task task;//the process structure
Event event;//the event structure
int prevat = 0, i;//set the previous arrival time to zero
for(i=0;i
Solution
#include
#include
#include
class cpuschedule
{
int n,bu[20];
float twt,awt,wt[20],tat[20];
public:
void Getdata();
void fcfs();
void sjf();
void roundrobin();
};
//Getting no of processes and Burst time
void cpuschedule::Getdata()
{
int i;
cout<<“Enter the no of processes:”;
cin>>n;
for(i=1;i<=n;i++)
{
cout<<“ Enter The BurstTime for Process p”<>bu[i];
}
}
//First come First served Algorithm
void cpuschedule::fcfs()
{
int i,b[10];
float sum=0.0;
twt=0.0;
for(i=1;i<=n;i++)
{
b[i]=bu[i];
cout<<“ Burst time for process p”<=1;i–)
{
for(j=2;j<=n;j++)
{
if(b[j-1]>b[j])
{
temp=b[j-1];
b[j-1]=b[j];
b[j]=temp;
}
}
}
wt[1]=0;
for(i=2;i<=n;i++)
{
wt[i]=b[i-1]+wt[i-1];
}
for(i=1;i<=n;i++)
{
twt=twt+wt[i];
tat[i]=b[i]+wt[i];
sum+=tat[i];
}
awt=twt/n;
sum=sum/n;
cout<<“ Total Waiting Time=”<>tq;
//TO find the dimension of the Round robin array
m=max/tq+1;
//initializing Round robin array
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
Rrobin[i][j]=0;
}
}
//placing value in the Rrobin array
i=1;
while(i<=n)
{
j=1;
while(b[i]>0)
{
if(b[i]>=tq)
{
b[i]=b[i]-tq;
Rrobin[i][j]=tq;
j++;
}
else
{
Rrobin[i][j]=b[i];
b[i]=0;
j++;
}
}
count[i]=j-1;
i++;
}
cout<<“Display”;
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
cout<<“ Rr[“<>ch;
getch();
}while(ch<5);
}

More Related Content

Similar to CODE#include stdlib.h #include stdio.hstruct task{proce.pdf

Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxteyaj1
 
Implement of c &amp; its coding programming by sarmad baloch
Implement of c &amp; its coding  programming by sarmad balochImplement of c &amp; its coding  programming by sarmad baloch
Implement of c &amp; its coding programming by sarmad balochSarmad Baloch
 
program on string in java Lab file 2 (3-year)
program on string in java Lab file 2 (3-year)program on string in java Lab file 2 (3-year)
program on string in java Lab file 2 (3-year)Ankit Gupta
 
GIVEN CODE template -typename T- class DList { private- struct Node {.docx
GIVEN CODE template -typename T- class DList { private- struct Node {.docxGIVEN CODE template -typename T- class DList { private- struct Node {.docx
GIVEN CODE template -typename T- class DList { private- struct Node {.docxLeonardN9WWelchw
 
Using Arbor/ RGraph JS libaries for Data Visualisation
Using Arbor/ RGraph JS libaries for Data VisualisationUsing Arbor/ RGraph JS libaries for Data Visualisation
Using Arbor/ RGraph JS libaries for Data VisualisationAlex Hardman
 
Write a C program that reads the words the user types at the command.pdf
Write a C program that reads the words the user types at the command.pdfWrite a C program that reads the words the user types at the command.pdf
Write a C program that reads the words the user types at the command.pdfSANDEEPARIHANT
 
#includeiostream struct node {    char value;    struct no.pdf
#includeiostream struct node {    char value;    struct no.pdf#includeiostream struct node {    char value;    struct no.pdf
#includeiostream struct node {    char value;    struct no.pdfankitmobileshop235
 
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docxcmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docxgordienaysmythe
 
In C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdfIn C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdffantoosh1
 
solution in c++program Program to implement a queue using two .pdf
solution in c++program Program to implement a queue using two .pdfsolution in c++program Program to implement a queue using two .pdf
solution in c++program Program to implement a queue using two .pdfbrijmote
 
#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdf#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdfannucommunication1
 
#includeiostream#includecstdio#includecstdlibusing names.pdf
#includeiostream#includecstdio#includecstdlibusing names.pdf#includeiostream#includecstdio#includecstdlibusing names.pdf
#includeiostream#includecstdio#includecstdlibusing names.pdfKUNALHARCHANDANI1
 
C++ Program to Implement Singly Linked List #includei.pdf
  C++ Program to Implement Singly Linked List  #includei.pdf  C++ Program to Implement Singly Linked List  #includei.pdf
C++ Program to Implement Singly Linked List #includei.pdfanupambedcovers
 
Please teach me how to fix the errors and where should be modified. .pdf
Please teach me how to fix the errors and where should be modified. .pdfPlease teach me how to fix the errors and where should be modified. .pdf
Please teach me how to fix the errors and where should be modified. .pdfamarndsons
 
mainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdfmainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdffathimafancyjeweller
 
Ugly code
Ugly codeUgly code
Ugly codeOdd-e
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYMalikireddy Bramhananda Reddy
 
Note             Given Code modified as required and required met.pdf
Note             Given Code modified as required and required met.pdfNote             Given Code modified as required and required met.pdf
Note             Given Code modified as required and required met.pdfAnkitchhabra28
 

Similar to CODE#include stdlib.h #include stdio.hstruct task{proce.pdf (20)

Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docx
 
Implement of c &amp; its coding programming by sarmad baloch
Implement of c &amp; its coding  programming by sarmad balochImplement of c &amp; its coding  programming by sarmad baloch
Implement of c &amp; its coding programming by sarmad baloch
 
program on string in java Lab file 2 (3-year)
program on string in java Lab file 2 (3-year)program on string in java Lab file 2 (3-year)
program on string in java Lab file 2 (3-year)
 
GIVEN CODE template -typename T- class DList { private- struct Node {.docx
GIVEN CODE template -typename T- class DList { private- struct Node {.docxGIVEN CODE template -typename T- class DList { private- struct Node {.docx
GIVEN CODE template -typename T- class DList { private- struct Node {.docx
 
Using Arbor/ RGraph JS libaries for Data Visualisation
Using Arbor/ RGraph JS libaries for Data VisualisationUsing Arbor/ RGraph JS libaries for Data Visualisation
Using Arbor/ RGraph JS libaries for Data Visualisation
 
Write a C program that reads the words the user types at the command.pdf
Write a C program that reads the words the user types at the command.pdfWrite a C program that reads the words the user types at the command.pdf
Write a C program that reads the words the user types at the command.pdf
 
#includeiostream struct node {    char value;    struct no.pdf
#includeiostream struct node {    char value;    struct no.pdf#includeiostream struct node {    char value;    struct no.pdf
#includeiostream struct node {    char value;    struct no.pdf
 
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docxcmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
 
Sorter
SorterSorter
Sorter
 
In C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdfIn C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdf
 
solution in c++program Program to implement a queue using two .pdf
solution in c++program Program to implement a queue using two .pdfsolution in c++program Program to implement a queue using two .pdf
solution in c++program Program to implement a queue using two .pdf
 
#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdf#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdf
 
#includeiostream#includecstdio#includecstdlibusing names.pdf
#includeiostream#includecstdio#includecstdlibusing names.pdf#includeiostream#includecstdio#includecstdlibusing names.pdf
#includeiostream#includecstdio#includecstdlibusing names.pdf
 
C++ Program to Implement Singly Linked List #includei.pdf
  C++ Program to Implement Singly Linked List  #includei.pdf  C++ Program to Implement Singly Linked List  #includei.pdf
C++ Program to Implement Singly Linked List #includei.pdf
 
Please teach me how to fix the errors and where should be modified. .pdf
Please teach me how to fix the errors and where should be modified. .pdfPlease teach me how to fix the errors and where should be modified. .pdf
Please teach me how to fix the errors and where should be modified. .pdf
 
mainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdfmainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdf
 
Ugly code
Ugly codeUgly code
Ugly code
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
 
Note             Given Code modified as required and required met.pdf
Note             Given Code modified as required and required met.pdfNote             Given Code modified as required and required met.pdf
Note             Given Code modified as required and required met.pdf
 

More from fathimalinks

Write the following using javaGiven a class ‘Node’ and ‘NodeList’,.pdf
Write the following using javaGiven a class ‘Node’ and ‘NodeList’,.pdfWrite the following using javaGiven a class ‘Node’ and ‘NodeList’,.pdf
Write the following using javaGiven a class ‘Node’ and ‘NodeList’,.pdffathimalinks
 
Write a program in C++ that declares a structure to store the code n.pdf
Write a program in C++ that declares a structure to store the code n.pdfWrite a program in C++ that declares a structure to store the code n.pdf
Write a program in C++ that declares a structure to store the code n.pdffathimalinks
 
Write a generic VBA Sub procedure to compute the value of the follow.pdf
Write a generic VBA Sub procedure to compute the value of the follow.pdfWrite a generic VBA Sub procedure to compute the value of the follow.pdf
Write a generic VBA Sub procedure to compute the value of the follow.pdffathimalinks
 
Why are standards needed in data communication and networking What .pdf
Why are standards needed in data communication and networking What .pdfWhy are standards needed in data communication and networking What .pdf
Why are standards needed in data communication and networking What .pdffathimalinks
 
Which of the following are mismatched A. Giordia - transmitted by f.pdf
Which of the following are mismatched  A. Giordia - transmitted by f.pdfWhich of the following are mismatched  A. Giordia - transmitted by f.pdf
Which of the following are mismatched A. Giordia - transmitted by f.pdffathimalinks
 
Which of the following statements about human evolution is correct.pdf
Which of the following statements about human evolution is correct.pdfWhich of the following statements about human evolution is correct.pdf
Which of the following statements about human evolution is correct.pdffathimalinks
 
What are the six major pollutions in the National Ambient Air Qualit.pdf
What are the six major pollutions in the National Ambient Air Qualit.pdfWhat are the six major pollutions in the National Ambient Air Qualit.pdf
What are the six major pollutions in the National Ambient Air Qualit.pdffathimalinks
 
UPS Worldpart DiscussionWhat do you think are the operational str.pdf
UPS Worldpart DiscussionWhat do you think are the operational str.pdfUPS Worldpart DiscussionWhat do you think are the operational str.pdf
UPS Worldpart DiscussionWhat do you think are the operational str.pdffathimalinks
 
True or False Justify your answer.Using multilevel signaling, it .pdf
True or False Justify your answer.Using multilevel signaling, it .pdfTrue or False Justify your answer.Using multilevel signaling, it .pdf
True or False Justify your answer.Using multilevel signaling, it .pdffathimalinks
 
This is question about excel cuers wish to answer shortly how to use.pdf
This is question about excel cuers wish to answer shortly how to use.pdfThis is question about excel cuers wish to answer shortly how to use.pdf
This is question about excel cuers wish to answer shortly how to use.pdffathimalinks
 
There is a requirement to design a system to sense the presence of gl.pdf
There is a requirement to design a system to sense the presence of gl.pdfThere is a requirement to design a system to sense the presence of gl.pdf
There is a requirement to design a system to sense the presence of gl.pdffathimalinks
 
The investments of Charger Inc. include a single investment 11,010 .pdf
The investments of Charger Inc. include a single investment 11,010 .pdfThe investments of Charger Inc. include a single investment 11,010 .pdf
The investments of Charger Inc. include a single investment 11,010 .pdffathimalinks
 
RNA polymerasebinds to DNA after the double strands have been unwoun.pdf
RNA polymerasebinds to DNA after the double strands have been unwoun.pdfRNA polymerasebinds to DNA after the double strands have been unwoun.pdf
RNA polymerasebinds to DNA after the double strands have been unwoun.pdffathimalinks
 
Research and explain the deviant actions of the Los Angeles Police D.pdf
Research and explain the deviant actions of the Los Angeles Police D.pdfResearch and explain the deviant actions of the Los Angeles Police D.pdf
Research and explain the deviant actions of the Los Angeles Police D.pdffathimalinks
 
Question 1 10 points Save A TALIA Contribute NINA Co Contribute TALIA.pdf
Question 1 10 points Save A TALIA Contribute NINA Co Contribute TALIA.pdfQuestion 1 10 points Save A TALIA Contribute NINA Co Contribute TALIA.pdf
Question 1 10 points Save A TALIA Contribute NINA Co Contribute TALIA.pdffathimalinks
 
Q1. Print all the odd numbers from 1 to a user specifiable upper lim.pdf
Q1. Print all the odd numbers from 1 to a user specifiable upper lim.pdfQ1. Print all the odd numbers from 1 to a user specifiable upper lim.pdf
Q1. Print all the odd numbers from 1 to a user specifiable upper lim.pdffathimalinks
 
Please revise the answer bellow.Q1. What historically have been Ap.pdf
Please revise the answer bellow.Q1. What historically have been Ap.pdfPlease revise the answer bellow.Q1. What historically have been Ap.pdf
Please revise the answer bellow.Q1. What historically have been Ap.pdffathimalinks
 
Negligence Curtis R. Wilhelm owned beehives and kept the hives on pr.pdf
Negligence Curtis R. Wilhelm owned beehives and kept the hives on pr.pdfNegligence Curtis R. Wilhelm owned beehives and kept the hives on pr.pdf
Negligence Curtis R. Wilhelm owned beehives and kept the hives on pr.pdffathimalinks
 
List and explain at least three popular sixteenth century dance type.pdf
List and explain at least three popular sixteenth century dance type.pdfList and explain at least three popular sixteenth century dance type.pdf
List and explain at least three popular sixteenth century dance type.pdffathimalinks
 
Introduction to Database Management SystemConsider the following .pdf
Introduction to Database Management SystemConsider the following .pdfIntroduction to Database Management SystemConsider the following .pdf
Introduction to Database Management SystemConsider the following .pdffathimalinks
 

More from fathimalinks (20)

Write the following using javaGiven a class ‘Node’ and ‘NodeList’,.pdf
Write the following using javaGiven a class ‘Node’ and ‘NodeList’,.pdfWrite the following using javaGiven a class ‘Node’ and ‘NodeList’,.pdf
Write the following using javaGiven a class ‘Node’ and ‘NodeList’,.pdf
 
Write a program in C++ that declares a structure to store the code n.pdf
Write a program in C++ that declares a structure to store the code n.pdfWrite a program in C++ that declares a structure to store the code n.pdf
Write a program in C++ that declares a structure to store the code n.pdf
 
Write a generic VBA Sub procedure to compute the value of the follow.pdf
Write a generic VBA Sub procedure to compute the value of the follow.pdfWrite a generic VBA Sub procedure to compute the value of the follow.pdf
Write a generic VBA Sub procedure to compute the value of the follow.pdf
 
Why are standards needed in data communication and networking What .pdf
Why are standards needed in data communication and networking What .pdfWhy are standards needed in data communication and networking What .pdf
Why are standards needed in data communication and networking What .pdf
 
Which of the following are mismatched A. Giordia - transmitted by f.pdf
Which of the following are mismatched  A. Giordia - transmitted by f.pdfWhich of the following are mismatched  A. Giordia - transmitted by f.pdf
Which of the following are mismatched A. Giordia - transmitted by f.pdf
 
Which of the following statements about human evolution is correct.pdf
Which of the following statements about human evolution is correct.pdfWhich of the following statements about human evolution is correct.pdf
Which of the following statements about human evolution is correct.pdf
 
What are the six major pollutions in the National Ambient Air Qualit.pdf
What are the six major pollutions in the National Ambient Air Qualit.pdfWhat are the six major pollutions in the National Ambient Air Qualit.pdf
What are the six major pollutions in the National Ambient Air Qualit.pdf
 
UPS Worldpart DiscussionWhat do you think are the operational str.pdf
UPS Worldpart DiscussionWhat do you think are the operational str.pdfUPS Worldpart DiscussionWhat do you think are the operational str.pdf
UPS Worldpart DiscussionWhat do you think are the operational str.pdf
 
True or False Justify your answer.Using multilevel signaling, it .pdf
True or False Justify your answer.Using multilevel signaling, it .pdfTrue or False Justify your answer.Using multilevel signaling, it .pdf
True or False Justify your answer.Using multilevel signaling, it .pdf
 
This is question about excel cuers wish to answer shortly how to use.pdf
This is question about excel cuers wish to answer shortly how to use.pdfThis is question about excel cuers wish to answer shortly how to use.pdf
This is question about excel cuers wish to answer shortly how to use.pdf
 
There is a requirement to design a system to sense the presence of gl.pdf
There is a requirement to design a system to sense the presence of gl.pdfThere is a requirement to design a system to sense the presence of gl.pdf
There is a requirement to design a system to sense the presence of gl.pdf
 
The investments of Charger Inc. include a single investment 11,010 .pdf
The investments of Charger Inc. include a single investment 11,010 .pdfThe investments of Charger Inc. include a single investment 11,010 .pdf
The investments of Charger Inc. include a single investment 11,010 .pdf
 
RNA polymerasebinds to DNA after the double strands have been unwoun.pdf
RNA polymerasebinds to DNA after the double strands have been unwoun.pdfRNA polymerasebinds to DNA after the double strands have been unwoun.pdf
RNA polymerasebinds to DNA after the double strands have been unwoun.pdf
 
Research and explain the deviant actions of the Los Angeles Police D.pdf
Research and explain the deviant actions of the Los Angeles Police D.pdfResearch and explain the deviant actions of the Los Angeles Police D.pdf
Research and explain the deviant actions of the Los Angeles Police D.pdf
 
Question 1 10 points Save A TALIA Contribute NINA Co Contribute TALIA.pdf
Question 1 10 points Save A TALIA Contribute NINA Co Contribute TALIA.pdfQuestion 1 10 points Save A TALIA Contribute NINA Co Contribute TALIA.pdf
Question 1 10 points Save A TALIA Contribute NINA Co Contribute TALIA.pdf
 
Q1. Print all the odd numbers from 1 to a user specifiable upper lim.pdf
Q1. Print all the odd numbers from 1 to a user specifiable upper lim.pdfQ1. Print all the odd numbers from 1 to a user specifiable upper lim.pdf
Q1. Print all the odd numbers from 1 to a user specifiable upper lim.pdf
 
Please revise the answer bellow.Q1. What historically have been Ap.pdf
Please revise the answer bellow.Q1. What historically have been Ap.pdfPlease revise the answer bellow.Q1. What historically have been Ap.pdf
Please revise the answer bellow.Q1. What historically have been Ap.pdf
 
Negligence Curtis R. Wilhelm owned beehives and kept the hives on pr.pdf
Negligence Curtis R. Wilhelm owned beehives and kept the hives on pr.pdfNegligence Curtis R. Wilhelm owned beehives and kept the hives on pr.pdf
Negligence Curtis R. Wilhelm owned beehives and kept the hives on pr.pdf
 
List and explain at least three popular sixteenth century dance type.pdf
List and explain at least three popular sixteenth century dance type.pdfList and explain at least three popular sixteenth century dance type.pdf
List and explain at least three popular sixteenth century dance type.pdf
 
Introduction to Database Management SystemConsider the following .pdf
Introduction to Database Management SystemConsider the following .pdfIntroduction to Database Management SystemConsider the following .pdf
Introduction to Database Management SystemConsider the following .pdf
 

Recently uploaded

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIShubhangi Sonawane
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 

Recently uploaded (20)

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 

CODE#include stdlib.h #include stdio.hstruct task{proce.pdf

  • 1. CODE: #include #include struct task{//process int id;//pid int bt;//burst time int at;//arrival time int pr;//priority }; typedef struct task Task; typedef Task *TaskPtr; struct qnode{//a node in the run/ready queue Task data;//process struct qnode *nextPtr; }; typedef struct qnode Qnode; typedef Qnode *QnodePtr; void enqueue(QnodePtr *headPtr, QnodePtr *tailPtr,Task task); Task dequeue(QnodePtr *headPtr, QnodePtr *tailPtr); int isEmpty(QnodePtr headPtr); void enqueue(QnodePtr *headPtr, QnodePtr *tailPtr,Task task){ QnodePtr newNodePtr = malloc( sizeof( Qnode)); if(newNodePtr !=NULL){ newNodePtr->data = task; newNodePtr->nextPtr = NULL; } QnodePtr current = *headPtr, prev = NULL; while(current!=NULL && task.bt>=(current->data).bt){ prev = current; current = current->nextPtr; } if(prev==NULL){ newNodePtr->nextPtr= *headPtr; *headPtr=newNodePtr; }
  • 2. else{ newNodePtr->nextPtr=prev->nextPtr; prev->nextPtr=newNodePtr; } if(newNodePtr->nextPtr==NULL){ *tailPtr = newNodePtr; } } Task dequeue(QnodePtr *headPtr, QnodePtr *tailPtr){ Task value; QnodePtr tempPtr; value = (*headPtr)->data; tempPtr = *headPtr; *headPtr = (*headPtr)->nextPtr; if(*headPtr == NULL){ *tailPtr = NULL; } free (tempPtr); return value; } int isEmpty(QnodePtr headPtr){ return headPtr == NULL; } /////////////////////////////////////////////// struct event{//an event event int type;//event type 0:arrival, 1: departure int time;//event time Task task;//the process }; typedef struct event Event; typedef Event *EventPtr; struct eventQnode{//an node in the events list Event data;//the event struct eventQnode *nextPtr; }; typedef struct eventQnode EventQnode;
  • 3. typedef EventQnode *EventQnodePtr; void enqueueevent(EventQnodePtr *headPtr, EventQnodePtr *tailPtr,Event e); Event dequeueevent(EventQnodePtr *headPtr, EventQnodePtr *tailPtr); int isEmptyEQ(EventQnodePtr headPtr); void displayEvents(EventQnodePtr currentPtr); void enqueueevent(EventQnodePtr *headPtr, EventQnodePtr *tailPtr,Event se){ EventQnodePtr newNodePtr = malloc( sizeof( EventQnode)); if(newNodePtr !=NULL){ newNodePtr->data = se; newNodePtr->nextPtr = NULL; } EventQnodePtr current = *headPtr, prev = NULL; while(current!=NULL && se.time>(current->data).time){//find the insert position in order of time prev = current; current = current->nextPtr; } while(current!=NULL && se.time==(current->data).time && se.type<(current- >data).type){//then find the insert position in order of event's type prev = current; current = current->nextPtr; } if(prev==NULL){ newNodePtr->nextPtr= *headPtr; *headPtr=newNodePtr; } else{ newNodePtr->nextPtr=prev->nextPtr; prev->nextPtr=newNodePtr; } if(newNodePtr->nextPtr==NULL){ *tailPtr = newNodePtr; } } Event dequeueevent(EventQnodePtr *headPtr, EventQnodePtr *tailPtr){
  • 4. Event value; EventQnodePtr tempPtr; value = (*headPtr)->data; tempPtr = *headPtr; *headPtr = (*headPtr)->nextPtr; if(*headPtr == NULL){ *tailPtr = NULL; } free (tempPtr); return value; } int isEmptyEQ(EventQnodePtr headPtr){ return headPtr == NULL; } void displayEvents(EventQnodePtr currentPtr){ if(currentPtr==NULL) printf("The event list is empty ... "); else{ printf("The event list is: "); Event tempevent; while(currentPtr!=NULL){ printf(" time: %d, type : %d : task(id:%d,bt:%d) ", (currentPtr->data).time, (currentPtr->data).type, (currentPtr->data).task.at,(currentPtr- >data).task.bt); currentPtr=currentPtr->nextPtr; } } } /////////////////////////////////////////////// const int MAXTASKS = 10; const int MAXBURSTTIME = 70; const int IAT = 30; void main(){ QnodePtr rqheadPtr=NULL, rqtailPtr=NULL;//the run/ready queue EventQnodePtr eventsQheadPtr=NULL, eventsQtailPtr=NULL;//the event queue/list
  • 5. Task task;//the process structure Event event;//the event structure int prevat = 0, i;//set the previous arrival time to zero for(i=0;i Solution #include #include #include class cpuschedule { int n,bu[20]; float twt,awt,wt[20],tat[20]; public: void Getdata(); void fcfs(); void sjf(); void roundrobin(); }; //Getting no of processes and Burst time void cpuschedule::Getdata() { int i; cout<<“Enter the no of processes:”; cin>>n; for(i=1;i<=n;i++) { cout<<“ Enter The BurstTime for Process p”<>bu[i]; } } //First come First served Algorithm void cpuschedule::fcfs() { int i,b[10]; float sum=0.0;
  • 6. twt=0.0; for(i=1;i<=n;i++) { b[i]=bu[i]; cout<<“ Burst time for process p”<=1;i–) { for(j=2;j<=n;j++) { if(b[j-1]>b[j]) { temp=b[j-1]; b[j-1]=b[j]; b[j]=temp; } } } wt[1]=0; for(i=2;i<=n;i++) { wt[i]=b[i-1]+wt[i-1]; } for(i=1;i<=n;i++) { twt=twt+wt[i]; tat[i]=b[i]+wt[i]; sum+=tat[i]; } awt=twt/n; sum=sum/n; cout<<“ Total Waiting Time=”<>tq; //TO find the dimension of the Round robin array m=max/tq+1; //initializing Round robin array for(i=1;i<=n;i++) { for(j=1;j<=m;j++)
  • 7. { Rrobin[i][j]=0; } } //placing value in the Rrobin array i=1; while(i<=n) { j=1; while(b[i]>0) { if(b[i]>=tq) { b[i]=b[i]-tq; Rrobin[i][j]=tq; j++; } else { Rrobin[i][j]=b[i]; b[i]=0; j++; } } count[i]=j-1; i++; } cout<<“Display”; for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { cout<<“ Rr[“<>ch; getch(); }while(ch<5); }