OS Assignment - 2
OS Assignment - 2
Assignment 2
INSTRUCTIONS:
You are required to complete the tasks according to the following instructions.
• At the start of each task, in every program, you are required to print PROCESS ID of the process,
your NAME, ROLL NUMBER and SECTION.
• You must attach the complete screenshots of the output.
• You must write code alongside the screenshot.
• Illustrate the code reason where necessary.
TASKS:
1. Copy the following code, Remove the errors, if any and compile it using command:
• gcc TestPogram.c -o test
TestProgram.c
#include<stdio.h>
#include<unistd.h>
int main(int argc, char *argv[])
{
printf(“\nMy Process ID is: %d\n”, getpid());
printf(“I am Called by exec Process”);
printf(“\nGOING BACK TO MAIN…?????”)
}
After executing the above code, Create a new C Program and copy the following code, Remove the errors,
if any and compile it using command:
gcc ExecProgram.c -o exec
ExecProgram.c
#include<stdio.h>
#include<unistd.h>
int main(int argc, char *argv[])
{
printf(“Process ID: %d\n”, getpid());
printf(“Main Thread..\nExecuting other program”);
char *args[] = { “./test”, ”Hello” , “From”, “Main”,
NULL};
execvp(args[0], args);
printf(“\nRETURNED TO MAIN…?????”);
}
Analyze the output of ./exec and answer the following questions:
3. A symbolic or soft link is an actual link to the original file, whereas a hard link is a mirror copy of
the original file. If you delete the original file, the soft link has no value, because it points to a non-
existent file. But in the case of hard link, it is entirely opposite. Even if you delete the original file, the
hard link will still has the data of the original file. Because hard link acts as a mirror copy of the original
file. Symbolic Link and Hard links. Write Pros and Cons of Soft and Hard links. Also, write a program
that reads file name, retrieve all the information (status) about that file and then display the SIZE and
PERMISSIONS granted to the file.
• Attach the screenshot of output and code.
NOTE:
• Copy all the attached files (.docx, .c) in a folder. The name of the folder must be like
Section-Roll No. (e.g. E1-0026-BSCS-13).
• You must submit assignment till 22-06-2020 before 02:00 pm. Late submissions will be
marked as ZERO.
• Do not copy anything from others. Plagiarized content will also be marked as ZERO.