Subversion Repositories programming

Rev

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

Rev Author Line No. Line
412 ira 1
/*******************************************************************************
415 ira 2
 * Process.java
412 ira 3
 *
4
 * Holds the Process class, which holds information about a process.
5
 *
6
 * Copyright (c) 2006, Ira W. Snyder (devel@irasnyder.com)
7
 *
8
 * Permission is hereby granted, free of charge, to any person obtaining a copy
9
 * of this software and associated documentation files (the "Software"), to deal
10
 * in the Software without restriction, including without limitation the rights
11
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
 * copies of the Software, and to permit persons to whom the Software is
13
 * furnished to do so, subject to the following conditions:
14
 *
15
 * The above copyright notice and this permission notice shall be included in
16
 * all copies or substantial portions of the Software.
17
 *
18
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
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
24
 * IN THE SOFTWARE.
25
 ******************************************************************************/
26
 
415 ira 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
 */
33
public class Process
412 ira 34
{
415 ira 35
    /** The Process' name */
412 ira 36
    public final String name;
415 ira 37
 
38
    /** The Process' burst time */
412 ira 39
    public final int timeslice;
415 ira 40
 
41
    /** The time when this process started running */
413 ira 42
    public int started_at = 0;
415 ira 43
 
44
    /** The time when this process completed */
413 ira 45
    public int finished_at = 0;
415 ira 46
 
47
    /** The amount of time this Process has left */
413 ira 48
    public int time_left;
412 ira 49
 
416 ira 50
    /** The amount of time this process spent waiting to execute */
51
    public int time_wait = 0;
52
 
415 ira 53
    /**
54
     * Constructor for the Process class.
55
     *
56
     * @param name this Process' name
57
     * @param timeslice the burst time for this process
58
     */
412 ira 59
    public Process (String name, int timeslice)
60
    {
61
        this.name = name;
62
        this.timeslice = timeslice;
413 ira 63
        this.time_left = timeslice;
412 ira 64
    }
65
 
415 ira 66
    /**
67
     * Copy constructor for the Process class.
68
     *
69
     * @param p the Process to be copied
70
     */
413 ira 71
    public Process (Process p)
72
    {
73
        this.name = new String (p.name);
74
        this.timeslice = p.timeslice;
75
        this.time_left = p.timeslice;
76
    }
77
 
415 ira 78
    /**
79
     * Convert this Process to a String for printing.
80
     *
81
     * @return the String representation of this Process
82
     */
412 ira 83
    public String toString ()
84
    {
85
        return name.toString() + " " + timeslice;
86
    }
413 ira 87
 
415 ira 88
    /**
89
     * Check if this Process is equal to another Process.
90
     *
91
     * @param rhs the Process to compare this Process to
92
     * @return true if these Processes are equal, false otherwise
93
     */
413 ira 94
    public boolean equals (Process rhs)
95
    {
96
        return (this.name == rhs.name) && (this.timeslice == rhs.timeslice);
97
    }
412 ira 98
}
99
 
100
/* vim: set ts=4 sts=4 sw=4 expandtab: */
101