Exercise 9-5.(d)

chw
Neuling
Neuling
Beiträge: 3
Registriert: 9. Aug 2016 11:51

Exercise 9-5.(d)

Beitrag von chw » 9. Aug 2016 12:18

Hello, everyone,

I have a question about the 5.(d) of Exercise 9. In the excise session, the tutor said(according to my notes), when the program is at state S5 during the search, in the cache S6, S3 and S7 will be recorded. Which means the state S7 has been visited twice? How could that happen?

Best regards,
Luo

hsaissi
Neuling
Neuling
Beiträge: 2
Registriert: 26. Okt 2015 10:06

Re: Exercise 9-5.(d)

Beitrag von hsaissi » 18. Aug 2016 10:58

Hi,
when s5 is reached, s7 is not yet marked as a visited state. States are only added to the visited list after the backtracking happens.

Cheers,
Habib

chw
Neuling
Neuling
Beiträge: 3
Registriert: 9. Aug 2016 11:51

Re: Exercise 9-5.(d)

Beitrag von chw » 18. Aug 2016 23:28

Hi, Habib, thanks a lot for your answer, now I got it.

And I have another question, which confused me for the last few weeks. In Midterm, as far as I can remember, there was a question about process pair backup(), what if the Out-Of-Memory Killer kills the process pair directly just before it goes to the waitpid() instruction. And the question is after this happened, whether it is possible that process pair could recover from this situation.

And my personal humble opinion(imagination) is that it's not possible, because the new child has already been killed, but after the successfully executed fork() now the ret=0, but waitpid()=-1. So it will just wait forever until this child "terminates" ,which is not going to happen. Since there's no Einsicht for Midterm exam, so I don't know whether I was right. I'm just quite curious about this question, if you could tell me the right answer, would be great.

Thanks, Cheers.
Luo

Stefan Winter
Mausschubser
Mausschubser
Beiträge: 57
Registriert: 18. Sep 2009 13:37

Re: Exercise 9-5.(d)

Beitrag von Stefan Winter » 19. Aug 2016 10:30

Hi Luo,

you're a bit off the right path here. Maybe this helps: Which process executes the waitpid instruction? Which process is OOM-killed then?

Cheers,
Stefan

chw
Neuling
Neuling
Beiträge: 3
Registriert: 9. Aug 2016 11:51

Re: Exercise 9-5.(d)

Beitrag von chw » 19. Aug 2016 11:54

Hi, Stefan

Thanks for your hints!

So, the backup() process executes the waitpid and OOM killer kills the child(will the value ret be set to -1 if the child is killed?), so the backup() will just run again to fork() another child for the recovery?

Cheers
Luo

Stefan Winter
Mausschubser
Mausschubser
Beiträge: 57
Registriert: 18. Sep 2009 13:37

Re: Exercise 9-5.(d)

Beitrag von Stefan Winter » 19. Aug 2016 13:14

Hi Luo,
chw hat geschrieben:the backup() process executes the waitpid and OOM killer kills the child
that's incorrect. I think you may have some misconception how process creation in the backup function works. Check this out:
http://pubs.opengroup.org/onlinepubs/96 ... /fork.html
Especially pay attention to the meaning of the return value and how this is used in backup function.
The POSIX standard documentation is generally a good place to search if you are not sure about the semantics of system functions. You will also find all details about the behavior of waitpid there.

Cheers,
Stefan

Antworten

Zurück zu „Archiv“