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 an lvalue?
L-Value stands for left value L-Value of Expressions refer to a memory locations In any assignment statement L-Value of Expression must be a container(i.e. must have ability to hold the data) Variable...
Nagasanthoshi
What is the importance of pointers? People stress more on them. Why they are useful actually what is their importance?
Importance of pointers:- Pointers are used in situations when passing actual values is difficult or not desired. To return more than one value from a function. They increase the execution speed. The...
Pati
Why is C still so popular?
While other languages have come and gone, C has remained a popular choice for many developers. One reason for C's continued popularity is its versatility, and it can be used for a wide range of tasks,...
Chitra
0 0
5
How do I trace C programs in Turbo C?
First of all goto C drive then program files then turbo c folder then open bin folder and search what program u want
Orange
0 0
6
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.

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-Error Handling[Program Exit Status]
//Header files #include<stdio.h>#include<conio.h>#include<stdlib.h> //Main Function void main(){ int dividend=20; int divisor=5; int quotient; //Function for clearing screen clrscr();...
S

Basic Concepts of Web Designing
An introduction to domain names, web servers, and website hosting 1)What is the web? In a nutshell, the web is a whole bunch of interconnected computers talking to one another. The computers (on the...

Recursion in C Programming
The process of calling a function by itself is called recursion and the function which calls itself is called recursive function. Syntax of Recursive Function returntype recursive_func () { statements; ...
R

Ravindra Yadav

2 0
0

Features Of C Language
Features of C language It is a robust language with rich set of built-in functions and operators that can be used to write any complex program. The C compiler combines the capabilities of an assembly...

C Program-String Comparison
// WAP to compare strings entered by the user //Header files #include<stdio.h>#include<conio.h>#include<string.h> //Main function void main(){ char str1; char str2; int comp; //Function...
S

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