0
$\begingroup$

I was studying for an exam when I stumbled across this true or false statement:

In a system of 7 states diagram, a process could switch from ready state to exit state directly.

The answer to this question was "True".

After some digging into books, I found this:

Ready -> Exit: For clarity, this transition is not shown on the state diagram. In some systems, a parent may terminate a child process at any time. Also, if a parent terminates, all child processes associated with that parent may be terminated.

That is an excerpt from Stallings 8th edition, page 119.

I don't understand how a process that never happens to execute is able to terminate. Could someone explain to me how is this done?

$\endgroup$

1 Answer 1

1
$\begingroup$

Imagine you have the following code in the parent:

child = create_child()
terminate(child)

Now, lets say that the scheduler decided to let the parent run one line only. Then, the child is created, but is yet to execute any code (its in the ready state, as you called it).

Now, there are two options:

  1. The scheduler decides to let the child run some code. In this case, the child goes through an "intermediate" state.

  2. The scheduler decides to let the parent run another line of code. In this case, the child will be terminated, but it never ran any code (since the scheduler didn't let it to). So, in this case the child process directly transitioned from ready to exit without executing at all.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.