Solved

first come first serve in java

Posted on 2010-08-17
5
1,193 Views
Last Modified: 2013-11-23
Can any1 provide a sample code of implementing first come first serve in java?

Lets assume that a tick is the minimum amount of time that CPU spends on one job before switching. The probabily of a job arriving between any two ticks is 0.2, the amount of work a job requires is randomly selected between 1 and 15 ticks. Finally keep generating jobs until a total of 100 jobs have arrived per run.

thnx
0
Comment
Question by:harryrei
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 10

Accepted Solution

by:
Hegemon earned 168 total points
ID: 33458321
You can use one of the classes implementing the Queue interface.http://cupi2.uniandes.edu.co/site/images/recursos/javadoc/j2se/1.5.0/docs/api/java/util/Queue.html
0
 
LVL 32

Assisted Solution

by:phoffric
phoffric earned 166 total points
ID: 33499523
"THIS IS A PROGRAM ON FIRST COME FIRST SERVED PROCESS SCHEDULING ALGORITHAM OF TYPE NONPREEMPTIVE SCHEDULING ALGORITHAM.THIS ALGORITHAM HELPS YOU TO ANALYSE THE FCFS CLEARLY AND AND ALSO CALCULATES SOME PARAMETERS WHICH ARE GOING TO BE MENTIONED."
   http://www.sourcecodesworld.com/source/show.asp?ScriptID=928

There are some good lectures on scheduling including FCFS here:

http://www.academicearth.org/courses/operating-systems-and-system-programming

Lecture 10: (latter 2/3 begins scheduling)
   http://www.academicearth.org/lectures/deadlock-continued--thread-scheduling

Lecture 11: continuation
http://www.academicearth.org/lectures/scheduling-continued--protection-kernel-and-address-spaces

Handouts for the these lectures:
http://www-inst.cs.berkeley.edu/~cs162/fa09/Lectures/lec10-scheduling.pdf
http://www-inst.cs.berkeley.edu/~cs162/fa09/Lectures/lec11-protection.pdf
0
 
LVL 2

Assisted Solution

by:matstein
matstein earned 166 total points
ID: 35967234
The above posters have already addressed the Queue issue if you need a hint with the job generation part of your question you can have something that looks like this


   
int ticks = 0;
int job_ticks;
for (i=0;i<100;i++)
 while(Random.nextInt(4))
 {
  ticks++; //20% chance of generating a job in this tick.
  }
  ticks++;
  job_ticks = (Random.nextInt(14)+1);
  Queue.add(job_ticks);
}
System.out.println("100 jobs where generated in "+ticks" ticks);

Open in new window


0
 
LVL 100

Expert Comment

by:mlmcc
ID: 36235309
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question