/
Structures.h
64 lines (47 loc) · 1.25 KB
/
Structures.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
#include <stdio.h>
#include <ucontext.h>
#include <signal.h>
#include <sys/time.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#define STACKSIZE 1024*1024
#ifndef STRUCTURES_H
#define STRUCTURES_H
typedef struct state{
int id;
int finish;
double percent;
double result;
int active;
}state;
typedef long thread_t;
typedef struct Thread{
char *tid;
int tickets;
int lowerLimit;
int upperLimit;
int finish;
}Thread;
struct Thread* getNewThreadnoStack(int, char*);
struct Thread* getNewThreadwithStack();
//Aqui puede crear las estructuras para manejar el scheduler y los hilos. seria bueno
//tener una estructura para los blocquados, otro para los que estan en cola y otra para los terminados
//y obviamente las funciones para manejarlas
enum{EXPROPIATIVO, NO_EXPROPIATIVO};
/* scheduler struct */
struct sched_t {
Thread *(*nextTask) (void);
void (*addTask)(Thread *, ucontext_t);
void (*removeTask)(int);
void (*manageTimer)();
void (*init)(int, int);
//void (*run)();
void (*updateWork)(float, double);
void(*updateCurrent)();
void (*switchContext)();
};
/* scheduler alloc functions */
struct sched_t *sched_ls_alloc();
struct sched_t *sched_fifo_alloc();
#endif //STRUCTURES_H