Assignemnt OS
Assignemnt OS
Question No 1. Marks: 10
CLO: <2>; Bloom Taxonomy Level: < Analyzing >
In the Process State diagram there is only one arrow going into the Running
state, but several going out of it, why?
Question No 2. Marks: 10
CLO: <2>; Bloom Taxonomy Level: < Analyzing >
Explain the role of the init (or systemd) process on UNIX and Linux
systems in regard to process termination.
c) Using the program given below, identify the values of pid at lines A, B,
C, and D. (Assume that the actual pids of the parent and child are 2600
and 2603, respectively.)
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
int main()
{
pid t pid, pid1;
/* fork a child process */
pid = fork();
if (pid < 0) { /* error occurred */
fprintf(stderr, "Fork Failed");
return 1;
}
else
if (pid == 0) { /* child process */
pid1 = getpid();
printf("child: pid = %d",pid); /* A */
printf("child: pid1 = %d",pid1); /* B */
}
else { /* parent process */
pid1 = getpid();
printf("parent: pid = %d",pid); /* C */
printf("parent: pid1 = %d",pid1); /* D */
wait(NULL);
}
return 0;
}