Linux Programming and Cloud Computing
Virtualization, Hypervisors, Provisioning and Migration
PGCP-BDA
virtualization
Virtualization presents isolated logical compute resources over physical hardware by mediating CPU, memory, device and storage access.
virtual machine
A virtual machine is an isolated guest computer with virtual hardware and its own operating-system kernel.
hypervisor type 1 and type 2
A type-1 hypervisor runs directly on hardware, while a type-2 hypervisor runs as an application over a host operating system.
container and VM
A container isolates processes while sharing the host kernel; a virtual machine includes a separate guest kernel behind virtual hardware.
VM image
A virtual-machine image is a reusable disk and metadata template from which instances are created
provisioning
Provisioning allocates and configures compute, storage, network, identity and software resources into a usable declared state.
resource oversubscription
Oversubscription assigns guests more virtual capacity than the host can supply simultaneously.
live migration
Live migration transfers a running virtual machine’s memory and device state between hosts while keeping interruption small and storage/network identity.
private cloud
A private cloud supplies self-service pooled infrastructure for one organization, whether hosted on its premises or by a provider.
Virtual Memory
What is Virtual Memory?
Virtual Memory allows executing processes that are not completely in main memory.
- Processes see a virtual address space larger than physical RAM
- OS swaps parts of processes between RAM and disk
Benefits:
- Run programs larger than physical RAM
- More processes can run simultaneously
- Memory protection between processes
Swapping
Swapping moves entire processes between main memory and disk (swap space/page file).
RAM: [Active Process A] [Active Process B] [Free]
Disk: [Swapped Process C] [Swap Space]
When process A needs to swap out:
A → written to disk swap area
C → loaded from disk into RAM
Performance impact: Disk I/O is much slower than RAM → excessive swapping = "thrashing"
Virtual Address Space
Virtual Address Space (per process):
+------------------+
| Stack | 0xFFFF...
| ↓ |
| |
| ↑ |
| Heap |
+------------------+
| Data/BSS |
+------------------+
| Text | 0x0000...
+------------------+
Physical RAM:
+------------------+
| OS Kernel |
+------------------+
| Process Pages | (only needed pages loaded)
+------------------+
Demand Paging: Load pages into RAM only when accessed ("lazy loading").
Segmentation
What is Segmentation?
Segmentation divides virtual memory into variable-size segments based on logical divisions of a program:
Program Segments:
+------------------+
| Code Segment | ← program instructions
+------------------+
| Data Segment | ← global variables
+------------------+
| Stack Segment | ← function calls
+------------------+
| Heap Segment | ← dynamic allocation
+------------------+
Segmentation vs Paging
| Feature | Paging | Segmentation |
|---|---|---|
| Block size | Fixed (4KB) | Variable |
| Fragmentation | Internal | External |
| User view | Flat address space | Logical segments |
| Hardware support | Page table | Segment table |
| Protection | By page | By segment type |
Paged Segmentation
Modern systems combine both:
- Segmented with Paged Segments — each segment is paged
Used by x86-64 architecture
IPv6
Why IPv6?
- IPv4 uses 32-bit addresses = ~4.3 billion unique addresses
- The internet has more than 4.3 billion devices — IPv4 addresses are exhausted
- IPv6 uses 128-bit addresses = 340 undecillion (3.4 × 10^38) unique addresses
IPv6 Address Format
IPv4: 192.168.1.100 (32 bits, decimal notation)
IPv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334 (128 bits, hex notation)
Simplified: Remove leading zeros and consecutive groups of zeros:
2001:db8:85a3::8a2e:370:7334
IPv6 vs IPv4
| Feature | IPv4 | IPv6 |
|---|---|---|
| Address size | 32 bits | 128 bits |
| Notation | Decimal dotted | Hexadecimal colon |
| Total addresses | ~4.3 billion | ~340 undecillion |
| Header size | 20 bytes | 40 bytes |
| NAT | Required | Not needed |
| Broadcast | Yes | No (multicast instead) |
| Auto-configuration | DHCP needed | SLAAC built-in |
| IPSec | Optional | Built-in |
| Fragmentation | At routers | Only at source |
IPv6 Address Types
| Type | Description | Example |
|---|---|---|
| Unicast | One-to-one communication | 2001:db8::1 |
| Multicast | One-to-many | ff02::1 (all nodes) |
| Anycast | Nearest of a set | Routing to nearest server |
| Link-Local | Used only on local link | fe80::/10 |
| Global Unicast | Public internet addresses | 2000::/3 |
| Loopback | ::1 | Same as 127.0.0.1 |
Paging
What is Paging?
Paging divides:
- Physical memory into fixed-size blocks called frames
Virtual address space into fixed-size blocks called pages
Same size: page size = frame size (typically 4KB)
How Paging Works
Virtual Address: [Page Number | Offset]
| |
↓ |
Page Table |
+---------+ |
| Page 0→Frame 5| |
| Page 1→Frame 3| |
| Page 2→Frame 7| |
+---------+ |
| |
↓ ↓
Physical Address: [Frame Number | Offset]
Address Translation:
Virtual address: page_number=2, offset=100
Page Table: page 2 → frame 7
Physical address: frame_number=7, offset=100
Physical addr = 7 × 4096 + 100
Page Table Storage
Large page tables stored in memory; TLB (Translation Lookaside Buffer) caches recent translations.
TLB Hit: Address found in TLB → fast access TLB Miss: Access page table in memory → slower; TLB updated
Page Replacement Algorithms
When RAM is full and new page needed, which page to evict?
| Algorithm | Description | Advantage |
|---|---|---|
| FIFO | Replace oldest loaded page | Simple |
| LRU (Least Recently Used) | Replace least recently used page | Good performance |
| Optimal | Replace page not used for longest in future | Best (theoretical, not practical) |
| LFU (Least Frequently Used) | Replace page with lowest access frequency | Good for varying patterns |
| Clock (Second Chance) | FIFO with a reference bit | Approximates LRU; practical |
Thrashing
Thrashing occurs when process spends more time swapping pages than executing:
- Too many processes → each has too few frames
- Constant page faults → constant disk I/O
- CPU utilization drops drastically
Solution: Reduce degree of multiprogramming; use working set model.
Continue learning
Related notes
Put this topic into timed practice
Open mock tests when you want full-exam pacing, or keep drilling in practice mode.