Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write an awk script freesize.awk that gets the size of the free list after every Free or Alloc operation. Your program should act like this:

write an awk script freesize.awk that gets the size of the free list after every Free or Alloc operation. Your program should act like this:

$ awk -f freesize.awk malloc-out.txt | wc -l

1000

$ awk -f freesize.awk malloc-out.txt | tail -5

41

42

41

42

43

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 num_bytes.awk that records the number of bytes requested in each alloc call. Your program should act like this:

$ awk -f num_bytes.awk malloc-out.txt | wc -l

554

$ awk -f num_bytes.awk malloc-out.txt | head -200 | tail -5

1

10

3

10

6

write an awk script succ_reqs.awk that prints the number of bytes requested, and then a 1 or a 0 depending on whether the request was successful. Your program should act like this:

$ awk -f succ_reqs.awk malloc-out.txt | tail -5

8 0

3 1

5 1

10 0

6 1

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

Hint: you can use printf and loops in awk programs. In both cases the syntax is similar to C. Here is an example of an awk program with a loop:

{ n = $1

for (i=0; i < n; i++) {

printf(%s , $(2+i))

}

}

This program assigns the value in field 1 to variable n, then prints fields 2, 3, 4 up to field 2 + n - 1.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions