Solved

first come first serve in java

Posted on 2010-08-17
5
1,172 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
Comment Utility
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
Comment Utility
"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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
XML Paring  Error - Premature end of file. 7 55
Math Question 1 51
mockito example issue 8 30
eclipse java  build path 6 18
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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

744 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now