ppos

Usermode educational operating system.
Log | Files | Refs

dispatcher.h (1507B)


      1 // PingPongOS - PingPong Operating System
      2 // © Prof. Carlos A. Maziero, DINF UFPR
      3 // Versão 2.1 -- 06/2026
      4 
      5 // ATENÇÃO: ESTE ARQUIVO NÃO DEVE SER ALTERADO;
      6 // ALTERAÇÕES SERÃO DESCARTADAS NA CORREÇÃO.
      7 
      8 // Implementa o dispatcher e operações internas sobre as tarefas.
      9 
     10 #ifndef __PPOS_DISPATCHER__
     11 #define __PPOS_DISPATCHER__
     12 
     13 #include "lib/queue.h"
     14 #include "tcb.h"
     15 
     16 // inicia o subsistema dispatcher
     17 // (chamada pelo núcleo na inicialização).
     18 void dispatcher_init();
     19 
     20 // encerra o subsistema dispatcher
     21 // (chamada pelo núcleo no encerramento).
     22 void dispatcher_term();
     23 
     24 // executa o dispatcher (chamada pelo núcleo após a inicialização).
     25 void dispatcher();
     26 
     27 // transfere a CPU da tarefa atual para outra tarefa; se task_id == 0, 
     28 // transfere para o núcleo. Ignora sem erro se "task" já tiver terminado.
     29 // Retorno: NOERROR (0) ou ERROR (<0)
     30 int task_switch(struct task_t *task);
     31 
     32 // executa a tarefa indicada: retira-a da fila de prontas, muda seu status
     33 // para RODANDO e transfere a CPU para ela.
     34 void task_run(struct task_t *task);
     35 
     36 // suspende a tarefa atual: retira-a da fila de prontas, muda seu status para
     37 // SUSPENSA, a insere na fila "queue" (se não for NULL) e retorna ao dispatcher.
     38 void task_suspend(struct queue_t *queue);
     39 
     40 // acorda uma tarefa: retira-a da fila onde se encontra suspensa (se estiver
     41 // em uma fila), muda seu status para PRONTA e a insere na fila de prontas,
     42 // para retomar (ou iniciar) sua execução.
     43 void task_awake(struct task_t *task);
     44 
     45 #endif