]>
wirehaze git hosting - ppos.git/blob - ppos/test/pingpong-contab-prio.c
1 // PingPongOS - PingPong Operating System
2 // Prof. Carlos A. Maziero, DINF UFPR
3 // Versão 2.0 -- Junho de 2025
5 // ATENÇÃO: ESTE ARQUIVO NÃO DEVE SER ALTERADO;
6 // ALTERAÇÕES SERÃO DESCARTADAS NA CORREÇÃO.
8 // Teste da contabilização com tarefas de prioridades distintas
14 #define WORKLOAD 40000
16 static struct task_t
*pang
, *peng
, *ping
, *pong
, *pung
;
18 // simula um processamento pesado
23 for (int i
= 0; i
< n
; i
++)
24 for (int j
= 0; j
< n
; j
++)
32 printf("%5d ms: %s inicia (prio: %d)\n", systime(),
33 (char *)arg
, sched_getprio(NULL
));
35 printf("%5d ms: %s termina\n", systime(), (char *)arg
);
39 // corpo da tarefa principal
40 void user_main(void *arg
)
42 printf("user: inicio\n");
45 pang
= task_create("pang", body
, "\tPang");
47 peng
= task_create("peng", body
, "\t\tPeng");
49 ping
= task_create("ping", body
, "\t\t\tPing");
51 pong
= task_create("pong", body
, "\t\t\t\tPong");
53 pung
= task_create("pung", body
, "\t\t\t\t\tPung");
57 sched_setprio(pang
, 0);
58 sched_setprio(peng
, -2);
59 sched_setprio(ping
, -4);
60 sched_setprio(pong
, -6);
61 sched_setprio(pung
, -8);
63 printf("user: fim\n");