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

If one leaves a lot of space in a C language code, will it require more space in a hard disk and RAM?
Head files tells system, how to deal with different functions with program such as printf(), scanf() , getche() etc. so you must have reference to it.
Abhishek
0 0
5

What is C language?

It is a general purpose high level language used to make software for operating systems (kernel programms), game development, Embedded devices etc. It avoids the complexity of writing machine code and...
Shiva
any one can teach me c++
Yes of course i can give you online classes
Bhuvanesh
What is a macro, and how do you use it?
A macro is a fragment of code which has been given a name. Whenever the name is used, it is replaced by the contents of the macro. There are two kinds of macros. They differ mostly in what they look...
Sandeep
What is a calling function in C?
A calling function is a way to execute a block of code that's defined elsewhere in your program. It's like asking a specialized worker to perform a specific task within your main project. It promotes code organization, reusability, and modularity.
Deepika
0 0
6

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

Ask a Question

Related Lessons

C Program-Temperature [conversion from farenheit to degree celsius]
//WAP to convert temperture from farenheit into degree celsius //Header files#include<stdio.h>#include<conio.h> //Main functrion void main(){ //Variable declaration of type float float...

Compiler vs Interpreter
Compiler Interpreter Convert all the code into binary format and execute. Convert one statement at a time and execute, then Convert next statement and execute. After conversion, source...

Tips of learning Java Language/Other Programming Languages
1.You should know the basic concept: If we talk about programming languages so basic concept are same in all the high level languages. So you should know the basic concept firstly then you can easily understand...
I

ICreative Solution

0 0
0

10 Tips to improve your learning
1. Have a quick revision of topics that you have read in past three days before you start studying a new topic. 2. Make your own notes containing the summary of the topic. 3. Allot proper timing for...

Operators in C
Operators in C Operator: An operator is a symbol that tells the compiler to perform certain mathematical or logical calculations. Operators are used in programs to manipulate data and variables. The...

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