]> wirehaze git hosting - ppos.git/blob - ppos/test/pingpong-dispatcher.c

wirehaze git hosting

tasks implementation (ongoing)
[ppos.git] / ppos / test / pingpong-dispatcher.c
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 // Teste do dispatcher com escalonador FCFS
9
10 #include <assert.h>
11 #include "lib/libc.h"
12 #include "ppos.h"
13
14 static struct task_t *pang, *peng, *ping, *pong, *pung;
15
16 // corpo das tarefas
17 void body(void *arg)
18 {
19 printf("%s: inicio\n", (char *)arg);
20 for (int i = 0; i < 5; i++)
21 {
22 printf("%s: %d\n", (char *)arg, i);
23 task_yield();
24 }
25 printf("%s: fim\n", (char *)arg);
26 task_exit(0);
27 }
28
29 // corpo da tarefa principal
30 void user_main(void *arg)
31 {
32 printf("user: criando as tarefas\n");
33
34 // cria tarefas
35 pang = task_create("pang", body, "\tPang");
36 assert(pang);
37 peng = task_create("peng", body, "\t\tPeng");
38 assert(peng);
39 ping = task_create("ping", body, "\t\t\tPing");
40 assert(ping);
41 pong = task_create("pong", body, "\t\t\t\tPong");
42 assert(pong);
43 pung = task_create("pung", body, "\t\t\t\t\tPung");
44 assert(pung);
45
46 printf("user: fim\n");
47
48 task_exit(0);
49 }