UrbanPro

Learn C Language from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

How do I write a simple code in C for SJF scheduling non preemptive?

Asked by Last Modified  

Follow 3
Answer

Please enter your answer

Advance Excel And VBA Training

A simple priority queue will do the job. You can define each node in the queue to hold the task as well as the priority level. Enqueueing will be no different that regular queues and will happen at the rear. Dequeueing however, will not always take place at the front but will rather happen to the...
read more
A simple priority queue will do the job. You can define each node in the queue to hold the task as well as the priority level. Enqueueing will be no different that regular queues and will happen at the rear. Dequeueing however, will not always take place at the front but will rather happen to the node with least priority level in the queue, regardless of location. Have a look at priority queues, learn what they are and have fun implementing them. I assure you, it’s easy to do and you learn a lot! Round Robin Scheduling Each process is provided a fix time to execute called quantum. Once a process is executed for given time period. Process is preempted and other process executes for given time period. Context switching is used to save states of preempted processes. See below attached image1 for your reference. CODE: #include "stdio.h" main() { int n; printf("Enter the no. of processes: "); scanf("%d",&n); int id[n],bt[n],rt[n],wt[n],tat[n],st[n],ft[n],q,i,time=0,btsum=0; for(i=0;iq) { time+=q; bt[i]-=q; wt[i]=wt[i]+st[i]-ft[i]; ft[i]=time; } else if(bt[i]<=q && bt[i]!=0) { time+=bt[i]; wt[i]=wt[i]+st[i]-ft[i]; bt[i]=0; } } for(i=0;iread less
Comments

Computer Wizard

#include stdio.h #include stdlib.h void sort(int,int); int main() { int bt,wt,n,i,sum,x,avg; float p; sum=0; printf("\nenter the number of processes:"); scanf("%d",&n); for(i=0;ibt) { temp=bt; bt=bt; bt=temp; } } } }
read more
#include stdio.h #include stdlib.h void sort(int[],int); int main() { int bt[10],wt[10],n,i,sum,x,avg; float p[5]; sum=0; printf("\nenter the number of processes:"); scanf("%d",&n); for(i=0;ibt[j+1]) { temp=bt[j]; bt[j]=bt[j+1]; bt[j+1]=temp; } } } } read less
Comments

Trainer

declare array and read jobs time in that. search the array for smallest cpu burst time and find the index and add
Comments

View 1 more Answers

Related Questions

What is a pragma?
In computer programming, a directive pragma is a language construct that specifies how a compiler should process its input. The ' #pragma ' directive is the method specified by the C standard for providing...
Anil
what are type qualifiers in c language
The type qualifiers/modifiers in C language are used to alter the meaning of basic data types. These can be divided into 3 categories: 1. Size modifiers a. short (default) b. long 2. Sign modifiers a....
Mahesh
How and where do I start learning C programming?
C language is the basic of the programming to learn the basic of programming we learn the c language
Gaurav
0 0
7
What is the fee for learning C Language?
In C lang course ,there is not only basics it also having whole package to complete the task and course.cost may be it's depends upon the institute n teaching level
Sk.
How to improve my c knowledge........
First learn the basic concepts of C .There is a book named Let Us C. It is a very good book with all the basics and concepts of C.I also have this book .I take classes of teaching basics of C,C++,java. Learn...
Anish

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Structures in C
A structure is a collection of one or more data members possibly of different data types, grouped together under a single name for convenient handling. Defining a Structure: In general terms,...

C PROGRAM FOR GENERATING SOUND
#include<stdio.h> #include<conio.h> #include<dos.h> void main() { sound(3000); // sound function have single parameter , this parameter we put integer value its generating...

V. Muthu Ganeshan

0 0
0

C Program-Upper Case Demo
/*WAP to print the character entered by user in upper case*/ //Header files #include<stdio.h>#include<conio.h> //Main function void main(){ char ch; //Function for clearing screen clrscr(); ...

Design your own Mouse Driver in C Language
Mouse Driver (msdrv.h) #include #include union REGS i,o; restrictmouseptr(int x1, int y1, int x2, int y2) { i.x.ax=7; i.x.cx=x1; i.x.dx=x2; ...

What is a Programming Language
What is a Language? Language is a communication system of human. What is a programming Language? A programming Language is a formal constructed language design to communicate...

Recommended Articles

Brilliant Academy is one of the reputed institutes for B.Tech tuition classes. This institute is specialised in delivering quality tuition classes for B.E, Engineering - all streams and Engineering diploma courses. Incorporated in 2012, Brillant Academy is a brainchild of Mr Jagadeesh. The main motto of the academy is to...

Read full article >

Lasya Infotech is a Hyderabad based IT training institute founded in 2016 by O Venkat. Believing in his innovation, passion and persistence and with a diverse blend of experience, he started his brainchild to deliver exemplary professional courses to aspiring candidates by honing their skills. Ever since the institute envisions...

Read full article >

Applications engineering is a hot trend in the current IT market.  An applications engineer is responsible for designing and application of technology products relating to various aspects of computing. To accomplish this, he/she has to work collaboratively with the company’s manufacturing, marketing, sales, and customer...

Read full article >

Microsoft Excel is an electronic spreadsheet tool which is commonly used for financial and statistical data processing. It has been developed by Microsoft and forms a major component of the widely used Microsoft Office. From individual users to the top IT companies, Excel is used worldwide. Excel is one of the most important...

Read full article >

Looking for C Language Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for C Language Classes?

The best tutors for C Language Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn C Language with the Best Tutors

The best Tutors for C Language Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more