Luv
Luv

Reputation: 5461

What will happen to thread B if thread A is killed in same process?

Suppose a process spawns a thread A and this thread further spawns a new thread B, now suppose thread A is killed then what will happen to the thread B.

I think if these are KLTs then surely nothing will happen to thread B is killed. And for ULTs also nothing should happen to the thread B

Upvotes: 1

Views: 115

Answers (1)

Florin Stingaciu
Florin Stingaciu

Reputation: 8295

Nothing. What happens during the forking process is that thread B starts by getting a reference to the thread A's page tables (virtual memory reference). As soon as there is any change to these page tables from either A or B, a copy is created (for each page) and given to both of them. In this case B will just inherit all of the page-tables and do its own thing.

Upvotes: 3

Related Questions