Subversion Repositories programming

Rev

Rev 415 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
412 ira 1
/*******************************************************************************
415 ira 2
 * Project1.java
412 ira 3
 *
4
 * Holds the Project1 class, which has the main implementation of CS431
5
 * Project #1.
6
 *
7
 * Copyright (c) 2006, Ira W. Snyder (devel@irasnyder.com)
8
 *
9
 * Permission is hereby granted, free of charge, to any person obtaining a copy
10
 * of this software and associated documentation files (the "Software"), to deal
11
 * in the Software without restriction, including without limitation the rights
12
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
 * copies of the Software, and to permit persons to whom the Software is
14
 * furnished to do so, subject to the following conditions:
15
 *
16
 * The above copyright notice and this permission notice shall be included in
17
 * all copies or substantial portions of the Software.
18
 *
19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25
 * IN THE SOFTWARE.
26
 ******************************************************************************/
27
 
415 ira 28
/**
29
 * The main class that holds the user interface for CS431 Project #1.
30
 *
31
 * @class CS431 Fall 2006
32
 * @author Ira W. Snyder (devel@irasnyder.com)
33
 */
34
public class Project1
412 ira 35
{
415 ira 36
    /**
37
     * The main() function for CS431 Project #1.
38
     *
39
     * @param argv the arguments given on the command line
40
     */
412 ira 41
    public static void main (String[] argv)
42
    {
43
        String s;
44
        ConfigParser cp;
45
 
46
        /* Check if we have a file to read */
47
        if (argv.length > 0)
48
        {
49
            System.out.printf ("Using %s as the input file\n", argv[0]);
50
            cp = new ConfigParser (argv[0]);
51
        }
52
        else
53
        {
54
            System.out.printf ("Using the keyboard as the input file\n");
55
            cp = new ConfigParser ();
56
        }
57
 
420 ira 58
        /* Diagnostics */
59
        System.out.println ("Diagnostics");
412 ira 60
        System.out.println ("RRInterval=" + cp.getRRInterval ());
61
        System.out.println ("Processes =" + cp.getProcesses  ());
62
 
63
        /* First Come First Served Scheduler */
413 ira 64
        System.out.println ("\n\nFirst Come First Served");
412 ira 65
        FCFSScheduler fcfs = new FCFSScheduler ();
66
 
67
        for (Process p : cp.getProcesses ())
413 ira 68
            fcfs.addProcess (p, 0);
412 ira 69
 
70
        fcfs.run ();
71
 
72
        /* Shortest-Job First Scheduler */
413 ira 73
        System.out.println ("\n\nShortest Job First");
74
        SJFScheduler sjf = new SJFScheduler ();
75
        int count = 0;
412 ira 76
 
413 ira 77
        for (Process p : cp.getProcesses ())
78
            sjf.addProcess (p, count++);
79
 
80
        sjf.run ();
81
 
82
        /* Round-Robin Scheduler */
83
        System.out.println ("\n\nRound Robin");
84
        RRScheduler rr = new RRScheduler (cp.getRRInterval ());
85
 
86
        for (Process p : cp.getProcesses ())
87
            rr.addProcess (p, 0);
88
 
89
        rr.run ();
412 ira 90
    }
91
}
92
 
93
/* vim: set ts=4 sts=4 sw=4 expandtab: */
94