Lab 3 - The Shell, System Calls and IPC

In this lab, you will write a small program to illustrate the use of multiple processes and pipes in a shell utility. You will be required to submit the code you have written as a tar file.

Lab Material

  1. Slides
  2. Materials

Assignment

Write a program to simulate how the shell interprets the command:

find $1 -name '*'.[h] | xargs grep -c $2 | sort -t : +1.0 -2.0 --numeric --reverse | head --lines=$3

This command will search through the directory given by the first argument for files ending in .h and return the N files (where N is the third argument) which contain the most occurrences of the string given by the second argument. You can use the lab's Makefile to run a bash script with this command:

make find

You can use the finder.c file in the lab's archive as starter code for your program. When you have finished the program, use the build target in the lab's Makefile to compile it. The output of the correct program will match with the output of the finder.sh script which is also present in the lab's archive. You can use the

make test
target in the lab's Makefile to check it against the expected output.


Submission

The total grade for this lab will be awarded based on the submission of your code and your quiz answers and demo. You should submit the following file through canvas:

<STUDENT_ID>-ipc-lab.tar.gz
  1. 75% (Lab submission) - Your submission on the canvas for this lab
  2. 10% (Quiz) - A short quiz about IPC will be open on the following week during the lab hours
  3. 15% (Demo) - A quick demo of your submission will be taken on the following week during the lab hours

Please ensure that all the changes you have implemented in this lab are limited to the finder.c file. Please make sure to replace the "XXXXXXX"s in the Makefile with your Student ID. You can use the archive target in the Lab's Makefile to package the deliverable.





< Back to the Lab Home Page