• Home
  • Raw
  • Download

Lines Matching full:this

7 //       notice, this list of conditions and the following disclaimer.
9 // copyright notice, this list of conditions and the following
14 // from this software without specific prior written permission.
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 // This is a JavaScript implementation of the Richards
100 this.queueCount = 0;
101 this.holdCount = 0;
102 this.blocks = new Array(NUMBER_OF_IDS);
103 this.list = null;
104 this.currentTcb = null;
105 this.currentId = null;
120 * Add an idle task to this scheduler.
127 this.addRunningTask(id, priority, queue, new IdleTask(this, 1, count));
131 * Add a work task to this scheduler.
137 this.addTask(id, priority, queue, new WorkerTask(this, ID_HANDLER_A, 0));
141 * Add a handler task to this scheduler.
147 this.addTask(id, priority, queue, new HandlerTask(this));
151 * Add a handler task to this scheduler.
157 this.addTask(id, priority, queue, new DeviceTask(this))
168 this.addTask(id, priority, queue, task);
169 this.currentTcb.setRunning();
173 * Add the specified task to this scheduler.
180 this.currentTcb = new TaskControlBlock(this.list, id, priority, queue, task);
181 this.list = this.currentTcb;
182 this.blocks[id] = this.currentTcb;
186 * Execute the tasks managed by this scheduler.
189 this.currentTcb = this.list;
190 while (this.currentTcb != null) {
191 if (this.currentTcb.isHeldOrSuspended()) {
192 this.currentTcb = this.currentTcb.link;
194 this.currentId = this.currentTcb.id;
195 this.currentTcb = this.currentTcb.run();
205 var tcb = this.blocks[id];
208 if (tcb.priority > this.currentTcb.priority) {
211 return this.currentTcb;
221 this.holdCount++;
222 this.currentTcb.markAsHeld();
223 return this.currentTcb.link;
231 this.currentTcb.markAsSuspended();
232 return this.currentTcb;
242 var t = this.blocks[packet.id];
244 this.queueCount++;
246 packet.id = this.currentId;
247 return t.checkPriorityAdd(this.currentTcb, packet);
254 * @param {int} id the id of this block
255 * @param {int} priority the priority of this block
261 this.link = link;
262 this.id = id;
263 this.priority = priority;
264 this.queue = queue;
265 this.task = task;
267 this.state = STATE_SUSPENDED;
269 this.state = STATE_SUSPENDED_RUNNABLE;
298 this.state = STATE_RUNNING;
302 this.state = this.state & STATE_NOT_HELD;
306 this.state = this.state | STATE_HELD;
310 return (this.state & STATE_HELD) != 0 || (this.state == STATE_SUSPENDED);
314 this.state = this.state | STATE_SUSPENDED;
318 this.state = this.state | STATE_RUNNABLE;
322 * Runs this task, if it is ready to be run, and returns the next task to run.
326 if (this.state == STATE_SUSPENDED_RUNNABLE) {
327 packet = this.queue;
328 this.queue = packet.link;
329 if (this.queue == null) {
330 this.state = STATE_RUNNING;
332 this.state = STATE_RUNNABLE;
337 return this.task.run(packet);
341 * Adds a packet to the worklist of this block's task, marks this as runnable if
346 if (this.queue == null) {
347 this.queue = packet;
348 this.markAsRunnable();
349 if (this.priority > task.priority) return this;
351 this.queue = packet.addTo(this.queue);
357 return "tcb { " + this.task + "@" + this.state + " }";
363 * @param {Scheduler} scheduler the scheduler that manages this task
365 * @param {int} count the number of times this task should be scheduled
369 this.scheduler = scheduler;
370 this.v1 = v1;
371 this.count = count;
375 this.count--;
376 if (this.count == 0) return this.scheduler.holdCurrent();
377 if ((this.v1 & 1) == 0) {
378 this.v1 = this.v1 >> 1;
379 return this.scheduler.release(ID_DEVICE_A);
381 this.v1 = (this.v1 >> 1) ^ 0xD008;
382 return this.scheduler.release(ID_DEVICE_B);
393 * @param {Scheduler} scheduler the scheduler that manages this task
397 this.scheduler = scheduler;
398 this.v1 = null;
403 if (this.v1 == null) return this.scheduler.suspendCurrent();
404 var v = this.v1;
405 this.v1 = null;
406 return this.scheduler.queue(v);
408 this.v1 = packet;
409 return this.scheduler.holdCurrent();
419 * @param {Scheduler} scheduler the scheduler that manages this task
425 this.scheduler = scheduler;
426 this.v1 = v1;
427 this.v2 = v2;
432 return this.scheduler.suspendCurrent();
434 if (this.v1 == ID_HANDLER_A) {
435 this.v1 = ID_HANDLER_B;
437 this.v1 = ID_HANDLER_A;
439 packet.id = this.v1;
442 this.v2++;
443 if (this.v2 > 26) this.v2 = 1;
444 packet.a2[i] = this.v2;
446 return this.scheduler.queue(packet);
456 * @param {Scheduler} scheduler the scheduler that manages this task
460 this.scheduler = scheduler;
461 this.v1 = null;
462 this.v2 = null;
468 this.v1 = packet.addTo(this.v1);
470 this.v2 = packet.addTo(this.v2);
473 if (this.v1 != null) {
474 var count = this.v1.a1;
477 if (this.v2 != null) {
478 v = this.v2;
479 this.v2 = this.v2.link;
480 v.a1 = this.v1.a2[count];
481 this.v1.a1 = count + 1;
482 return this.scheduler.queue(v);
485 v = this.v1;
486 this.v1 = this.v1.link;
487 return this.scheduler.queue(v);
490 return this.scheduler.suspendCurrent();
511 * @param {int} id an ID for this packet
512 * @param {int} kind the type of this packet
516 this.link = link;
517 this.id = id;
518 this.kind = kind;
519 this.a1 = 0;
520 this.a2 = new Array(DATA_SIZE);
524 * Add this packet to the end of a worklist, and return the worklist.
525 * @param {Packet} queue the worklist to add this packet to
528 this.link = null;
529 if (queue == null) return this;
533 next.link = this;