Subversion Repositories programming

Rev

Rev 413 | Rev 416 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 413 Rev 415
Line 1... Line 1...
1
/*******************************************************************************
1
/*******************************************************************************
2
 * File: Process.java
2
 * Process.java
3
 *
3
 *
4
 * Holds the Process class, which holds information about a process.
4
 * Holds the Process class, which holds information about a process.
5
 *
5
 *
6
 * Copyright (c) 2006, Ira W. Snyder (devel@irasnyder.com)
6
 * Copyright (c) 2006, Ira W. Snyder (devel@irasnyder.com)
7
 *
7
 *
Line 22... Line 22...
22
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24
 * IN THE SOFTWARE.
24
 * IN THE SOFTWARE.
25
 ******************************************************************************/
25
 ******************************************************************************/
26
 
26
 
-
 
27
/**
-
 
28
 * The Process class. This holds information about a simulated process.
-
 
29
 *
-
 
30
 * @class CS431 Fall 2006
-
 
31
 * @author Ira W. Snyder (devel@irasnyder.com)
-
 
32
 */
27
class Process
33
public class Process
28
{
34
{
-
 
35
    /** The Process' name */
29
    public final String name;
36
    public final String name;
-
 
37
 
-
 
38
    /** The Process' burst time */
30
    public final int timeslice;
39
    public final int timeslice;
-
 
40
 
-
 
41
    /** The time when this process started running */
31
    public int started_at = 0;
42
    public int started_at = 0;
-
 
43
 
-
 
44
    /** The time when this process completed */
32
    public int finished_at = 0;
45
    public int finished_at = 0;
-
 
46
 
33
    public int waited = 0;
47
    /** The amount of time this Process has left */
34
    public int time_left;
48
    public int time_left;
35
 
49
 
-
 
50
    /**
-
 
51
     * Constructor for the Process class.
-
 
52
     *
-
 
53
     * @param name this Process' name
-
 
54
     * @param timeslice the burst time for this process
-
 
55
     */
36
    public Process (String name, int timeslice)
56
    public Process (String name, int timeslice)
37
    {
57
    {
38
        this.name = name;
58
        this.name = name;
39
        this.timeslice = timeslice;
59
        this.timeslice = timeslice;
40
        this.time_left = timeslice;
60
        this.time_left = timeslice;
41
    }
61
    }
42
 
62
 
-
 
63
    /**
-
 
64
     * Copy constructor for the Process class.
-
 
65
     *
-
 
66
     * @param p the Process to be copied
-
 
67
     */
43
    public Process (Process p)
68
    public Process (Process p)
44
    {
69
    {
45
        this.name = new String (p.name);
70
        this.name = new String (p.name);
46
        this.timeslice = p.timeslice;
71
        this.timeslice = p.timeslice;
47
        this.time_left = p.timeslice;
72
        this.time_left = p.timeslice;
48
    }
73
    }
49
 
74
 
-
 
75
    /**
-
 
76
     * Convert this Process to a String for printing.
-
 
77
     *
-
 
78
     * @return the String representation of this Process
-
 
79
     */
50
    public String toString ()
80
    public String toString ()
51
    {
81
    {
52
        return name.toString() + " " + timeslice;
82
        return name.toString() + " " + timeslice;
53
    }
83
    }
54
 
84
 
-
 
85
    /**
-
 
86
     * Check if this Process is equal to another Process.
-
 
87
     *
-
 
88
     * @param rhs the Process to compare this Process to
-
 
89
     * @return true if these Processes are equal, false otherwise
-
 
90
     */
55
    public boolean equals (Process rhs)
91
    public boolean equals (Process rhs)
56
    {
92
    {
57
        return (this.name == rhs.name) && (this.timeslice == rhs.timeslice);
93
        return (this.name == rhs.name) && (this.timeslice == rhs.timeslice);
58
    }
94
    }
59
}
95
}