Day 26 multiprocess

Day 26

Process State

Created

Running

Terminated

Blocked

Waiting/Ready

Zombie process

A zombie process is a process whose execution is completed but it still has an entry in the process table. Zombie processes usually occur for child processes, as the parent process still needs to read its child's exit status

How do you kill a zombie process?

A zombie is already dead, so you cannot kill it. To clean up a zombie, it must be waited on by its parent, so killing the parent should work to eliminate the zombie. (After the parent dies, the zombie will be inherited by pid 1, which will wait on it and clear its entry in the process table.

Is it bad to have zombie processes on your system?

The presence of zombie processes also indicates an operating system bug if their parent processes are not running anymore. This is not a serious problem if there are a few zombie processes but under heavier loads, this can create issues for the system.

Orphan process

An orphan process is a computer process whose parent process has finished or terminated, though it remains running itself.

Daemon process

A daemon process is a background process that is not under the direct control of the user. This process is usually started when the system is bootstrapped and it terminated with the system shut down. Usually the parent process of the daemon process is the init process

Mutex in Python

A mutex is an object enabling threads of execution to protect critical sections of code from reentrancy or to temporarily protect critical data sets from being updated by other threads. The term “mutex” derives from the notion of mutual exclusion

How to use Mutex in python

mutex = threading.Lock()

mutex.acquire()
print("mutex is now locked")
OUTPUT
# mutex is now locked

mutex.release()
print("mutex is now unlocked")
OUTPUT
# mutex is now unlocked

 

posted @ 2021-01-20 14:24  fengshili0721  阅读(77)  评论(0编辑  收藏  举报