Starting from:

$29.99

Computer Operating Systems Assignment 1

BLG312E – Computer Operating Systems
Assignment 1
Q1: Please answer the following questions for the given code below.
a) How many processes will be created?
b) How many `c` variable will be generated?
c) What are the values stored inside `c` variables for each process just before their termination?
int main(int argc, char* argv[])
{
int c = 0;
int child = fork();
c++;
if(child == 0)
{
 child = fork();
 c += 2;
 if(child) c = c*3;
}
else
{
c += 4;
fork();
}
return 0;
}
Q2:
Please write, compile and run the C program, which creates the process hierarchy given below.
Assuming the hierarchy level of the main process as 1, your program should generate an output
listing the identification and level information for every process as <PID, Children_PID(s), level>.
Page 1 of 2
Submission Deadline: 15.03.2019
Important notes:
• You are expected to work individually on this homework. All forms of collaboration are
discouraged and will be treated as plagiarism. This includes actions such as, but not limited
to, submitting the work of others as one's own (even if in part and even with modifications)
and copy/pasting from other resources (including Internet resources) even with proper
reference. Such offenses are reported to the administration for disciplinary measures. All
parties involved in the act will be treated equally.

• You should submit your homework through Ninova system. Late submissions are not
accepted.
• Your code must be written in C, and should be compiled and run on ITU’s Linux Server
(you can access it through SSH) using gcc. Your code must compile without any errors;
otherwise, you may get a grade of zero on the assignment.
Submission Details:
 You should submit two files through Ninova: (i) C source file of your implementation for
Q2, (ii) report (pdf file) containing your answers to the questions and necessary
instructions for compiling and running your program.
 If you have further questions about the assignment, you may contact the course assistant
(unlut@itu.edu.tr)
Page 2 of 2

More products