Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2010
    Posts
    4
    Rep Power
    0

    Question Scheduling problem with FCFS/FIFO

    I'm a java novice, and trying a few things out.

    I've been trying to write a basic scheduling program and so far I'm happy with what I've done. But I've hit a wall it seems! I started off with First In First Out, and want to modify it to Round Robin...

    I've looked several places but everythings over complicated and I'd just like a basic example of each to compare them :)

  2. #2
    paul pasciak is offline Senior Member
    Join Date
    Jul 2008
    Posts
    125
    Rep Power
    0

    Default FIFO vs. Circular List

    Here is a very basic (single link) circular linked list
    followed by a basic (single link) fifo.
    I stripped out all functions because they obscurred
    the basic difference in the two data structures and
    complicated any explaination of their differences.

    The difference can be seen on line 5 of each example.
    The end of the circular list links back to its beginning.
    The end of the FIFO ends with null.

    Java Code:
     1  class CircleList{
     2
     3    CircleNode circularList;
     4    circularList = new CircleNode();
     5    circularList.next = circularList;
     6
     7    class CircleNode{
     8      int data;
     9      CircleNode next;
    10    }
    11  }
    
    
    
     1  class FIFOList{
     2
     3    FIFONode fifo;
     4    fifo = new FIFONode();
     5    fifo.next = null;
     6
     7    class FIFONode{
     8      int data;
     9      FIFONode next;
    10    }
    11  }
    Last edited by paul pasciak; 04-24-2010 at 05:47 PM. Reason: minor error in FIFO code

  3. #3
    Join Date
    Apr 2010
    Posts
    4
    Rep Power
    0

    Default

    Thanks you for your reply :)

    That suprisingly helped alot! So I'm guessing the next step would be to add some sort of time slicing into the circular list? So that each item had a specified amount of time before the next ones turn?

  4. #4
    paul pasciak is offline Senior Member
    Join Date
    Jul 2008
    Posts
    125
    Rep Power
    0

    Default Time allocation

    Time allocation to service individual data nodes
    in any data structure is not a fundamental
    issue. Modern computers run at exceptional
    speeds, which has made this fundamental more
    fact than application theory.

    You may have a specific need, like animation
    for this 'time slicing' you refer to. Without
    understanding your specific need, I can't help.

  5. #5
    Join Date
    Apr 2010
    Posts
    4
    Rep Power
    0

    Default

    Oh I didn't realise, so what happens if you don't allocate a time for it to spend on a task?

    if (!this.queue.contains(job))

    My trail of thought was to add to the above, and tell it to spend a certain time on a job before putting it to the back of the arraylist and then running the next for that time before putting it at the back of the arraylist...etc

    if not, what would you suggest? :)

  6. #6
    paul pasciak is offline Senior Member
    Join Date
    Jul 2008
    Posts
    125
    Rep Power
    0

    Default

    Time allocation is not an issue. The computer will
    take all the time it needs to process a node, then
    move on to the next, and the next, and the next..

    Unless you site a specific time issue, there are none.
    Computers can perform at least 1 Billion additions a
    second. There is no time issue.

    You may have something else in mind. You might
    be wondering how you move from one node to the
    next. You mention moving a job to the 'back' of
    an arraylist. There is no back in a circular list. You
    pass over data elements, and eventually you end
    up back where you started, to do it all over again.

    You also use arraylist in context. I'm not certain
    what your vision of this project is when you use
    this term. 'arrayList' is a much more complex topic
    specific to java. You will usually be advised to read
    the API on "Collections" to find your answer.
    Whereas, "Linked List" and "Circular List" are general
    terms understood and studied in Computer Science
    in general.

    If you are just beginning, I can clarify the operation
    of the general theory on this topic, but in order to
    help you with "arrayList" I would have to review
    the API on that topic.

    It has also occurred to me that I do not understand
    the term "basic scheduling program". It may be that
    there is a timing factor involved in such a project.
    If this is the case, I might be of further help if you
    gave a clear description of how timing or time are
    integral to this project.
    Last edited by paul pasciak; 04-24-2010 at 08:01 PM. Reason: Add a more complete closure to my reply

  7. #7
    Join Date
    Apr 2010
    Posts
    4
    Rep Power
    0

    Default

    Ahhh yes :) I didn't realise that I didn't have to specify times etc...

    this.lastJobReturned = (Job)this.queue.get(count);
    if (count=numberOfJobs) {
    count=0;
    }
    else {
    count++;
    }

    Here's a part of the code I'm implementing, it doesn't like the "count=numberOfJobs" part...I don't know why, it might be something simple that I'm simply overlooking. (where count and numberOfJobs are both ints)

    I'm going to look at another scheduling algorithm too, which would you say is the easiest to implement? :) (excluding FIFO and Round Robin that is?)

  8. #8
    paul pasciak is offline Senior Member
    Join Date
    Jul 2008
    Posts
    125
    Rep Power
    0

    Default basic equality symbol error

    Sorry if this is late.
    I had to leave the internet for a while to live a
    normal life.

    In the back of my mind, some notions about 'schedulers'
    are to the front, but I'm not going to study this subject.
    I think you are referring to an application that does not
    require critical timing of any sort. It might require a
    "time" as an index, or a simple count.

    If you find examples that specify a specific data structure
    and algorithm, go with that. Usually, although a structure
    may not be the quickest to sort, it is specified for an
    application because it is the easiest to manage, and
    possiblly the most efficient for that project.

    Otherwise:
    Java Code:
    // Change this code fragment..
    
      this.lastJobReturned = (Job)this.queue.get(count);
        if(count=numberOfJobs){
          count=0;
        }
        else{ 
          count++;
        }
    
    
    // to this.
    
    
      this.lastJobReturned = (Job)this.queue.get(count);
        if(count==numberOfJobs){
          count=0;
        }
        else{ 
          count++;
        }
    
    // use '==' instead of '=' to make comparisons

Similar Threads

  1. FIFO sorting
    By fanle in forum New To Java
    Replies: 3
    Last Post: 07-24-2009, 06:35 AM
  2. FIFO communication over a unreliable UDP
    By r_rama in forum Networking
    Replies: 1
    Last Post: 12-21-2008, 09:04 AM
  3. Quartz scheduling in EJB3
    By Niveditha in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 06-30-2008, 08:34 AM
  4. Scheduling tasks using Threads
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-11-2007, 10:24 AM
  5. Scheduling a task
    By bugger in forum Advanced Java
    Replies: 3
    Last Post: 12-04-2007, 12:32 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •