Death of a process

OpenSource For You - - FOR U & ME -

It’s na­ture’s rule that no one can live for­ever. So, un­for­tu­nately, pro­cesses also have to die. A process dies by it­self by call­ing exit() sys­tem call. This is how it self­de­structs. Pro­cesses can also die from a re­ceived sig­nal or ex­cep­tion, which they can­not han­dle. Exit() then calls do_ exit(), which calls ex­it_mm(), ex­it_sem(), ex­it_­files() and ex­it_ fs(), to re­lease mm_struct, to de-queue pro­cesses wait­ing for the semaphore, to decre­ment count of us­age of file de­scrip­tors and file sys­tem data, re­spec­tively. It also calls sched­ule() so that the next process can be sched­uled.

With this, all re­sources are re­leased ex­cept the ker­nel stack, task_struct and thread­_info. That means the process is in the zom­bie state. Now it’s the re­spon­si­bil­ity of the par­ent process to in­form the ker­nel that its child is not re­quired; then the ker­nel re­moves the process com­pletely by call­ing re­lease_­task(), which again calls put_­task_struct() to free the pages con­tain­ing the process’ ker­nel stack and thread­_info struc­ture and deal­lo­cate the slab cache con­tain­ing the task_struct.

Newspapers in English

Newspapers from India

© PressReader. All rights reserved.