Linux Programming and Cloud Computing
Linux Evolution, GNU, GPL and System Architecture
PGCP-BDA
Linux evolution
Linux grew from a Unix-like kernel into a complete operating-system family by combining the kernel with GNU tools, libraries.
GNU project
The GNU project develops a free Unix-compatible software environment
GPL
The GNU General Public License permits use, study, modification and redistribution while requiring redistributed derivative source code to remain available.
distribution
A Linux distribution packages the kernel, installer, system libraries, utilities, package manager.
kernel and user space
Kernel space executes privileged code that manages memory, devices, processes and filesystems
system call
A system call is the protected entry point through which a user-space process asks the kernel to perform work such as opening a file.
process and service
A process is a running program instance; a service is a managed background capability often supervised by a service manager.
Linux server
A Linux system configured to provide network or local services under controlled identities, resources and operational policies.
UNIX System Architecture
Overview
UNIX is one of the most influential operating systems ever designed (Bell Labs, 1969).
Major Subsystems of UNIX:
- File Subsystem — manages files and directories
- Process Control Subsystem — manages processes
UNIX Architecture Diagram
+-------------------------------------------------------+
| USER SPACE |
| User Programs / Applications |
| (Shell, Compiler, text editor, database client) |
+------------------+-------------------------------------|
| System Call Interface (API boundary) |
+------------------+------------------------------------+
| KERNEL SPACE |
| File Subsystem | Process Control Subsystem |
| (file operations) | (process scheduling, IPC) |
| +---------------+ | +-------------------------+ |
| | File tables | | | CPU Scheduler | |
| | Inodes | | | Memory Management | |
| | Buffer cache | | | IPC (pipes, signals) | |
| +---------------+ | +-------------------------+ |
+----------------------+----------------------------------+
| Hardware Control (Device Drivers) |
+-------------------------------------------------------+
| HARDWARE |
| CPU | Memory | Disk | Network | Terminal |
+-------------------------------------------------------+
UNIX Key Concepts
| Concept | Description |
|---|---|
| Everything is a file | Devices, sockets, pipes are represented as files |
| Shell | Command-line interface to the kernel (bash, sh, zsh, ksh) |
| PID | Every process has a unique Process ID |
| UID/GID | User ID and Group ID for security |
| File permissions | rwx for owner, group, others |
| Kernel | Core of the OS managing all resources |
| Daemon | Background process (like a service in Windows) |
System Calls
What are System Calls?
System calls provide the interface between user programs and the operating system kernel.
When a program needs OS services (file I/O, process creation, memory allocation), it makes a system call.
Categories of System Calls
| Category | Examples |
|---|---|
| Process Control | fork(), exec(), exit(), wait(), getpid() |
| File Management | open(), read(), write(), close(), unlink(), stat() |
| Device Management | ioctl(), read(), write() (for devices) |
| Information Maintenance | getpid(), alarm(), sleep(), time() |
| Communication | pipe(), socket(), send(), recv(), shmget() |
System Call Flow
User Program
|
| calls printf("hello") → internally calls write()
|
↓
std C library (write() wrapper)
|
| System Call Instruction (int 0x80 / syscall)
↓
KERNEL (system call handler)
|
| sys_write() → device driver → I/O
↓
Returns to user program
Dual Mode Operation
What is Dual Mode?
The CPU operates in two modes to protect the OS from user programs:
| Mode | Also Called | Privilege |
|---|---|---|
| User Mode | Unprivileged mode | Limited instructions; cannot directly access hardware |
| Kernel Mode | Supervisor/System mode | All instructions; full hardware access |
Mode Switching
User Program executes → User Mode
|
| System Call or Interrupt
↓
Kernel Mode (OS handles request)
|
| Return from system call
↓
User Mode (program resumes)
Mode bit:
- 0 = Kernel Mode
- 1 = User Mode
Privileged vs Non-Privileged Instructions
| Instruction Type | User Mode | Kernel Mode |
|---|---|---|
| I/O operations | Not allowed | Allowed |
| Memory management | Not allowed | Allowed |
| Interrupt control | Not allowed | Allowed |
| Normal arithmetic | Allowed | Allowed |
| Function calls | Allowed | Allowed |
Process Management
What is a Process?
A process is a program in execution — an active entity.
Program vs Process:
| Feature | Program | Process |
|---|---|---|
| State | Passive (on disk) | Active (in memory) |
| Resources | None (static file) | CPU, memory, I/O |
| Number | One copy on disk | Multiple processes can run from same program |
| Example | notepad.exe file | Running instance of Notepad |
Process in Memory
+------------------+ High address
| Stack | ← Function calls, local variables (grows down)
| ↓ |
| |
| ↑ |
| Heap | ← Dynamic memory (malloc, new)
+------------------+
| BSS Segment | ← Uninitialized global/static variables
+------------------+
| Data Segment | ← Initialized global/static variables
+------------------+
| Text Segment | ← Program code (instructions)
+------------------+ Low address
Process Creation
In Unix/Linux:
pid_t child_pid = fork(); // Creates child process (copy of parent)
if (child_pid == 0) {
// This is the child process
exec("new_program"); // Replace with different program
} else {
wait(NULL); // Parent waits for child to finish
}
Process hierarchy — Process Tree:
init (PID 1)
├── systemd
│ ├── sshd
│ │ └── bash (user session)
│ │ └── vim
│ └── cron
│ └── backup_script.sh
└── kthreadd (kernel threads)
What is an Operating System?
Why is an OS Needed?
Basic functions of a computer:
- Data Storage — save data to storage devices
Data Processing — compute and transform data 3. Data Movement — transfer data between components 4. Control — coordinate all operations
Problem: Any user cannot communicate/interact directly with computer hardware to do different tasks. There is a need for some interface between user and hardware.
Solution: The Operating System
Definition of Operating System
An Operating System (OS) is system software that:
- Manages computer hardware and software resources
- Provides a common interface between users and hardware
- Controls and coordinates use of hardware among various application programs for various users
- Acts as a resource manager — allocates CPU, memory, I/O to processes
OS as an Intermediary
Applications (User Programs)
↕
OPERATING SYSTEM
↕
Hardware (CPU, Memory, I/O)
Popular Operating Systems
| OS | Family | Use Case |
|---|---|---|
| Windows 11 | Microsoft | Desktop, Gaming |
| Ubuntu / Debian | Linux | Development, Server |
| macOS | Apple/Unix | Creative, Development |
| Android | Linux-based | Mobile |
| iOS | Apple | Mobile |
| Unix | AT&T Bell Labs | Server, Academic |
| Linux | Open-source Unix-like | Server, Embedded |
Functions of an Operating System
| Function | Description |
|---|---|
| Process Management | Create, schedule, terminate processes; handle synchronization |
| Memory Management | Allocate/deallocate memory; virtual memory management |
| File Management | Create/delete files and directories; access control |
| I/O Management | Control I/O devices; provide device driver interface |
| Security & Protection | Protect resources from unauthorized access |
| Networking | TCP/IP stack; network communication |
| Error Detection & Handling | Detect hardware errors; take corrective action |
| User Interface | CLI (command line) or GUI (graphical) interface |
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.