/** * Execute the tasks managed by this scheduler. */ public void schedule() { this.currentTcb = this.list; #if TRACEIT int kkk = 0; #endif while (this.currentTcb != null) { #if TRACEIT Console.WriteLine("kkk = {0}", kkk); kkk++; #endif if (this.currentTcb.isHeldOrSuspended()) { #if TRACEIT Console.WriteLine("held"); #endif this.currentTcb = this.currentTcb.link; } else { this.currentId = this.currentTcb.id; #if TRACEIT Console.WriteLine("currentId is now...{0}", this.currentId.ToString()); #endif this.currentTcb = this.currentTcb.run(); } } }
public Scheduler() { this.queueCount = 0; this.holdCount = 0; this.blocks = new TaskControlBlock[NUMBER_OF_IDS]; this.list = null; this.currentTCB = null; this.currentId = 0;//check this }
public Scheduler() { this.queueCount = 0; this.holdCount = 0; this.blocks = new TaskControlBlock[Support.NUMBER_OF_IDS]; this.list = null; this.currentTcb = null; this.currentId = 0; }
/** * Add the specified packet to the end of the worklist used by the task * associated with the packet and make the task runnable if it is currently * suspended. * #param {Packet} packet the packet to add */ public TaskControlBlock queue(Packet packet) { TaskControlBlock t = this.blocks[packet.id]; if (t == null) { return(t); } this.queueCount++; packet.link = null; packet.id = this.currentId; return(t.checkPriorityAdd(this.currentTCB, packet)); }
/** * Execute the tasks managed by this scheduler. */ public void schedule() { this.currentTCB = this.list; while (this.currentTCB != null) { if (this.currentTCB.isHeldOrSuspended()) { this.currentTCB = this.currentTCB.link; } else { this.currentId = this.currentTCB.id; this.currentTCB = this.currentTCB.run(); } } }
public TaskControlBlock(TaskControlBlock link, int id, int priority, Packet queue, Task task) { this.link = link; this.id = id; this.priority = priority; this.queue = queue; this.task = task; if (queue == null) { this.state = States.SUSPENDED; } else { this.state = States.SUSPENDED_RUNNABLE; } }
/** * Adds a packet to the worklist of this block's task, marks this as runnable if * necessary, and returns the next runnable object to run (the one * with the highest priority). */ public TaskControlBlock checkPriorityAdd(TaskControlBlock task, Packet packet) { if (this.queue == null) { this.queue = packet; this.markAsRunnable(); if (this.priority >= task.priority) { return(this); } } else { this.queue = packet.addTo(this.queue); } return(task); }
/** * Release a task that is currently blocked and return the next block to run. * #param {int} id the id of the task to suspend */ public TaskControlBlock release(int id) { TaskControlBlock tcb = this.blocks[id]; if (tcb == null) { return(tcb); } tcb.markAsNotHeld(); if (tcb.priority > this.currentTCB.priority) { return(tcb); } else { return(this.currentTCB); } }
/** * Adds a packet to the worklist of this block's task, marks this as runnable if * necessary, and returns the next runnable object to run (the one * with the highest priority). */ public TaskControlBlock checkPriorityAdd(TaskControlBlock task, Packet packet) { if (this.queue == null) { this.queue = packet; this.markAsRunnable(); if (this.priority >= task.priority) return this; } else { this.queue = packet.addTo(this.queue); } return task; }
public TaskControlBlock(TaskControlBlock link, int id, int priority, Packet queue, Task task) { this.link = link; this.id = id; this.priority = priority; this.queue = queue; this.task = task; if (queue == null) { this.state = Support.STATE_SUSPENDED; } else { this.state = Support.STATE_SUSPENDED_RUNNABLE; } }
/** * Add the specified task to this scheduler. * @param {int} id the identity of the task * @param {int} priority the task's priority * @param {Packet} queue the queue of work to be processed by the task * @param {Task} task the task to add */ public void addTask(int id, int priority, Packet queue, Task task) { this.currentTcb = new TaskControlBlock(this.list, id, priority, queue, task); this.list = this.currentTcb; this.blocks[id] = this.currentTcb; }
/** * Add the specified task to this scheduler. * @param {int} id the identity of the task * @param {int} priority the task's priority * @param {Packet} queue the queue of work to be processed by the task * @param {Task} task the task to add */ public void addTask(int id, int priority, Packet queue, Task task) { this.currentTCB = new TaskControlBlock(this.list, id, priority, queue, task); this.list = this.currentTCB; this.blocks[id] = this.currentTCB; }