forked from HexHive/SMoTherSpectre
-
Notifications
You must be signed in to change notification settings - Fork 0
/
orchestrator.c
43 lines (34 loc) · 994 Bytes
/
orchestrator.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
#include <sys/sysinfo.h>
#include <sys/types.h>
#include <unistd.h>
#include "synch.h"
int main(int argc, char **argv) {
int nprocs;
pid_t pida, pidv, pid, status;
char core[2] = {'0', 0};
nprocs = get_nprocs();
/* Create shmem for synchronization */
synch_create();
/* Launch attacker */
pida = fork();
VERIFY(pida >= 0, "Forking attacker failed");
if(pida == 0){
core[0] = '0' + CORE0;
/* Child exec's attacker process */
char *args[] = {"attack", "a", core, NULL};
VERIFY(execv("./attack", args) != -1, "Executing attacker failed");
}
/* Launch victim */
pidv = fork();
VERIFY(pidv >= 0, "Forking victim failed");
if(pidv == 0){
core[0] = '0' + CORE1;
/* Child exec's victim process */
char *args[] = {"victim", "v", core, NULL};
VERIFY(execv("./victim", args) != -1, "Executing victim failed");
}
/* Assuming clean exit */
pid = waitpid(pida, &status, 0);
pid = waitpid(pidv, &status, 0);
synch_destroy();
}