-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpass.c
More file actions
59 lines (51 loc) · 937 Bytes
/
pass.c
File metadata and controls
59 lines (51 loc) · 937 Bytes
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
#include<unistd.h>
int toc[2], top[2], tome, fromme;
void __attribute__ ((noinline)) block(){
char buf[2];
read(tome,buf,1);
}
void __attribute__ ((noinline)) realtrigger(){
write(fromme,"\n",1);
}
void __attribute__ ((noinline)) trigger(){
realtrigger();
}
void __attribute__ ((noinline)) do_remaining_work(int* data){
for (int j=0; j<2000; j++) {
for (int i=1000; i<1024; i++) {
data[i]*=i;
}
}
}
void __attribute__ ((noinline)) work(){
int data[1024];
for (int i=0; i<1024; i++) {
data[i]=i;
}
for (int j=0; j<1000; j++) {
for (int i=0; i<1024; i++) {
data[i]*=i;
}
}
do_remaining_work(data);
}
void __attribute__ ((noinline)) realmain(){
pipe(toc);
pipe(top);
if (fork()){
tome=toc[0];
fromme=top[1];
block();
} else {
tome=top[0];
fromme=toc[1];
}
while(1) {
work();
trigger();
block();
}
}
int main() {
realmain();
}