Question
Create 5 small awk programs: count_allocs.awk Script should handle tests like: awk -f count_allocs.awk ../malloc-out.txt > temp.txt diff -w temp.txt test1.txt > diffs.txt freesize.awk Script
Create 5 small awk programs:
- count_allocs.awk
- Script should handle tests like:
- awk -f count_allocs.awk ../malloc-out.txt > temp.txt
- diff -w temp.txt test1.txt > diffs.txt
- Script should handle tests like:
- freesize.awk
- Script should handle tests like:
- awk -f freesize.awk ../malloc-out.txt | head -100 | awk '{sum += $1}END{print sum}' > temp.txt
- awk -f freesize.awk ../malloc-out.txt | wc -l >> temp.txt
- Script should handle tests like:
- list_sizes.awk
- Script should handle tests like:
- awk -f list_sizes.awk ../malloc-out.txt | head -20 | tail -1 > temp.txt
- diff -w temp.txt test1.txt > diffs.txt
- Script should handle tests like:
- num_bytes.awk
- Script should handle tests like:
- awk -f num_bytes.awk ../malloc-out.txt | head -100 | awk '{sum += $1}END{print sum}' > temp.txt
- diff -w temp.txt test1.txt > diffs.txt
- Script should handle tests like:
- succ_reqs.awk
- Script should handle tests like:
- awk -f succ_reqs.awk ../malloc-out.txt | head -10 | tail -1 > temp.txt
- diff -w temp.txt test1.txt > diffs.txt
- Script should handle tests like:
- Write these awk programs and submit them as described below. Note: the five programs will be tested on simulator output: malloc.txt.
Heres some of malloc.txt simulator output that will be tested with each of the five scripts:
ptr[403] = Alloc(3) returned 1001 (searched 45 elements)
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 ]
DIRECTIONS:
- The idea is that the operating system keeps track of memory that it can provide to processes. The processes make Alloc() calls to allocate memory, and Free() calls to release memory. For example, a process calls Alloc(5) to get 5 bytes of memory.
- The operating system keeps track of free memory in a list, called the free list. The free list contains chunks of free memory. Each line above that starts with Free List is showing the number of elements in the free list, followed by details about each element. Each element represents a chunk of available memory, with values giving the beginning address of the chunk, and the number of bytes in the chunk.
- In the first Free List line above, the free list has 3 elements. The first element of the list shows 1 byte available at address 1000; the second elements shows 2 bytes available at address 1006, etc.
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