Question: [AWK Programming] Please help me write this awk script using the three text files given below. Thank You! ----------------------------------------------------------------------- The three text files needed to
[AWK Programming] Please help me write this awk script using the three text files given below. Thank You!
![[AWK Programming] Please help me write this awk script using the three](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f50838dec51_45666f508384f613.jpg)
-----------------------------------------------------------------------
The three text files needed to test the script:
------------------------------------------------------------------------
test1.txt:
sr sr dr dr sw dw
-----------------------------------------------------------------------
test2.txt:
sr sw dw dr
-----------------------------------------------------------------------
test3.txt:
sr dr sw sw dw dw
Write an awk script called check-rwlock.c to check the output of your rwlock.c code provided in the text files given below. The output of rwlock.c contained in the text files is a sequence of lines, each of which is either 'sr', 'dr', 'sw', or 'dw'. "sr" stands for "start read", "dr" for done read, "sw" for start write, and "dw" for done write Your awk script should take as input the output of your rwlock code, and produce as output the following: * the maximum number of concurrently reading threads * the maximum number of concurrently writing threads * whether a read operation ever overlapped with a write operation . whether a write operation ever overlapped with a write operation The basic idea on writing the awk script is to keep counts of the number of current readers and the number of current writers. For example, the number of current writers will increase on a 'sw' line and decrease on a 'dw' line. Here is example output you should get from each text files provided: awk -f check-rwlock.awk test1.txt maxr - 2, maxW1 reader/writer test: PASS writer/writer test: PASS awkf check-rwlock.awk test2.txt maxr - 1, maxW 1 reader/writer test: FAIL writer/writer test: PASS awkf check-rwlock.awk test3.txt maxr 1, maxW 2 reader/writer test: PASS writer/writer test: FAIL Write an awk script called check-rwlock.c to check the output of your rwlock.c code provided in the text files given below. The output of rwlock.c contained in the text files is a sequence of lines, each of which is either 'sr', 'dr', 'sw', or 'dw'. "sr" stands for "start read", "dr" for done read, "sw" for start write, and "dw" for done write Your awk script should take as input the output of your rwlock code, and produce as output the following: * the maximum number of concurrently reading threads * the maximum number of concurrently writing threads * whether a read operation ever overlapped with a write operation . whether a write operation ever overlapped with a write operation The basic idea on writing the awk script is to keep counts of the number of current readers and the number of current writers. For example, the number of current writers will increase on a 'sw' line and decrease on a 'dw' line. Here is example output you should get from each text files provided: awk -f check-rwlock.awk test1.txt maxr - 2, maxW1 reader/writer test: PASS writer/writer test: PASS awkf check-rwlock.awk test2.txt maxr - 1, maxW 1 reader/writer test: FAIL writer/writer test: PASS awkf check-rwlock.awk test3.txt maxr 1, maxW 2 reader/writer test: PASS writer/writer test: FAIL
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
