]> wirehaze git hosting - ppos.git/blob - ppos/kernel/dispatcher.h

wirehaze git hosting

tasks implementation (ongoing)
[ppos.git] / ppos / kernel / dispatcher.h
1 // PingPongOS - PingPong Operating System
2 // Prof. Carlos A. Maziero, DINF UFPR
3 // Versão 2.0 -- Junho de 2025
4
5 // ATENÇÃO: ESTE ARQUIVO NÃO DEVE SER ALTERADO;
6 // ALTERAÇÕES SERÃO DESCARTADAS NA CORREÇÃO.
7
8 #ifndef __PPOS_DISPATCHER__
9 #define __PPOS_DISPATCHER__
10
11 #include "lib/queue.h"
12 #include "tcb.h"
13
14 // inicia o subsistema dispatcher
15 void dispatcher_init();
16
17 // executa o dispatcher
18 void dispatcher();
19
20 // executa a tarefa indicada: a retira da fila de prontas,
21 // muda seu status para RODANDO e transfere a CPU para ela.
22 void task_run(struct task_t *task);
23
24 // a tarefa atual libera a CPU para o dispatcher,
25 // voltando para a fila de prontas
26 void task_yield();
27
28 // suspende a tarefa atual: a retira da fila de prontas,
29 // a insere na fila "queue" (se não for NULL) e retorna
30 // ao dispatcher.
31 void task_suspend(struct queue_t *queue);
32
33 // acorda uma tarefa: a retira da fila onde se encontra
34 // suspensa (se estiver em uma) e a insere na fila de
35 // prontas, para retomar (ou iniciar) sua execução.
36 void task_awake(struct task_t *task);
37
38 // encerra a execução da tarefa atual, informando um
39 // "exit code", e retorna ao dispatcher.
40 void task_exit(int exit_code);
41
42 // a tarefa atual fica suspensa aguardando que a tarefa
43 // indicada termine; a execução retorna ao dispatcher.
44 // retorno: "exit code" da tarefa indicada ou ERROR
45 int task_wait(struct task_t *task);
46
47 // a tarefa atual fica suspensa por t milissegundos;
48 // a execução retorna ao dispatcher.
49 void task_sleep(int t);
50
51 #endif