Spring 2024 - CS604P - 1
Spring 2024 - CS604P - 1
Please carefully read the following instructions before attempting the assignment.
You should consult the recommended books to clarify your concepts, as handouts are insufficient.
Assignment Submission:
You are supposed to submit your assignment in Doc or Docx format.
Any other formats, such as scanned images, PDF, zip, rar, ppt, and BMP, will not be accepted.
You are required to send the Screenshot and C code of Question No. 1 in the same Word file.
Furthermore, Linux commands of Question No. 2 should also be pasted in the same Word file.
Assignment No. 1 covers Labs 1 to Labs 3
OBJECTIVE
The objective of this assignment is to provide hands-on experience in the:
Inter-Process Communication through the pipe System call
Linux File/Directory management commands.
System calls and their usage in Linux
NOTE
No assignment will be accepted after the due date via email in any case (whether it is due to load
shedding or internet malfunctioning, etc.). Hence, refrain from uploading assignments within the
last hour of the deadline. It is recommended that the solution file be uploaded at least two days
before its closing date.
Please consult your instructor before the deadline if you find any mistake or confusion in the
assignment (Question statement). After the deadline, no queries will be entertained in this
regard.
You are required to describe how the following code created in the C program works.
Execute the program in C first, then determine how it works from its output. Also, attach
screenshots of the output.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
int main() {
int pipefd[2];
pid_t pid;
char buffer[BUFFER_SIZE];
int nbytes;
// Create pipe
if (pipe(pipefd) == -1) {
perror("pipe");
exit(EXIT_FAILURE);
}
if (pid == -1) {
perror("fork");
exit(EXIT_FAILURE);
}
return 0;
}
Questions No 02 5 marks
In the following table, write the details for the given Linux commands.
Note: If you have installed the Virtual Box, you can take the Screenshot as follows. Go to the
view menu and click on Take Screenshot as follows.
See the following link for the installation of Virtual Box and Ubuntu (Linux) on your system.
https://vulms.vu.edu.pk/CourseResources/OpenFile.aspx?
File=tutorial_for_installing_virtualbox_and_ubuntu.mp4
See the following link installing gcc and compiling and runnings your first program in Linux.
https://vulms.vu.edu.pk/CourseResources/OpenFile.aspx?File=How%20to%20install%20gcc
%20on%20Ubuntu%20and%20compile%20a%20C%20program.mp4
The End