5- Operations on Process
5- Operations on Process
CSC351-Operating System
Week-3 Lecture-5
Semester 5
2
Process concept
►Process States
Preamble ►Queues
(Past lesson ►Schedulers
brief)
init
pid = 1
emacs tcsch
ps
pid = 9204 pid = 4005
pid = 9298
Address space
Child duplicate of parent
Child has a program loaded into it
UNIX examples
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 deallocated by operating system
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);
If no parent waiting (did not invoke wait()) process is a zombie (a zombie
process or defunct process is a process that has completed execution but
still has an entry in the process table)
If parent terminated without invoking wait , process is an orphan
Information sharing:
Since several users may be interested in the same piece of information (for
instance, a shared file) we must provide an environment to allow concurrent users
to access these types of resources.
Modularity:
We may want to construct the system in a modular fashion, dividing the system
functions into separate processes or threads.
Convenience:
Even an individual user may have many tasks on which to work at one time. For
instance, a user may be editing, printing, and compiling in parallel.
Direct Communication
Mailbox sharing
P1, P2, and P3 share mailbox A
P1, sends; P2 and P3 receive
Who gets the message?
Solutions
Allow a link to be associated with at most two processes
Allow only one process at a time to execute a receive operation
Allow the system to select arbitrarily the receiver. Sender is notified who
the receiver was.