Subversion Repositories programming

Rev

Rev 413 | Rev 416 | 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
 
415 ira 50
    /**
51
     * Constructor for the Process class.
52
     *
53
     * @param name this Process' name
54
     * @param timeslice the burst time for this process
55
     */
412 ira 56
    public Process (String name, int timeslice)
57
    {
58
        this.name = name;
59
        this.timeslice = timeslice;
413 ira 60
        this.time_left = timeslice;
412 ira 61
    }
62
 
415 ira 63
    /**
64
     * Copy constructor for the Process class.
65
     *
66
     * @param p the Process to be copied
67
     */
413 ira 68
    public Process (Process p)
69
    {
70
        this.name = new String (p.name);
71
        this.timeslice = p.timeslice;
72
        this.time_left = p.timeslice;
73
    }
74
 
415 ira 75
    /**
76
     * Convert this Process to a String for printing.
77
     *
78
     * @return the String representation of this Process
79
     */
412 ira 80
    public String toString ()
81
    {
82
        return name.toString() + " " + timeslice;
83
    }
413 ira 84
 
415 ira 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
     */
413 ira 91
    public boolean equals (Process rhs)
92
    {
93
        return (this.name == rhs.name) && (this.timeslice == rhs.timeslice);
94
    }
412 ira 95
}
96
 
97
/* vim: set ts=4 sts=4 sw=4 expandtab: */
98