示例#1
0
        /**
         * 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();
                }
            }
        }
示例#2
0
 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
 }
示例#3
0
 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;
 }
示例#4
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));
        }
示例#5
0
 /**
  * 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();
         }
     }
 }
示例#6
0
 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;
     }
 }
示例#7
0
 /**
  * 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);
 }
示例#8
0
        /**
         * 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);
            }
        }
示例#9
0
 /**
  * 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;
 }
示例#10
0
 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;
     }
 }
示例#11
0
        /**
         * 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();
                }
            }
        }
示例#12
0
 /**
  * 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;
 }
示例#13
0
 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;
 }
示例#14
0
 /**
  * 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;
 }