Solved

first come first serve in java

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

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 50
Error in @AspectJ Based AOP with Spring 2 14
Unhandled exception type Exception 18 31
Java string replace 11 49
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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This video teaches viewers about errors in exception handling.

832 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