[Ilugc] [OT] OS concepts -Threads

  • From: peevee.chaitanya@xxxxxxxxx (peevee)
  • Date: Sun Sep 24 15:11:52 2006


Wonder why you marked it OT.

If a process exits, the threads also die. Remember a process is defined by
context and the most important aspect is its address space. A context has
several components like contents of Ax,Bx,Cx,Dx regs if it is x86, signal
mask, state(running,sleeping etc.) , stack etc...

Now, each thread has a lightweight context associated with it, the most
important thing here being its stack.

So when a process is divided into threads , basically the global process
context is split into diff threads. All of them map to the same address
space.
If you try to access memory outside the bounds of the address space
allocated to the process, a hardware trap is generated by the MMU.

Now, the moment a process dies, its address space is removed from the MMU
and all page tables cleared of its existence.

So there is no room for any thread to run. Essentially I mean that
thread's context has to be stored somewhere, if it does not have an address
space mapping where will it go?

Remember I am only talking of user space threading. Kernel threading is a
different ballgame.


Ya, I am also on the same thoughts initially,
but when I thought about Unix/Linux threads, Unix clones a process to make
thread, and this may share memory or it may not share memory,
in this case, if the parent thread (process) is killed, will the cloned
(thread/process) continue to exist?
I remember reading somewhere that in Solaris, even if the parent
process/thread is killed , the child process/thread can run.
Even I am not sure if this parent child process is the same as parent child
thread.

Please throw some light on my doubts.
Regards

peevee

Other related posts: