Commit a6ea1595c93e483ee7b688d418b13b2653b510c3
1 parent
8a0f7262a0
Exists in
master
Indented stuff for CPU directory
Showing 12 changed files with 58 additions and 31 deletions Side-by-side Diff
cpu/context_switch_process.o
View file @
a6ea159
cpu/loop_overhead_time.c
View file @
a6ea159
... | ... | @@ -12,10 +12,9 @@ |
12 | 12 | asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time1)); |
13 | 13 | for (i = 0; i < 1000; i++); |
14 | 14 | asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time2)); |
15 | - avg = (time2 - time1 - 5); | |
15 | + avg = (time2 - time1 - 5); //5 is measurement overhead for mrc | |
16 | 16 | sum++; |
17 | - printf("%f,", avg/1000); | |
18 | 17 | } |
19 | - printf("%f", avg); | |
18 | + printf("%f", avg/100); | |
20 | 19 | } |
cpu/loop_overhead_time.o
View file @
a6ea159
cpu/process_creation.c
View file @
a6ea159
... | ... | @@ -16,10 +16,10 @@ |
16 | 16 | int pid = fork(); |
17 | 17 | if (pid) { |
18 | 18 | asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (b)); |
19 | + // Measure time for creation, kill the child | |
19 | 20 | kill(pid, SIGKILL); |
20 | 21 | wait(NULL); |
21 | - if ((b - a) < 400000) | |
22 | - printf("%u,", b - a); | |
22 | + printf("%u,", b - a); | |
23 | 23 | } |
24 | 24 | } |
25 | 25 |
cpu/rasperf.h
View file @
a6ea159
1 | + | |
2 | +#ifndef __RASPERF_H__ | |
3 | +#define NULL '\0' | |
4 | +#define __RASPERF_H__ | |
5 | +#define RTT 35 //in MicroSec | |
6 | +#define PI 0 | |
7 | +#define x86 1 | |
8 | +#define CPU_CYCLES 900 | |
9 | +#define MHz 1e6 | |
10 | +#if defined(PI) && PI | |
11 | +#define time unsigned int | |
12 | +#define getTime(var) \ | |
13 | + asm volatile (\ | |
14 | + "mrc p15, 0, %0, c9, c13, 0":\ | |
15 | + "=r" (var)); | |
16 | +#define readCCNTStatus(var) \ | |
17 | + asm volatile (\ | |
18 | + "mrc p15, 0, %0, c9, c14, 0":\ | |
19 | + "=r" (var)); | |
20 | +#define diff(end, begin) \ | |
21 | + (end - begin)/ CPU_CYCLES}; | |
22 | +#endif | |
23 | +#if defined(x86) && x86 | |
24 | +#define time struct timeval | |
25 | +#define getTime(var) gettimeofday(&var, NULL) | |
26 | +#define diff(end, begin) \ | |
27 | + ((end.tv_sec*1e6+end.tv_usec) - (begin.tv_sec*1e6+ begin.tv_usec)) | |
28 | +#endif | |
29 | +#endif |
cpu/reading_time.c
View file @
a6ea159
... | ... | @@ -13,7 +13,7 @@ |
13 | 13 | asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (a)); |
14 | 14 | asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (b)); |
15 | 15 | time += b - a; |
16 | - printf("%d,", b-a); | |
16 | + //printf("%d,", b-a); | |
17 | 17 | } |
18 | 18 | avg = time / 1000; |
19 | 19 | printf("Measurement overhead: %f\n", avg); |
cpu/reading_time.o
View file @
a6ea159
cpu/syscall.c
View file @
a6ea159
... | ... | @@ -14,10 +14,6 @@ |
14 | 14 | i = getpid(); |
15 | 15 | asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (b)); |
16 | 16 | printf("PID: %u, Time for getpid: %u\n", i, b - a); |
17 | - asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (a)); | |
18 | - time(); | |
19 | - asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (b)); | |
20 | - printf("PID2: Time for time(): %u\n", b - a); | |
21 | 17 | return 0; |
22 | 18 | } |
cpu/syscall.o
View file @
a6ea159
cpu/thd_ctxsw.c
View file @
a6ea159
... | ... | @@ -6,27 +6,30 @@ |
6 | 6 | #include<stdlib.h> |
7 | 7 | #include<signal.h> |
8 | 8 | #define STACK_SIZE 4096 |
9 | + | |
9 | 10 | int pipe_fd[2], tid1, tid2; |
10 | 11 | char buffer[10]; |
11 | 12 | int reader(void* arg); |
12 | 13 | int writer(void* arg); |
13 | -int controller(void *arg) | |
14 | +int primary(void *arg) | |
14 | 15 | { |
15 | - void *tid1_stack = malloc(STACK_SIZE); | |
16 | - void *tid2_stack = malloc(STACK_SIZE); | |
17 | - tid1 = clone(&writer, tid1_stack+STACK_SIZE, SIGCHLD|CLONE_SIGHAND|CLONE_FS|CLONE_VM|CLONE_FILES|CLONE_THREAD, NULL); | |
18 | - tid2 = clone(&reader, tid2_stack+STACK_SIZE, SIGCHLD|CLONE_SIGHAND|CLONE_FS|CLONE_VM|CLONE_FILES|CLONE_THREAD, NULL); | |
19 | - return 0; | |
16 | + void *tid1_stack = malloc(STACK_SIZE); | |
17 | + void *tid2_stack = malloc(STACK_SIZE); | |
18 | + tid1 = clone(&writer, tid1_stack+STACK_SIZE, | |
19 | + SIGCHLD|CLONE_SIGHAND|CLONE_FS|CLONE_VM|CLONE_FILES|CLONE_THREAD, NULL); | |
20 | + tid2 = clone(&reader, tid2_stack+STACK_SIZE, | |
21 | + SIGCHLD|CLONE_SIGHAND|CLONE_FS|CLONE_VM|CLONE_FILES|CLONE_THREAD, NULL); | |
22 | + return 0; | |
20 | 23 | } |
21 | 24 | int reader(void* arg) |
22 | 25 | { |
23 | - read(pipe_fd[0], buffer, 1); | |
24 | - return 0; | |
26 | + read(pipe_fd[0], buffer, 1); | |
27 | + return 0; | |
25 | 28 | } |
26 | 29 | int writer(void* arg) |
27 | 30 | { |
28 | - write(pipe_fd[1], "a", 1); | |
29 | - return 0; | |
31 | + write(pipe_fd[1], "a", 1); | |
32 | + return 0; | |
30 | 33 | } |
31 | 34 | int main(){ |
32 | 35 | |
33 | 36 | |
34 | 37 | |
... | ... | @@ -39,16 +42,17 @@ |
39 | 42 | |
40 | 43 | //asm volatile("mrc p15, 0, %0, c9, c14, 0" : "=r" (regr)); |
41 | 44 | //printf("regr: %x\n", regr); |
42 | - | |
45 | + | |
43 | 46 | //initialize communication pipe |
44 | 47 | for (i = 0; i < 1000; i++) |
45 | 48 | { |
46 | 49 | getTime(start); |
47 | - thread_pid = clone(&controller, child_stack+STACK_SIZE, SIGCHLD|CLONE_SIGHAND|CLONE_FS|CLONE_VM|CLONE_FILES|CLONE_THREAD, NULL); | |
50 | + thread_pid = clone(&primary, child_stack+STACK_SIZE, | |
51 | + SIGCHLD|CLONE_SIGHAND|CLONE_FS|CLONE_VM|CLONE_FILES|CLONE_THREAD, NULL); | |
48 | 52 | waitpid(thread_pid, 0, 0); |
49 | 53 | getTime(end); |
50 | 54 | printf("\nTime Taken %d", diff(end,start)); |
51 | 55 | } |
52 | 56 | return 0; |
53 | -} | |
57 | +} |
cpu/thd_ctxsw.o
View file @
a6ea159
cpu/thread_creation.c
View file @
a6ea159
... | ... | @@ -21,14 +21,12 @@ |
21 | 21 | asm volatile("mrc p15, 0, %0, c9, c14, 0" : "=r" (regr)); |
22 | 22 | printf("regr: %x\n", regr); |
23 | 23 | |
24 | -// for (i = 0; i < 1000; i++) | |
25 | -// { | |
26 | - asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (a)); | |
27 | - thread_pid = clone(&func, child_stack+STACK_SIZE, SIGCHLD|CLONE_SIGHAND|CLONE_FS|CLONE_VM|CLONE_FILES|CLONE_THREAD, NULL); | |
28 | - asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (b)); | |
29 | -// waitpid(thread_pid,0,0); | |
30 | - printf("%u,", b - a); | |
31 | -// } | |
24 | + asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (a)); | |
25 | + thread_pid = clone(&func, child_stack+STACK_SIZE, | |
26 | + SIGCHLD|CLONE_SIGHAND|CLONE_FS|CLONE_VM|CLONE_FILES|CLONE_THREAD, NULL); | |
27 | + asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (b)); | |
28 | + // waitpid(thread_pid,0,0); | |
29 | + printf("%u,", b - a); | |
32 | 30 | return 0; |
33 | 31 | } |