Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Multithreaded Task Queue (C++) Overview

This project explores how concurrency and scheduling decisions affect system performance. I implemented a multithreaded task queue in C++ using a fixed-size thread pool and benchmarked how throughput scales as the number of worker threads increases.

The goal was not just to execute tasks, but to understand how synchronization, contention, and task distribution impact real performance.

Architecture Thread pool with configurable worker count Shared task queue protected by mutex std::condition_variable for efficient thread wakeup std::future for async result handling Atomic counters to track active and pending work Benchmark Results

Workload: 12,000 CPU-bound tasks

Threads Time (ms) Throughput (tasks/sec) 1 664 18,072 2 327 36,697 4 168 71,429 8 128 93,750 Key Observations Near-linear scaling from 1 → 4 threads Diminishing returns from 4 → 8 threads Shared queue introduces contention at higher concurrency Synchronization overhead limits perfect scaling What I Learned

This project changed how I think about performance.

Adding more threads does not guarantee better results. At higher thread counts, lock contention and scheduling overhead start to dominate. Even a simple mutex-protected queue can become a bottleneck under load.

It pushed me to think about:

how work is distributed across threads how long critical sections last how synchronization choices affect throughput Next Steps Implement per-thread local queues Add work-stealing to reduce contention Explore lock-free queue designs Measure latency distribution (not just throughput) How to Run g++ -std=c++17 -O2 -pthread cpptaskqueueproject.cpp -o task_queue ./task_queue Why This Matters

Most of my background has been in backend and distributed systems. This project pushed me to go deeper into how systems behave at a lower level. It made me more interested in concurrency, memory behavior, and performance tradeoffs, which is why I’m continuing to explore C++ and systems programming.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages