Instructor: Dr. Aditya Nigam
Name | Roll No. | |
---|---|---|
A | Ashutosh Sharma | B18010 |
B | Anuj Goel | B18161 |
C | Om Pandey | B18182 |
Assignment problem sheet: Assignment Questions
gcc version: 9.3
Libraries used-
Q1: Creating a shell.
- #include <sys/wait.h>
- #include <sys/types.h>
- #include <unistd.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <dirent.h>
Q2: Dining students problem
- #include <pthread.h>
- #include <stdio.h>
- #include <unistd.h>
- #include <time.h>
- #include <stdlib.h>
Q3: Matrix Multiplication
- #include<bits/stdc++.h>
- #include<pthread.h>
- #include<time.h>
- #include
- #include<stdio.h>
- #include<stdlib.h>
In this question we have to create a shell which supports the following commands:
- clr: To clear the screen.
- pause: To pause operations of the shell until ENTER is pressed.
- help: To show the help menu.
- quit / Ctrl+D: To quit the shell.
- history: To print all the previous commands used in the shell.
- cd : To move to . If the directory is not present it will out current address.
- dir : To list the contents of .
- environ: To print environment variables of bash and current shell.
- echo : To print on screen.
- Add shell environment variables to it.
- Shell can take commands from a batchfile.
Steps to run the shell:
- Enter the Q1 folder.
- Type "make" on terminal.
- Then type "./shell" on terminal. or type "./shell " if you have a batch-file.
- The shell is running.
This problem is similar to dining philosphers problem but it has the following states: Use threads with locks to simulate the students eat-think lifecycle. There are 4 states for each student:
- Waiting for Spoons
- One spoon acquired.
- Both spoons acquired and Eating (20 seconds)
- Thinking (< 2 seconds)
Steps to run the program:
- Enter the Q2 folder.
- Type make on terminal.
- Then type "./prog" on terminal.
- The program is running and it will output the initial states of all students and when state od any student changes.
Write a sequential program to multiply two square matrices. Initialize the matrices with any random values. The size of matrix (n) should be taken as command line argument. Now write a parallel program using threads to do the same. Run both programs for different values of n (n=1 to at least 3000) and make proper log of respective running time.
Input n = size of the square matrix
Output Create a report which includes the graph of input size (n) vs running times for both programs. Run each program at least 5 times and use average running time for analysis. Discuss your inferences.
Steps to run the program:
- Enter the Q3 folder.
- Type make on terminal.
- Then type "./simp " on terminal for simple multiplication.
- Then type "./base " on terminal for parallel multiplication.