• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Fork and exec program

 
Ranch Hand
Posts: 103
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey. I need to learn about forks and execs for school. I spent whole day on it and still does not understand it fully.
Here is exercise from the test.
Could someone write step by step what is program doing?
I need process tree for it.


Please, I need your help really!

 
must Janik
Ranch Hand
Posts: 103
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see that img does not work.
I attached it then.
....png
[Thumbnail for ....png]
 
author
Posts: 23840
141
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

IMHO, you should explain what you are confused with... The concept of fork and exec is really straightforward, and it is just two function calls -- there really isn't much to explain. Perhaps if you explain what you are confuse with, we can target that.

Henry
 
must Janik
Ranch Hand
Posts: 103
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey. More or less I know what is going on the problem. But I've got problem with process tree. Cant draw it. Could you help?
 
must Janik
Ranch Hand
Posts: 103
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More or less I know what is going on with the program*.
 
Henry Wong
author
Posts: 23840
141
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Well, I guess I can explain this line...



As it is silly, and no real application will do this... okay, the program hits the fork() in the condition, and becomes two processes.

The child process with get a zero result and goes to the next line. The parent process get the PID of the child, which of course, is not zero, and ... execute the second fork(). This means that the parent process becomes two process again. Both of these two processes will go to the next line.

At this point, you have three processes, which will executes the next line... the rest you should be able to figure out yourself....

Henry
 
must Janik
Ranch Hand
Posts: 103
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ye. I got it! That was the problem that I struggle before.
For now, I need to draw process tree. Dont know how it should like.
 
Henry Wong
author
Posts: 23840
141
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

must Janik wrote:I see that img does not work.



The img tag requires an URL to an image file. In your case, it is to a html file.

Henry
 
must Janik
Ranch Hand
Posts: 103
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yea. Okey got it. What about this process tree?
 
Henry Wong
author
Posts: 23840
141
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

must Janik wrote:Yea. Okey got it. What about this process tree?



It should be easy to go from the description to a diagram that puts the description in graph form. Did you work out the rest? If not, tell us what you did so far. If so, show us what you draw out so far. And of course why.

Henry
 
must Janik
Ranch Hand
Posts: 103
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't done anything like this, yet. So I do now know how it even looks like.
 
I'm not dead! I feel happy! I'd like to go for a walk! I'll even read a tiny ad:
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!