All of lore.kernel.org
 help / color / mirror / Atom feed
* working of fork and exec
@ 2013-01-17 17:02 Niroj Pokhrel
  2013-01-17 17:59 ` Mulyadi Santosa
  2013-01-18 16:39 ` Jonathan Neuschäfer
  0 siblings, 2 replies; 6+ messages in thread
From: Niroj Pokhrel @ 2013-01-17 17:02 UTC (permalink / raw)
  To: kernelnewbies

Hi all,
I have been using fork and exec for sometime. But I have no idea about what
are the things done by the kernel when we fork or exec and how things work.
How the kernel load new program and what all things are done ....... Can
anybody please explain me this ? Thank you in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130117/cf1ef3e0/attachment.html 

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

* working of fork and exec
  2013-01-17 17:02 working of fork and exec Niroj Pokhrel
@ 2013-01-17 17:59 ` Mulyadi Santosa
  2013-01-18  2:09   ` Peter Teoh
  2013-01-18 16:39 ` Jonathan Neuschäfer
  1 sibling, 1 reply; 6+ messages in thread
From: Mulyadi Santosa @ 2013-01-17 17:59 UTC (permalink / raw)
  To: kernelnewbies

Hi :)

On Fri, Jan 18, 2013 at 12:02 AM, Niroj Pokhrel <nirojpokhrel@gmail.com> wrote:
> Hi all,
> I have been using fork and exec for sometime. But I have no idea about what
> are the things done by the kernel when we fork or exec and how things work.
> How the kernel load new program and what all things are done ....... Can
> anybody please explain me this ? Thank you in advance.

this is too broad to answer, but in general fork() does:
- preparing new address space
- preparing new task_struct
- doing COW (copy on write), so newly born child initially simply use
parent's pages

in exec() case, instead of COW, you load the target binary. It does so
by the work of loader in user space and ELF interpreter in the kernel
space.

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

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

* working of fork and exec
  2013-01-17 17:59 ` Mulyadi Santosa
@ 2013-01-18  2:09   ` Peter Teoh
  2013-01-18 17:47     ` horseriver
  2013-01-19  2:25     ` Mulyadi Santosa
  0 siblings, 2 replies; 6+ messages in thread
From: Peter Teoh @ 2013-01-18  2:09 UTC (permalink / raw)
  To: kernelnewbies

Hi Mulyadi,

Great to see you again!

Sorry, can I fork on your explanation to explain further about fork?

Yes, "fork" is at the core of process management, scheduling and all that:

http://www.ibm.com/developerworks/linux/library/l-linux-process-management/

a good picture of process splitting up (forking) is here:

http://www.linux-tutorial.info/modules.php?name=MContent&pageid=83

what happened to all the IPC after forking?

http://hzqtc.github.com/2012/07/linux-ipc-with-pipes.html

http://static.usenix.org/event/usenix2000/general/reumann/reumann_html/node9.html

Generally, the last thing u should read is the kernel source code, though
it also has the last word to be said for fork() :-).

On Fri, Jan 18, 2013 at 1:59 AM, Mulyadi Santosa
<mulyadi.santosa@gmail.com>wrote:

> Hi :)
>
> On Fri, Jan 18, 2013 at 12:02 AM, Niroj Pokhrel <nirojpokhrel@gmail.com>
> wrote:
> > Hi all,
> > I have been using fork and exec for sometime. But I have no idea about
> what
> > are the things done by the kernel when we fork or exec and how things
> work.
> > How the kernel load new program and what all things are done ....... Can
> > anybody please explain me this ? Thank you in advance.
>
> this is too broad to answer, but in general fork() does:
> - preparing new address space
> - preparing new task_struct
> - doing COW (copy on write), so newly born child initially simply use
> parent's pages
>
> in exec() case, instead of COW, you load the target binary. It does so
> by the work of loader in user space and ELF interpreter in the kernel
> space.
>
> --
> regards,
>
> Mulyadi Santosa
> Freelance Linux trainer and consultant
>
> blog: the-hydra.blogspot.com
> training: mulyaditraining.blogspot.com
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>



-- 
Regards,
Peter Teoh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130118/b4e82847/attachment.html 

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

* working of fork and exec
  2013-01-17 17:02 working of fork and exec Niroj Pokhrel
  2013-01-17 17:59 ` Mulyadi Santosa
@ 2013-01-18 16:39 ` Jonathan Neuschäfer
  1 sibling, 0 replies; 6+ messages in thread
From: Jonathan Neuschäfer @ 2013-01-18 16:39 UTC (permalink / raw)
  To: kernelnewbies

On Thu, Jan 17, 2013 at 10:32:45PM +0530, Niroj Pokhrel wrote:
> Hi all,
> I have been using fork and exec for sometime. But I have no idea about what
> are the things done by the kernel when we fork or exec and how things work.
> How the kernel load new program and what all things are done ....... Can
> anybody please explain me this ? Thank you in advance.

I recommend reading linux-0.12.

Jonathan Neusch?fer

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

* working of fork and exec
  2013-01-18  2:09   ` Peter Teoh
@ 2013-01-18 17:47     ` horseriver
  2013-01-19  2:25     ` Mulyadi Santosa
  1 sibling, 0 replies; 6+ messages in thread
From: horseriver @ 2013-01-18 17:47 UTC (permalink / raw)
  To: kernelnewbies

In my opinion ,  fork and exec is based on independent  task environment for per process ,
which is corresponding to task_struct .

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

* working of fork and exec
  2013-01-18  2:09   ` Peter Teoh
  2013-01-18 17:47     ` horseriver
@ 2013-01-19  2:25     ` Mulyadi Santosa
  1 sibling, 0 replies; 6+ messages in thread
From: Mulyadi Santosa @ 2013-01-19  2:25 UTC (permalink / raw)
  To: kernelnewbies

Hi Peter :)

On Fri, Jan 18, 2013 at 9:09 AM, Peter Teoh <htmldeveloper@gmail.com> wrote:
> Hi Mulyadi,
>
> Great to see you again!

> Sorry, can I fork on your explanation to explain further about fork?

Sure, please fork to fork()

Oh and btw, as always, you give nice reference links...bravo!


-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

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

end of thread, other threads:[~2013-01-19  2:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-17 17:02 working of fork and exec Niroj Pokhrel
2013-01-17 17:59 ` Mulyadi Santosa
2013-01-18  2:09   ` Peter Teoh
2013-01-18 17:47     ` horseriver
2013-01-19  2:25     ` Mulyadi Santosa
2013-01-18 16:39 ` Jonathan Neuschäfer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.