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  

3 Answers

Learn C Language

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

Can a file other than a .h file be included with #include?
Yes. user defined header file ex:#include "nim.c"
Pankaj
0 0
7
Is it valid to address one element beyond the end of an array?
No, array is a fixed size memory allocation for variables. It is illegal to access elements beyond the allocated space.
Shivani
When is a "switch" statement better than multiple "if" statements?
switch statement is generally best to use when you have more than two conditional expressions based on a single variable of numeric type. For instance, rather than the code if (x == 1) printf(“x...
Shalu
Why are C and C++ faster than other programming languages?
C is basic programming language. It is very simple language & interested. C is procedural programming language
Kalyani
0 0
8
How can you be sure that a program follows the ANSI C standard?
The ANSI C standard provides a predefined symbol named __STDC__ that is set to 1 when the compiler is enforcing strict ANSI standard conformance. If you want your programs to be 100 percent ANSI conformant,...
Vibha

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

Ask a Question

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