Solved

first come first serve in java

Posted on 2010-08-17
5
1,188 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
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
use lov values 2 71
runtime exception 2 50
ejb entity bean example 2 31
Java array 21 78
Okay. So what exactly is the problem here? How often have we come across situations where we need to know if two strings are 'similar' but not necessarily the same? I have, plenty of times. Until recently, I thought any functionality like that wo…
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 will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This video teaches viewers about errors in exception handling.

713 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