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 meant by "bit masking"?
Mask means to block in bit masking, blocking can be done by bit by bit e.g. 0101 1000 OR -------------- 1101
Kiran
0 0
6
What are the toughest topics in C language?
1. pointer 2. dynamic memory allocation 3. File handling
Lokayya
0 0
5
How can I learn C easily and rapidly?
You can learn C by three ways 1. Practise 10 programs daily for 10 days. 2. Understand the programming concept before going to make an attempt 3. Try to do some simple projects on your own will improve your skills rapidly.
Umamahesh
0 0
5
Which is older - Java or C?
C is older than JAVA
Baby
Which is the best software for working with C language?
Choosing the best software for C programming often depends on personal preference, but popular options include GCC (GNU Compiler Collection), Visual Studio, and CLion. Consider factors like your platform,...
Kiran
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

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...

C Program-Vowels and Consonants
/*WAP to print the character entered by user is a vowel or consonant*/ //Header files #include<stdio.h>#include<conio.h> //Main functionvoid main(){ char c; //Function for clearing screen...

Can we store different data types in a stack?
Yesterday, one of my Facebook friend asked me this question. My answer is "yes", and in this post I will discuss how could we do this.I am a great supporter of working with unions and I will be using union...

Working with C/C++ applications
Inorder to learn C and C++ programming languages one can work with various editors available.To name a few are the most popular one is turbo c++, DEV C++, Eclipse, NetBeans. Here are the screen shots...

INTRODUCTION TO PROGRAMMING LANGUAGES
Language is a medium for communication. If we want to perform anything with another person, we can know the human language as a human being. Similarly, if we want to perform anything with a computer, we...

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