linux - Question about zombie processess and threads -
i had these questions in mind since reading new topics on processes , threads. glad if me out.
1) happens if thread marked uncancelable, , process killed inside of critical section?
2) have main thread program known operating system? mean operating system give first thread of program beneficial rights or something?
3) when kill process , threads not joind, become zombies?
first, don't kill or cancel threads, ask them kill themselves. if kill thread outside never know side effects - variables, state of synchronization primitives, etc.- leave behind. if find necessary 1 thread terminate have problematic thread check switch, catch signal, whatever, , clean state before exiting itself.
1) if uncancelable mean detached, same joined thread. don't know mess leaving behind if blindly killing it.
2) application level viewpoint primary thing if main thread exits() or returns() going take down other threads it. if main thread terminates pthread_exit() remaining threads continue on.
3) process thread retain resources until reaped (joined) or program ends, unless run detached.
re note: threads don't share stack each have own. see clone() info on thread creation.
Comments
Post a Comment