Question: QUESTION 5 How does a process know after a call to fork() whether it is the child or the parent? It attempts to modify some

QUESTION 5

  1. How does a process know after a call to fork() whether it is the child or the parent?

It attempts to modify some global variable (say, errno). If the modification fails, it is the child.

It calls the functions getpid() (get process ID) and getppid() (get parent process ID) and compares the returned IDs. If its own ID is larger - then it is the child.

It checks if it owns any open files (aside from stdin, stdout, and stderr). If it does, it is the parent.

It checks if fork() returns a 0 (in the child) or not (in the parent).

QUESTION 6

  1. Which transition in the process state transition diagram is not possible?

Ready -> Terminated

Waiting/Blocked -> Ready

Running -> Terminated

Ready -> Waiting/Blocked

QUESTION 7

  1. Which code fragment correctly programs the timer to expire once after 15 seconds of process running time? Note that the process running time advances only when the process runs. (Read man setitimer before answering the question.)

struct itimerval {{15,0}, {15,0}} ti; setitimer(ITIMER_VIRTUAL, &ti, NULL);

struct itimerval {{15,0}, {0,0}} ti; setitimer(ITIMER_REAL, NULL, &ti);

struct itimerval {{0,0}, {15,0}} ti; setitimer(ITIMER_REAL, &ti, &ti);

struct itimerval {{0,0}, {0,15000000}} ti; setitimer(ITIMER_VIRTUAL, &ti, NULL);

QUESTION 8

  1. What action is not possible when a blocked (waiting) process is awaken? (Check one answer.)

It is blocked again.

It becomes ready and waits for the CPU.

It is immediately scheduled for execution (at the expense of some other process).

It is terminated by the parent process or some other process that has control over it.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!