9/14/2020
Operations on Process
• Process Creation
– Parent process creates children processes, which,
in turn create other processes, forming a tree of
processes
– Generally, process identified and managed via a
process identifier (pid) init
pid = 1
login kthreadd sshd
pid = 8415 pid = 2 pid = 3028
bash khelper pdflush sshd
pid = 8416 pid = 6 pid = 200 pid = 3610
emacs tcsch
ps
pid = 9204 pid = 4005
pid = 9298
Operations on Process
• Address space
– Child duplicate of parent
– Child has a program loaded into it
• UNIX examples
– fork() system call creates new process
– exec() system call used after a fork() to replace the
process’ memory space with a new program
1
9/14/2020
Operations on Process
– Resource sharing options
• Parent and children share all resources
• Children share subset of parent’s resources
• Parent and child share no resources
– Execution options
• Parent and children execute concurrently
• Parent waits until children terminate
Process Termination
• Process executes last statement and then asks the
operating system to delete it using the exit() system
call.
– Returns status data from child to parent (via wait())
– Process’ resources are de-allocated by operating system
• Parent may terminate the execution of children
processes using the abort() system call. Some
reasons for doing so:
– Child has exceeded allocated resources
– Task assigned to child is no longer required
– The parent is exiting and the operating systems does not
allow a child to continue if its parent terminates
2
9/14/2020
Process Termination
• Some operating systems do not allow child to
exists if its parent has terminated. If a process
terminates, then all its children must also be
terminated.
– cascading termination. All children, grandchildren,
etc. are terminated.
– The termination is initiated by the operating system.
• The parent process may wait for termination of a
child process by using the wait()system call.
The call returns status information and the pid of
the terminated process
pid = wait(&status);
Orphan Process
• Running process whose parent process has finished
or terminated.
• In a Unix-like operating system,
immediately adopted by the init process. called re-
parenting and occurs automatically.
• called an orphan process since the process that
originally created it no longer exists.
• Unintentional Orphan
– when the parent process terminates or crashes.
• Intentional Orphan
– detached from the user’s session and left running in the
background
3
9/14/2020
Daemon Process
• A Daemon process is an intentionally
orphaned process in order to have
a background process.
• syslogd is the daemon that implements the
system logging facility and sshd is a daemon
that services incoming SSH connections.
Zombie Process
• process that has completed execution but hasn’t
been reaped by its parent process.
• As result it holds a process entry in the process
table and the PID.
• When a process ends, all of the memory and
resources associated with it are deallocated so
they can be used by other processes.
• However, the process’s entry in the process table
remains. The parent can read the child’s exit
status by executing the wait system call,
whereupon the zombie is removed.