Subversion Repositories programming

Rev

Rev 413 | 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
 * LogEntry.java
2
 * LogEntry.java
3
 *
3
 *
4
 * Holds the LogEntry class, which is a representation of what happened every
4
 * Holds the LogEntry class, which is a representation of what happened every
5
 * step() in a Scheduler (or derived classes).
5
 * during the critical parts of step() in Scheduler-derived classes.
6
 *
6
 *
7
 * Copyright (c) 2006, Ira W. Snyder (devel@irasnyder.com)
7
 * Copyright (c) 2006, Ira W. Snyder (devel@irasnyder.com)
8
 *
8
 *
9
 * Permission is hereby granted, free of charge, to any person obtaining a copy
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
10
 * of this software and associated documentation files (the "Software"), to deal
Line 23... Line 23...
23
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
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
24
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25
 * IN THE SOFTWARE.
25
 * IN THE SOFTWARE.
26
 ******************************************************************************/
26
 ******************************************************************************/
27
 
27
 
-
 
28
/**
-
 
29
 * A representation of critical events that happen in Scheduler-derived classes.
-
 
30
 *
-
 
31
 * @class CS431 Fall 2006
-
 
32
 * @author Ira W. Snyder (devel@irasnyder.com)
-
 
33
 */
28
class LogEntry
34
public class LogEntry
29
{
35
{
-
 
36
    /** Message types that are possible */
30
    public static enum MsgType { START, EXPIRE, COMPLETE };
37
    public static enum MsgType
-
 
38
    {
-
 
39
        /** Represents a Process starting on the CPU */
-
 
40
        START,
-
 
41
 
-
 
42
        /** Represents a Process completing this timeslice on the CPU,
-
 
43
         * but not being completely finished yet.
-
 
44
         */
-
 
45
        EXPIRE,
31
 
46
 
-
 
47
        /** Represents a Process completing its execution completely. */
-
 
48
        COMPLETE
-
 
49
    };
-
 
50
 
-
 
51
    /** The time at which this event happened */
32
    public final int time;
52
    public final int time;
-
 
53
 
-
 
54
    /** The process that caused this event */
33
    public final Process proc;
55
    public final Process proc;
-
 
56
 
-
 
57
    /** The type of message that this event represents */
34
    public final MsgType msg;
58
    public final MsgType msg;
35
 
59
 
-
 
60
    /**
-
 
61
     * Constructor for the LogEntry class.
-
 
62
     *
-
 
63
     * @param proc the Process that caused this event
-
 
64
     * @param time the time when this event happened
-
 
65
     * @param msg the type of message that this represents
-
 
66
     */
36
    public LogEntry (Process proc, int time, MsgType msg)
67
    public LogEntry (Process proc, int time, MsgType msg)
37
    {
68
    {
38
        this.time = time;
69
        this.time = time;
39
        this.proc = proc;
70
        this.proc = proc;
40
        this.msg  = msg;
71
        this.msg  = msg;
41
    }
72
    }
42
 
73
 
-
 
74
    /**
-
 
75
     * Convert this LogEntry to a String for printing.
-
 
76
     *
-
 
77
     * @return the String representation of this LogEntry
-
 
78
     */
43
    public String toString ()
79
    public String toString ()
44
    {
80
    {
45
        String action = new String ("invalid");
81
        String action = new String ("invalid");
46
 
82
 
47
        switch (msg)
83
        switch (msg)