The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
* [TUHS] In V6 exit(): wakeup(&proc[1])) unnecessary?
@ 2002-12-22 23:01 Wolfgang Helbig
  0 siblings, 0 replies; 3+ messages in thread
From: Wolfgang Helbig @ 2002-12-22 23:01 UTC (permalink / raw)


>>When a process terminates (in sys1.c/exit()), it explicitly wakes up
>>the init process. In light of the fact, that every process has a parent,
>>this extra wakeup(&proc[1]) seems unnecessary.
>
>I believe this is meant to handle the case where a process exits
>without having called wait() on its children.
>
>Imagine two processes, A and B, where A is B's parent and A's parent
>is some process other than init.  B calls exit(), becomes a zombie,
>and awakens A.  Some time later, A calls exit() without ever having
>called wait().  This will cause B to become a child of init, and as B
>is a zombie, init should awaken so that B can die.  However, A might
>have any number of zombie children, and it would be redundant to call
>wakeup(&proc[1]) for each one.  Therefore, the wakeup call to init is
>done up front, whether it is needed or not.  This does result in some
>unnecessary wakeup calls but on the whole it seems a good tradeoff for
>code simplicity.

Oh, I see! So the condition to wakeup init would be
	"Do I have any zombie children"?
The code as it is is simpler. But harder to understand.
Thank you very much for your help!

Greetings

Wolfgang Helbig




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [TUHS] In V6 exit(): wakeup(&proc[1])) unnecessary?
  2002-12-22 11:15 Wolfgang Helbig
@ 2002-12-22 19:00 ` Mirian Crzig Lennox
  0 siblings, 0 replies; 3+ messages in thread
From: Mirian Crzig Lennox @ 2002-12-22 19:00 UTC (permalink / raw)


On Sun, 22 Dec 2002 12:15:01 +0100 (MET), Wolfgang Helbig <helbig at Informatik.BA-Stuttgart.DE> wrote:
>
>When a process terminates (in sys1.c/exit()), it explicitly wakes up
>the init process. In light of the fact, that every process has a parent,
>this extra wakeup(&proc[1]) seems unnecessary.

I believe this is meant to handle the case where a process exits
without having called wait() on its children.

Imagine two processes, A and B, where A is B's parent and A's parent
is some process other than init.  B calls exit(), becomes a zombie,
and awakens A.  Some time later, A calls exit() without ever having
called wait().  This will cause B to become a child of init, and as B
is a zombie, init should awaken so that B can die.  However, A might
have any number of zombie children, and it would be redundant to call
wakeup(&proc[1]) for each one.  Therefore, the wakeup call to init is
done up front, whether it is needed or not.  This does result in some
unnecessary wakeup calls but on the whole it seems a good tradeoff for
code simplicity.

>Furthermore, the "goto loop:" at the end of exit() will never be
>executed.

This seems to be correct.  I can't think of any normal sequence of
events which could result in an exiting process having no parent in
the process table.

--Mirian



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [TUHS] In V6 exit(): wakeup(&proc[1])) unnecessary?
@ 2002-12-22 11:15 Wolfgang Helbig
  2002-12-22 19:00 ` Mirian Crzig Lennox
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Helbig @ 2002-12-22 11:15 UTC (permalink / raw)


Hi,
encouraged by the profound answers I thankfully recieved to my previous
question about the Unix V6 kernel, here is another one:

When a process terminates (in sys1.c/exit()), it explicitly wakes up
the init process. In light of the fact, that every process has a parent,
this extra wakeup(&proc[1]) seems unnecessary. Furthermore, the "goto loop:"
at the end of exit() will never be executed.

So is this just defensive programming, or did I miss something?

Greetings,

Wolfgang Helbig




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-12-22 23:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-22 23:01 [TUHS] In V6 exit(): wakeup(&proc[1])) unnecessary? Wolfgang Helbig
  -- strict thread matches above, loose matches on Subject: below --
2002-12-22 11:15 Wolfgang Helbig
2002-12-22 19:00 ` Mirian Crzig Lennox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).