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 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
/**
27
import java.util.Vector;
28
 * A Round-Robin Scheduler.
28
 
29
 *
-
 
30
 * @class CS431 Fall 2006
-
 
31
 * @author Ira W. Snyder (devel@irasnyder.com)
-
 
32
 */
29
class RRScheduler extends Scheduler
33
public class RRScheduler extends Scheduler
30
{
34
{
-
 
35
    /** the interval at which to switch processes */
31
    protected final int interval;
36
    protected final int interval;
-
 
37
 
-
 
38
    /** the amount of time that the current process has been running */
32
    protected int cur_proc_runtime = 0;
39
    protected int cur_proc_runtime = 0;
33
 
40
 
-
 
41
    /**
-
 
42
     * Constructor for the Round Robin Scheduler class.
-
 
43
     */
34
    public RRScheduler (int interval)
44
    public RRScheduler (int interval)
35
    {
45
    {
36
        super ();
46
        super ();
37
        this.interval = interval;
47
        this.interval = interval;
38
    }
48
    }
39
 
49
 
-
 
50
    /**
-
 
51
     * Emulates a single time unit in a Round Robin Scheduler.
-
 
52
     *
-
 
53
     * @return false if there is nothing left to do, true otherwise
-
 
54
     */
40
    protected boolean step ()
55
    protected boolean step ()
41
    {
56
    {
42
        /* Stop if we have nothing left to do */
57
        /* Stop if we have nothing left to do */
43
        if (cur_proc == null && run_queue.isEmpty ())
58
        if (cur_proc == null && run_queue.isEmpty ())
44
            return false;
59
            return false;