Commit bfd14a387ea48472cf1c6188a4ec95475aab81ea
1 parent
90b06817c3
Exists in
master
File cache
Showing 2 changed files with 4 additions and 10 deletions Side-by-side Diff
filesystem/file_cache.c
View file @
bfd14a3
... | ... | @@ -6,9 +6,7 @@ |
6 | 6 | #define BLOCK_SIZE 1024 |
7 | 7 | void main() |
8 | 8 | { |
9 | - char fname[10]="file"; | |
10 | - char *fno[] = {"1", "2", "3", "4", "5", "6", "7"}; | |
11 | - char *file; | |
9 | + char *fnames[] = {"file_1", "file_2", "file_3", "file_4", "file_5", "file_6", "file_7"}; | |
12 | 10 | char buffer[BLOCK_SIZE]; |
13 | 11 | struct timeval start, end; |
14 | 12 | int fd=0; |
15 | 13 | |
... | ... | @@ -16,10 +14,9 @@ |
16 | 14 | unsigned long long time; |
17 | 15 | int status; |
18 | 16 | for (i = 0; i < 7; i++) { |
19 | - file = strcat(fname, fno[i]); | |
20 | - printf("File %d: %s\n", i, file); | |
17 | + fd = open(fnames[i], O_RDONLY); | |
18 | + printf("File %d: %s\n", i, fnames[i]); | |
21 | 19 | fflush(NULL); |
22 | - fd = open(file, O_RDONLY); | |
23 | 20 | if (!fd) { |
24 | 21 | printf("unable to open\n"); |
25 | 22 | exit(0); |
26 | 23 | |
27 | 24 | |
... | ... | @@ -33,14 +30,11 @@ |
33 | 30 | } |
34 | 31 | gettimeofday(&end, NULL); |
35 | 32 | time = (end.tv_sec*1e6+end.tv_usec) - (start.tv_sec*1e6+start.tv_usec); |
36 | - printf("timestamp %llu - %llu\n", end.tv_sec*1e6+end.tv_usec, start.tv_sec*1e6+start.tv_usec); | |
33 | + //printf("timestamp %llu - %llu\n", end.tv_sec*1e6+end.tv_usec, start.tv_sec*1e6+start.tv_usec); | |
37 | 34 | printf("time taken to read file # %d - %llu\n", i, time); |
38 | 35 | sync(); |
39 | 36 | status = system("sudo /sbin/sysctl vm.drop_caches=3"); |
40 | 37 | sync(); |
41 | - strcpy(fname, "file"); | |
42 | 38 | } |
43 | - | |
44 | - | |
45 | 39 | } |
filesystem/file_cache.o
View file @
bfd14a3