示例#1
0
文件: kernel.c 项目: aianus/trains
/**
 * Handles a request for a task.
 *
 */
int handle(Task *task, Request *req) {
    // Handle Interrupts.
    if (req == 0) {
        int data;
        int event = process_interrupt(&data); 
        kevent(event, data);
        make_ready(task);
        return 0;
    }


    // Handle System Calls.
    switch (req->request) {
    case MY_TID:
        kmytid(task);
        break;
    case CREATE:
        kcreate(task, (int)req->args[0] /* priority */, req->args[1] /* code */, (int)req->args[2] /* args */);
        break;
    case MY_PARENT_TID:
        kmy_parent_tid(task);
        break;
    case PASS:
        make_ready(task);
        break;
    case EXIT:
        kexit(task);
        break;
    case SEND:
        ksend(task, (int)req->args[0], (char *)req->args[1], (int)req->args[2], (char *)req->args[3], (int)req->args[4]);
        break;
    case RECEIVE:
        krecieve(task, (int *)req->args[0], (char *)req->args[1], (int)req->args[2]);
        break;
    case REPLY:
        kreply(task, (int)req->args[0], (char *)req->args[1], (int)req->args[2]);
        break;
    case AWAIT_EVENT:
        kawait(task, (int)req->args[0]);
        break;
    case WAIT_TID:
        kwait_tid(task, (int)req->args[0]);
        break;
    case SHUTDOWN:
        return -1;
    default:
        bwprintf(COM2, "Undefined request number %u\n", req->request);
        break;
    }

    return 0;
}
示例#2
0
static inline void irq_select(void)
{
  if (SillyG) {
    int irq_bits = vm86_plus(VM86_GET_IRQ_BITS, 0);
    if (irq_bits) {
      SillyG_t *sg=SillyG;
      while (sg->fd) {
        if (irq_bits & (1 << sg->irq)) {
          if (process_interrupt(sg)) {
            vm86_plus(VM86_GET_AND_RESET_IRQ,sg->irq);
            h_printf("SIG: We have an interrupt\n");
          }
        }
        sg++;
      }
    }
  }
}