Home Knowledge Base Operating System Process

Operating System Process is the fundamental unit of program execution that provides isolated memory, its own set of resources, and an independent execution context — the OS abstraction that enables multiprocessing in Python AI systems, provides crash isolation between services, and forms the basis of containerization in AI infrastructure.

What Is an OS Process?

Why Process Isolation Matters for AI Systems

Process vs Thread Comparison

AspectProcessThread
Memory spacePrivate, isolatedShared with parent process
Creation costHigh (fork ~1ms)Low (~microseconds)
Memory overheadHigh (full copy of address space)Low (shared pages)
Crash isolationYes — crash doesn't affect othersNo — crash kills entire process
Data sharingIPC required (pipes, queues, shared memory)Direct (but needs locks)
GILEach process has its own GILShared GIL — no true parallelism for Python
Use caseCPU-bound parallelismI/O-bound concurrency

Process Life Cycle

Fork: Parent calls fork() → kernel creates identical child process (copy-on-write memory). Exec: Child optionally calls exec() to replace itself with a new program binary. Running: Process executes, makes system calls, uses CPU and memory. Waiting: Process blocks on I/O, sleep, or waiting for child (wait() system call). Zombie: Process has exited but parent has not yet called wait() to collect exit status. Terminated: Parent called wait() — OS reclaims all resources.

IPC (Inter-Process Communication) in AI

Since processes cannot share memory directly, they communicate via IPC:

Pipes/Queues: Byte streams between processes. from multiprocessing import Queue q = Queue() q.put(tensor.cpu().numpy()) # Serialize to queue data = q.get() # Deserialize in worker

Shared Memory: Zero-copy sharing of arrays (NumPy, tensors). from multiprocessing import shared_memory shm = shared_memory.SharedMemory(create=True, size=array.nbytes)

Zero-copy access from multiple processes

Sockets: TCP/UDP communication — used by Ray, gRPC, and REST APIs between services.

Memory-Mapped Files: Map a file into multiple processes' address spaces for zero-copy data access — used for large dataset sharing.

Process Management in AI Infrastructure

Supervisor / systemd: Manage long-running AI service processes — restart on crash, log output, manage environment.

Gunicorn: gunicorn app:app --workers 4 --worker-class uvicorn.workers.UvicornWorker Spawns 4 worker processes, each running the FastAPI/inference app — provides multi-core CPU utilization and crash isolation.

torch.multiprocessing: PyTorch's process pool with CUDA-aware shared memory — enables safe tensor sharing between training processes.

Kubernetes Pods: A pod contains one or more containers (processes) sharing a network namespace — the OS process model maps directly to Kubernetes deployment patterns.

OS processes are the fundamental isolation boundary of AI infrastructure — understanding how the kernel creates, isolates, and manages processes clarifies every aspect of container orchestration, DataLoader worker behavior, model serving architecture, and the multi-processing patterns that unlock true CPU parallelism in Python-based AI pipelines.

processisolationfork

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.