CS3500 Lab 2: Shell Scripting, Processes and Threads


Category: You will Instantly receive a download link for .zip solution file upon Payment


5/5 - (1 vote)

1. Write a shell script to search for the file ‘Assignment1_data.txt’ and read its content. Find
the top 3 most occurring unique words in it along with its count.
3 marks

2. Write a shell script to sort an array using merge sort. 3 marks

3. A pipe is a method to pass information from one process to another process. It offers only
one way communication and the passed information is held by system until it is read by the
receiving process.

Write a C/C++ program to read a string from the user. Create a child
process using fork and form a pipe between the parent and child process. The child process
should write the string from one end of the pipe and the parent process read the string
from the other end of the pipe.


https://man7.org/linux/man-pages/man2/pipe.2.html 5 marks

4. Searching Array using Threads

Given a large sized integer array arr, a number N and an integer ‘element’. Write a
multithreaded program that works as follows:
The array is divided into two sub lists of equal size. Create two threads called Sorting
Threads – that sorts the first and second half of the array respectively. You are free to
choose any sorting algorithm. A third thread called Merger Thread is merge the two sorted
arrays into a single array.

The sorted array is then divided into N parts and N separate thread search and count
numbers which are multiple of element in the sub arrays and returns the count. Print the
total number of elements present in the array.
The implementation will use multiple threads using the Linux pthreads API. The
implementation will be done in Linux/C/C++ platform.
6 marks