| 529 | {{{#!protected ------------------------------------------------------------------------------------ |
| 530 | '' |
| 531 | `kernel/harch.c` |
| 532 | {{{#!c |
| 533 | extern void arch_init (int tick, unsigned quantum); |
| 534 | }}} |
| 535 | `kernel/harch.c` |
| 536 | {{{#!c |
| 537 | static unsigned timer_quantum; |
| 538 | static void timer_init (int timer, int tick, unsigned quantum) |
| 539 | { |
| 540 | __timer_regs_map[timer].resetirq = 0; // to delete previous untraited IRQ |
| 541 | __timer_regs_map[timer].period = tick; // next period |
| 542 | __timer_regs_map[timer].mode = (tick)?3:0; // timer ON with IRQ only if (tick != 0) |
| 543 | timer_quantum = quantum % 100; // %100 to avoid aberrant value |
| 544 | } |
| 545 | static void timer_isr (int timer) |
| 546 | { |
| 547 | __timer_regs_map[timer].resetirq = 1; |
| 548 | if (timer_quantum) { |
| 549 | kprintf ("\n...%d : ", timer_quantum--); |
| 550 | } else { |
| 551 | kprintf ("\nGame Over\n"); |
| 552 | exit(1); |
| 553 | } |
| 554 | } |
| 555 | }}} |
| 556 | `kernel/kinit.c` |
| 557 | {{{#!c |
| 558 | void kinit (void) |
| 559 | { |
| 560 | [...] |
| 561 | arch_init (3*3500000, 10); // tick is about 1 seconde, quantum is about 30 secondes |
| 562 | [...] |
| 563 | } |
| 564 | }}} |
| 565 | '' |
| 566 | }}} |