-
Notifications
You must be signed in to change notification settings - Fork 1
/
swappingTheSpit.c
88 lines (54 loc) · 1.22 KB
/
swappingTheSpit.c
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
79
80
81
82
83
84
85
86
87
88
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdbool.h>
#define MAX_PROCESSES 64
int pid;
pid_t mainPid;
bool mainGameLoopConditional;
//begin
enum PROCESSES {
MAIN = 0,
LAUNCHER,
JOY,
KEY,
MOUSE,
SOUND
};
struct procIdentTableStructure
{
int processNumber;
void (*processFunction)(void *);
};
struct procIdentTableStructure procIdentTable[MAX_PROCESSES]; //a table to identify the many processes that are going to be spawned
//~ void *(something)(void); //I think this is a function pointer right here
void joyStickDaemon(void *package);
void soundDaemon(void *package);
void keyboardDaemon(void *package);
void mouseDaemon(void *package);
void launcherDaemon(void *package);
int main()
{
int i = 0;
for (i = 0; i < MAX_PROCESSES; i++)
{
procIdentTable[i].processFunction = &joyStickDaemon;
mainPid = fork();
if (mainPid != 0)
{
procIdentTable[i].processNumber = (int) mainPid; //make sure to cast this to make it safe
}
else
{
procIdentTable[i].processFunction(NULL);
}
}
//ending the simulation is below right here
END_SIM:
return 0;
}
void joyStickDaemon(void *package)
{
int i;
usleep(2);
}