]>
wirehaze git hosting - ppos.git/blob - ppos/test/pingpong-preempcao.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 preempção por tempo (quantum)
14 #define WORKLOAD 10000
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("%s: inicio\n", (char *)arg
);
33 for (int i
= 0; i
< 10; i
++)
35 printf("%s: %d\n", (char *)arg
, i
);
38 printf("%s: fim\n", (char *)arg
);
42 // corpo da tarefa principal
43 void user_main(void *arg
)
45 printf("user: inicio\n");
48 pang
= task_create("pang", body
, "\tPang");
50 peng
= task_create("peng", body
, "\t\tPeng");
52 ping
= task_create("ping", body
, "\t\t\tPing");
54 pong
= task_create("pong", body
, "\t\t\t\tPong");
56 pung
= task_create("pung", body
, "\t\t\t\t\tPung");
59 printf("user: fim\n");