Operating System Processes and CPU Scheduling
Operating System Processes and CPU Scheduling
• Stack
contains the temporary data such as method/function
parameters, return address and local variables.
• Heap
This is dynamically allocated memory to a process during its
run time.
• Text
This includes the value of Program Counter and the
contents of the processor's registers.
• Data
This section contains the global and static variables.
Process Life Cycle
• New: This is the initial state when a process is first
started/created.
• Ready: In a ready state, the process should be
loaded into the primary memory, which is ready for
execution.
• Waiting: The process is waiting for the allocation of
CPU time and other resources for execution.
• Running: The process is an execution state.
• Terminated: Terminated state specifies the time
when a process is terminated
• After completing every step, all the resources are used by
a process, and memory becomes free.
Process Control Block(PCB)
Suspend ready
Suspend wait
Schedulers
Output:
hello
hello
Operation on process
Process termination
• A process terminates when it finishes executing its final
statement and asks the operating system to delete it by
using the exit () system call.
• At that point, the process may return a status value
(typically an integer) to its parent process (via the wait()
system call).
• All the resources of the process—including physical and
virtual memory, open files, and I/O buffers—are
deallocated by the operating system.
• Termination can occur in other circumstances
as well.
• A process can cause the termination of another
process via an appropriate system call.
• Usually, such a system call can be invoked only
by the parent of the process that is to be
terminated.
• Otherwise users could arbitrarily kill each
others job.
• A parent may terminate the execution of one of its
children for a variety of reasons:
• The child has exceeded its usage of some of the
resources that it has been allocated.
• The task assigned to the child is no longer required.
(If parent doesn’t required that task)
• The parent is exiting, and the operating system
does not allow a child to continue if its parent
terminates.
Cooperating Process
• Modularity:
dividing complicated tasks into smaller subtasks.
leads to faster and more efficient completion.
• Information Sharing:
access to the same files.
processes can access the files in parallel to each
other.
• Computation Speedup:
Subtasks of a single task can be performed in
parallel .
increases the computation speedup .
• Convenience:
individual user may work on many tasks at
the same time.
For instance, a user may be editing, printing,
and compiling in parallel.
Methods of Cooperation