Introduction

Process creation is a core function in operating systems enabling multitasking and resource sharing. It involves instantiating a new process with its own execution context and resources. This page details mechanisms, system calls, and associated data structures essential for understanding how processes are generated and managed.

"A process is the unit of work in an operating system. Creating processes efficiently is fundamental to system performance and user experience." -- Abraham Silberschatz

Process Concept

Definition

Process: executing instance of a program. Contains code, data, stack, heap, and system resources.

Process vs Program

Program: passive code on disk. Process: active execution with state and resources.

Process Attributes

Includes PID, state, priority, CPU registers, memory maps, I/O status, and accounting info.

Process Control Block (PCB)

Purpose

PCB: data structure storing process state and context for CPU scheduling and management.

Key Fields

Process ID, Process State, CPU registers, Program Counter, Memory pointers, I/O status, Accounting info.

Role in Creation

PCB initialized during creation, updated throughout process lifetime to track execution status.

PCB FieldDescription
Process ID (PID)Unique identifier for the process
Program CounterAddress of next instruction to execute
CPU RegistersContents of processor registers
Memory Management InfoPointers to code, data, stack segments

Process Creation Overview

Definition

Process creation: instantiation of a new process with its own context and resources.

Reasons to Create Processes

Parallel execution, service provision, resource sharing, user requests, system tasks.

Types of Creation

Parent creates child (fork), system creates service processes, batch job initiation.

System Calls for Creation

fork()

Creates child process by duplicating parent. Both processes continue independently.

exec()

Replaces process memory space with new program. Used after fork for new execution.

spawn()

Creates new process and loads a program in one call (common in Windows).

clone()

Creates process with shared resources (threads). Provides fine-grained control.

System CallDescriptionTypical Use
fork()Duplicate current processUnix process creation
exec()Load new program into processReplace process image
spawn()Create and execute new processWindows process creation
clone()Create process/thread with shared resourcesThread and process control

Process Hierarchy and Relationships

Parent and Child Processes

Parent creates child; child inherits some resources. Parent waits or monitors child.

Process Tree

Hierarchical structure showing ancestor-descendant relationships.

Orphan and Zombie Processes

Orphan: parent terminated before child; adopted by init/system process. Zombie: terminated child waiting for parent cleanup.

Process Creation Steps

Step 1: Allocate PCB

Reserve memory for PCB, assign unique PID.

Step 2: Initialize PCB Fields

Set state to new, initialize CPU context, memory pointers, I/O status.

Step 3: Allocate Memory

Reserve address space, load program code and data segments.

Step 4: Setup Parent-Child Links

Update process tree, set parent PID, create child list entry.

Step 5: Add to Ready Queue

Set process state to ready, enqueue for scheduling.

Algorithm ProcessCreation(parent) Allocate PCB for new process P Assign unique PID to P Initialize PCB fields for P Allocate memory for P’s code, data, stack Set P's parent pointer to parent Insert P into parent’s child list Set P state to READY Enqueue P in ready queue Return PID of Pend Algorithm

Resource Allocation During Creation

Memory Allocation

Allocate separate address space or share memory segments based on process type.

File Descriptor Table

Copy or share file descriptors from parent depending on semantics.

CPU Registers and Stack

Initialize stack pointer, program counter, general purpose registers.

I/O and Device Allocation

Assign or inherit open devices, sockets, and other resources.

Process States During Creation

New State

Process is being created, resources being allocated.

Ready State

Process prepared to run, waiting for CPU allocation.

Running State

Process currently executing on CPU.

Blocked State

Process waiting for I/O or event. Not directly related to creation but may occur after.

Terminated State

Process completed execution or aborted.

StateDescription
NewProcess is being created, initializing data
ReadyProcess ready to be assigned CPU
RunningCurrently executing on CPU
BlockedWaiting for I/O or event
TerminatedExecution finished or aborted

Process Creation in Unix/Linux

fork() System Call

Duplicates calling process, creating child with identical memory and resources.

exec() System Call

Replaces process memory with new program, used post-fork for new execution.

wait() System Call

Parent waits for child termination, preventing zombie processes.

Copy-on-Write Optimization

Memory pages shared until modification, reducing overhead of fork.

pid = fork()if pid == 0 then exec("/bin/program")else wait(pid)end if

Process Creation in Windows

CreateProcess() API

Single call to create new process and primary thread, specifying executable and parameters.

Process and Thread Model

Process contains one or more threads; creation involves allocating both process and thread objects.

Security and Access Tokens

New process inherits security context or is assigned new token for permissions.

Handles and Resource Inheritance

Option to inherit handles from parent, enabling resource sharing.

Challenges and Optimization

Performance Overhead

Process creation expensive due to resource allocation and initialization.

Copy-on-Write Techniques

Delay memory copying until write action to reduce cost.

Thread Creation as Alternative

Threads lighter-weight, share address space, faster creation.

Resource Limits

OS limits number of processes to prevent exhaustion.

Security Concerns

Proper access rights and isolation critical during creation.

References

  • A. Silberschatz, P. Galvin, G. Gagne, Operating System Concepts, 10th Ed., Wiley, 2018, pp. 150-200.
  • W. Stallings, Operating Systems: Internals and Design Principles, 9th Ed., Pearson, 2018, pp. 220-270.
  • R. Love, Linux Kernel Development, 3rd Ed., Addison-Wesley, 2010, pp. 100-140.
  • J. Lions, Lions' Commentary on UNIX 6th Edition with Source Code, UNIX Archive, 1976, pp. 45-70.
  • M. Solomon, D. Russinovich, Windows Internals, 7th Ed., Microsoft Press, 2017, pp. 500-560.