Subversion Repositories programming

Rev

Rev 413 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

/*******************************************************************************
 * Project1.java
 *
 * Holds the Project1 class, which has the main implementation of CS431
 * Project #1.
 *
 * Copyright (c) 2006, Ira W. Snyder (devel@irasnyder.com)
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 ******************************************************************************/

/**
 * The main class that holds the user interface for CS431 Project #1.
 *
 * @class CS431 Fall 2006
 * @author Ira W. Snyder (devel@irasnyder.com)
 */
public class Project1
{
    /**
     * The main() function for CS431 Project #1.
     *
     * @param argv the arguments given on the command line
     */
    public static void main (String[] argv)
    {
        String s;
        ConfigParser cp;

        /* Check if we have a file to read */
        if (argv.length > 0)
        {
            System.out.printf ("Using %s as the input file\n", argv[0]);
            cp = new ConfigParser (argv[0]);
        }
        else
        {
            System.out.printf ("Using the keyboard as the input file\n");
            cp = new ConfigParser ();
        }

        System.out.println ("RRInterval=" + cp.getRRInterval ());
        System.out.println ("Processes =" + cp.getProcesses  ());
        System.out.println ("DONE DIAGNOSTICS!");

        /* First Come First Served Scheduler */
        System.out.println ("\n\nFirst Come First Served");
        FCFSScheduler fcfs = new FCFSScheduler ();

        for (Process p : cp.getProcesses ())
            fcfs.addProcess (p, 0);

        fcfs.run ();

        /* Shortest-Job First Scheduler */
        System.out.println ("\n\nShortest Job First");
        SJFScheduler sjf = new SJFScheduler ();
        int count = 0;

        for (Process p : cp.getProcesses ())
            sjf.addProcess (p, count++);

        sjf.run ();

        /* Round-Robin Scheduler */
        System.out.println ("\n\nRound Robin");
        RRScheduler rr = new RRScheduler (cp.getRRInterval ());

        for (Process p : cp.getProcesses ())
            rr.addProcess (p, 0);

        rr.run ();
    }
}

/* vim: set ts=4 sts=4 sw=4 expandtab: */