Process Virtualization
Process Management
This
component deals with the creation, scheduling, and termination of processes. It
includes the process control block (PCB) data
structure for managing process information. The process management component
ensures that processes share CPU time fairly
and efficiently, and it handles process synchronization and communication.
Process management is a crucial
aspect of operating systems that involves the creation,
scheduling, termination, and coordination of processes. A process represents an
executing instance of a computer program, and process management ensures that
multiple processes can run concurrently and share system resources efficiently. Here are the key components and
functions of process management:
Process Creation:
The operating system is responsible for creating new
processes. This can occur in several ways, such as when a user starts an
application or when a parent process spawns a child process. During process creation, the operating system allocates a
unique process identifier (PID) to each process and sets up a separate address
space for the new process, ensuring that each process runs independently.Process States:
Processes
can be in different states
during their lifetime, including:
· New: The process is being created.
· Ready: The process is prepared to run, but the CPU is currently executing another process.
·
Running: The process is currently being
executed by the CPU.
·
Terminated:
The process has finished its
execution and is being removed from the system.
The operating
system maintains a data structure called the Process Control Block (PCB) for
each process. The PCB contains essential information about the process,
including process state, program counter, CPU registers, memory allocation, and
more. The PCB enables the operating system to manage and track processes
efficiently.
Process
management is a fundamental function of operating systems, enabling efficient
multitasking, resource sharing, and overall system stability. It ensures that
multiple processes can execute concurrently without interfering with each other,
creating a seamless
user experience and efficient utilization of system resources.
A Process is a running program. A process is basically a program in execution. The execution of a process must progress in a sequential procedure.
·
Comprising of
a process:
§
Memory (address space)
§
Instructions
§ Data section
· Registers
§
Program counter
§
Stack pointer
·
Process API:
§
These APIs are available on any modern
OS.
·
Create
§
Create a new process to run a program
·
Destroy
§
Halt a runaway
process
·
Wait
§
Wait for a process to stop running
·
Miscellaneous
Control
§
Some kind of method to suspend a process and then
resume it
·
Status
§
Get some status info about a process
Process Creation:
Load a program
code into memory, into the address
space of the process.
·
Programs initially reside
on disk in executable
format.
· OS perform the loading process lazily.
· Loading pieces of code or data only as they are needed during program execution.
1.
The program’s run-time
stack is allocated.
·
Use the stack for local variables, function parameters, and return address.
· Initialize the stack with arguments argc and argvarray of main() function
2.
The program’s heap is
created
· Used for explicitly requested dynamically allocated data.
·
Program request such space by calling malloc()
and free it by calling free().
3.
The OS do some other initialization tasks. input/output (I/O) setup.
·
Each process by default has three open file descriptors.
·
Standard input, output
and error
4.
Start the program running at the entry point, namely
main().
· The OS transfers control of the CPU to the newly- created process.
Process States:
A process can be one of three states.
·
Running: A
process is running
on a processor.
·
Ready: A process is ready to run but for some
reason the OS has chosen not to run it at this given moment.
· Blocked: A process has performed some kind of operation.
· When a process initiates an I/O request to a disk, it becomes blocked and thus some other process can use the processor.
Process State Transition:
Data structures:
·
The OS has some key data structures that track
various relevant pieces of information.
Process list
·
Ready processes
·
Blocked processes
·
Current running process
Register context
·
PCB(Process Control Block)
·
A C-structure that contains information about each process.
Each process has a name; in most systems, that name is a number known as a process ID (PID).
What API does the OS provide to user programs?
·
API = Application Programming Interface=
functions available to write user programs.
·
API provided
by OS is a set of ―system calls‖ –
System call is a function call into
OS code that runs at a higher privilege level of the CPU.
· Sensitive operations (e.g., access to hardware) are allowed only at a higher privilege level – Some ―blocking‖ system calls cause the process to be blocked and de-scheduled (e.g., read from disk)
The fork() system
call is used to create
a new process,
The fork() System Call:
•
Create a new process
•
The newly-created process
has its own copy of the
address
space, registers, and PC.
Fork system call is used for creating a new process, which is called child process, which runs concurrently with the process that makes the fork() call (parent process). After a new child process is created, both processes will execute the next instruction following the fork() system call. A child process uses the same pc (program counter), same CPU registers, same open files which use in the parent process.
It takes no parameters and returns an integer value. Below are different values returned by fork().
Negative Value: creation of a child process was unsuccessful.
Zero: Returned to the newly created child process.
Positive value: Returned to parent or caller. The value
contains process ID of newly created child process.









Comments
Post a Comment