Linux process management(1)

LORY
2 min readFeb 7, 2021

--

Process life cycle

fork and exec

Fork : Create a separate duplicated process (child process memory space copied from parent )

Exec : create a process replace current entire process (replace pid)

creation

All process created from parent process except ‘init’

Init process created by os kernel , id= 1 , which is the root process (systemd)

Subprocess.popen and os.fock in python

subprocess.Popen execute an arbitrary program/command/executable/whatever in its own process.

os.fork only allows you to create a child process that will execute the same script from the exact line in which you called it. As its name suggests, it “simply” forks the current process into 2.

os.fork is only available on Unix, and subprocess.Popen is cross-platfrom.

process scheduler (CFS)

- Pick lowest vuntime task

- Use red-black tree store task (log(n) lookup time),left vruntime node less than right node .so the left most node is the task with least vruntime

process management commands

bg = send stopped process to backgroundcommand & = run process in backgroundctrl+z = stop current process and put to jobsctrl+c = cancel process (remove from jobs)jobs = list all jobsfg %3 = bring 3rd job to fore groundkill — 15 pid = send signal ‘sigterm’kill -9 pid = kill signal ‘sigkill’ to processnice = run command with defined priority (-20 highest, 19 lowest)renice = modify process priority . renice +x 18471

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

LORY
LORY

Written by LORY

A channel which focusing on developer growth and self improvement

No responses yet

Write a response