-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathppos_data.h
79 lines (63 loc) · 2.31 KB
/
ppos_data.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// PingPongOS - PingPong Operating System
// Prof. Carlos A. Maziero, DINF UFPR
// Versão 1.1 -- Julho de 2016
// Estruturas de dados internas do sistema operacional
#ifndef __PPOS_DATA__
#define __PPOS_DATA__
#include <stdio.h>
#include <ucontext.h> // biblioteca POSIX de trocas de contexto
#include "queue.h" // biblioteca de filas genéricas
// Estrutura que define um Task Control Block (TCB)
typedef struct task_t
{
struct task_t *prev, *next ; // ponteiros para usar em filas
int id ; // identificador da tarefa
ucontext_t context ; // contexto armazenado da tarefa
unsigned char state; // indica o estado de uma tarefa (ver defines no final do arquivo ppos.h):
// n - nova, r - pronta, x - executando, s - suspensa, e - terminada
struct task_t* queue;
struct task_t* joinQueue;
int exitCode;
unsigned int awakeTime; // used to store the time when it should be waked up
// ... (outros campos deve ser adicionados APOS esse comentario)
int staticPriority; //escalonador priod: prioridade estática
int dynamicPriority; //escalonador priod: prioridade dinâmica
unsigned char userTask; //preempção: se a tarefa é do usuário ou não
int quantum; //quantidade de ticks antes da preempção
int creationDate; //momento da criação da tarefa
int lastSwitchDate; //último momento em que a tarefa foi ativada
int cpuTime; //tempo do processador utilizado na tarefa
int activations; //numero de ativações, trocas para esta tarefa
} task_t ;
// estrutura que define um semáforo
typedef struct {
struct task_t *queue;
int value;
unsigned char active;
} semaphore_t ;
// estrutura que define um mutex
typedef struct {
struct task_t *queue;
unsigned char value;
unsigned char active;
} mutex_t ;
// estrutura que define uma barreira
typedef struct {
struct task_t *queue;
int maxTasks;
int countTasks;
unsigned char active;
mutex_t mutex;
} barrier_t ;
// estrutura que define uma fila de mensagens
typedef struct {
void* content;
int messageSize;
int maxMessages;
int countMessages;
semaphore_t sBuffer;
semaphore_t sItem;
semaphore_t sVaga;
unsigned char active;
} mqueue_t ;
#endif