C | Unix Pipes | Concurrency | Systems Programming
A high-performance concurrent text editor in C that allows multiple clients to edit a shared document in real time. Built from scratch using threads, epoll, and low-level IPC.
- Built a multi-client real-time editor in C using epoll and threads
- Designed a thread-safe shared document model
- Implemented IPC using Unix pipes
- Handled concurrent edits without race conditions or deadlocks
This project implements a multi-client collaborative text editor where:
- A central server maintains the shared document
- Multiple clients can connect and issue edit commands concurrently
- Changes are safely synchronized across clients
- The updated document is broadcast periodically to all connected clients
The document is internally represented as a linked list of character arrays, enabling efficient insertions, deletions, and formatting operations.
- Supports multiple concurrent clients editing the same document
- Thread-safe operations using mutex-based synchronization
- Real-time document updates broadcast to all clients
- Markdown-style editing (headers, lists, formatting, etc.)
This project explores how real-time collaborative systems (like Google Docs or Notion) can be built at a low level without relying on high-level frameworks.
It demonstrates how to:
- Handle concurrent edits safely in C
- Design scalable event-driven servers using epoll
- Build efficient shared data structures under contention
The system follows a client–server model with concurrency at the server level.
- Clients → send edit commands
- Server → processes and synchronizes edits
- Shared Document → stored as a linked structure
Each client communicates with the server via Unix pipes for command delivery and updates.
- The server acts as the single source of truth
- All edits are serialized through a central update queue
- Mutex locks ensure atomic modifications to the document
- Clients receive periodic snapshots to stay in sync
source/
├── client.c # Client-side logic and command interface
├── server.c # Multi-threaded server and coordination logic
├── markdown.c # Document editing operations (linked list)
libs/ # Header files for each source code file
├── client.h
├── server.h
├── markdown.hclient.c
- Represents a client process
- Sends editing commands to the server
- Receives updated document snapshots
- Supports collaborative editing across multiple clients
server.c
- Spawns multiple threads:
- One per client connection
- Worker threads for document updates
- A broadcasting thread for periodic updates
- Ensures synchronization and consistency across concurrent edits
markdown.c
- Implements all document manipulation logic
- Uses a linked list of character arrays for memory efficiency
Communication between clients and server is implemented using Unix pipes, which enables:
- Lightweight IPC between processes
- Efficient message passing for commands and updates
This project is designed for Linux environments only. It leverages Linux-specific system calls such as epoll for high-performance I/O, and therefore will not compile or run natively on macOS or Windows.
If you are using macOS or Windows, you can run the project via:
- WSL (Windows Subsystem for Linux)
- Docker
- A Linux virtual machine
- Compile
make- Start the Server
./server- Launch Clients (in separate terminals)
./clientYou can start multiple clients to simulate concurrent editing.
Example Workflow
- Start the server
- Launch multiple clients
- Clients send edit commands (insert/delete/format)
- Server processes edits safely
- Updated document is broadcast to all clients periodically
- Designing thread-safe systems in C
- Managing concurrency and synchronization
- Implementing inter-process communication with Unix pipes
- Building efficient data structures for dynamic text editing
- Coordinating multi-threaded server architectures
- Designing a thread-safe editing system without introducing deadlocks
- Synchronizing concurrent edits across multiple clients
- Efficiently managing IPC without blocking performance
- Structuring a dynamic document using linked lists for fast updates