Question
Write two AWK scripts (i.e. 'count_alloc.awk' and 'list_sizes.awk') to run on the malloc.txt file. count_allocs.awk write an awk script count_allocs.awk that counts the number of
Write two AWK scripts (i.e. 'count_alloc.awk' and 'list_sizes.awk') to run on the malloc.txt file.
- count_allocs.awk
- write an awk script count_allocs.awk that counts the number of successful allocs and the number of failed alloc calls. Your program should act like this:
-
$ awk -f count_allocs.awk malloc-out.txt
num successes: 448; num failures: 106
-
- write an awk script count_allocs.awk that counts the number of successful allocs and the number of failed alloc calls. Your program should act like this:
- list_sizes.awk
- write an awk script list_sizes.awk that prints the size of every element in the free list, in order, after each Free or Alloc operation. Your program should act like this:
-
$ awk -f list_sizes.awk malloc-out.txt | head
99
1 99
1 92
1 7 92
1 2 92
1 2 84
1 2 8 84
1 5 2 8 84
5 2 8 84
2 8 84
-
- write an awk script list_sizes.awk that prints the size of every element in the free list, in order, after each Free or Alloc operation. Your program should act like this:
************** malloc.txt *****************
Free List [ Size 44 ]: [ addr:1000 sz:1 ] [ addr:1004 sz:1 ] [ addr:1005 sz:1 ][ addr:1016 sz:5 ] [ addr:1021 sz:1 ] [ addr:1022 sz:5 ] [ addr:1027 sz:1 ] [ adr:1035 sz:1 ] [ addr:1036 sz:1 ] [ addr:1037 sz:2 ] [ addr:1039 sz:1 ] [ addr:106 sz:2 ] [ addr:1048 sz:3 ] [ addr:1051 sz:6 ] [ addr:1057 sz:1 ] [ addr:1058 sz1 ] [ addr:1069 sz:2 ] [ addr:1071 sz:6 ] [ addr:1077 sz:2 ] [ addr:1079 sz:1 ] addr:1095 sz:1 ] [ addr:1096 sz:1 ] [ addr:1097 sz:1 ] [ addr:1098 sz:2 ]
Free(ptr[403]) returned 0
Free List [ Size 45 ]: [ addr:1000 sz:1 ] [ addr:1001 sz:3 ] [ addr:1004 sz:1 ][ addr:1012 sz:4 ] [ addr:1016 sz:5 ] [ addr:1021 sz:1 ] [ addr:1022 sz:5 ] [ adr:1031 sz:4 ] [ addr:1035 sz:1 ] [ addr:1036 sz:1 ] [ addr:1037 sz:2 ] [ addr:105 sz:1 ] [ addr:1046 sz:2 ] [ addr:1048 sz:3 ] [ addr:1051 sz:6 ] [ addr:1057 sz7 ] [ addr:1068 sz:1 ] [ addr:1069 sz:2 ] [ addr:1071 sz:6 ] [ addr:1077 sz:2 ] addr:1088 sz:7 ] [ addr:1095 sz:1 ] [ addr:1096 sz:1 ] [ addr:1097 sz:1 ] [ add
ptr[404] = Alloc(4) returned 1012 (searched 45 elements)
Free List [ Size 44 ]: [ addr:1000 sz:1 ] [ addr:1001 sz:3 ] [ addr:1004 sz:1 ][ addr:1016 sz:5 ] [ addr:1021 sz:1 ] [ addr:1022 sz:5 ] [ addr:1027 sz:1 ] [ adr:1035 sz:1 ] [ addr:1036 sz:1 ] [ addr:1037 sz:2 ] [ addr:1039 sz:1 ] [ addr:106 sz:2 ] [ addr:1048 sz:3 ] [ addr:1051 sz:6 ] [ addr:1057 sz:1 ] [ addr:1058 sz1 ] [ addr:1069 sz:2 ] [ addr:1071 sz:6 ] [ addr:1077 sz:2 ] [ addr:1079 sz:1 ] addr:1095 sz:1 ] [ addr:1096 sz:1 ] [ addr:1097 sz:1 ] [ addr:1098 sz:2 ]
.
.
.
ptr[405] = Alloc(3) returned 1001 (searched 44 elements)
Free List [ Size 43 ]: [ addr:1000 sz:1 ] [ addr:1004 sz:1 ] [ addr:1005 sz:1 ][ addr:1021 sz:1 ] [ addr:1022 sz:5 ] [ addr:1027 sz:1 ] [ addr:1028 sz:1 ] [ adr:1036 sz:1 ] [ addr:1037 sz:2 ] [ addr:1039 sz:1 ] [ addr:1040 sz:1 ] [ addr:108 sz:3 ] [ addr:1051 sz:6 ] [ addr:1057 sz:1 ] [ addr:1058 sz:1 ] [ addr:1059 sz2 ] [ addr:1071 sz:6 ] [ addr:1077 sz:2 ] [ addr:1079 sz:1 ] [ addr:1080 sz:1 ] addr:1096 sz:1 ] [ addr:1097 sz:1 ] [ addr:1098 sz:2 ]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started