Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 978919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:08:09+00:00 2026-05-16T04:08:09+00:00

I have a multithreaded application. Each module is executed in a separate thread. Modules

  • 0

I have a multithreaded application. Each module is executed in a separate thread.
Modules are:

- network module - used to receive/send data from network
- parser module - encode/decode network data to internal presentation
- 2 application module - perform some application logic on the above data one after other
- counter module - used to gather statistics from other modules
- timer module - used to schedule timers
- and much more ...

All threads using message queues for inter thread communication (std::deque sync by conditional variable and mutex).

Some modules are used by others ones (e.g. all modules use timer and counter) and this for each message received from network wich should be handled in very high rates.

This is pretty complex application and the design looks “reasonable”. From other hand, I’m not sure that such design, thread per module, is the “best” one? In particular, I’m afraid that such design “encorage” a lot of context switches.

What do you think?

Is there’re any good guidelines or open source project to learn from how to do “correct” design of threaded application?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T04:08:10+00:00Added an answer on May 16, 2026 at 4:08 am

    Thread-per-function designs are just naive: they assume that by separating tasks – by module – onto threads, that some kind of scalability will be achieved.

    This kind of design is inefficient, as very few task breakdowns yield exactly as many tasks as there are CPUs.

    Far more rational designs are to break tasks down into ‘jobs’ – and then use thread pooling mechanisms to dispatch those jobs.
    Advantages over the thread-per-module approach:

    • Thread pools take advantage of all cores. with thread-per-module if you have modules < cores you have cores sitting idle.

    • Thread pools minimize contention and resources by maintaining a parity between active threads, and cores. with thread-per-module, if modules > cores you incur needless extra context switches and (on some platforms) each thread exhausts other limited per process resources (like virtual memory).

    • Thread pools let a “module” do multiple jobs at a time. thread-per-module means that the busiest module still only gets one core.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a multithreaded C# application where each thread has it's own set of
I have an application that I'm trying to make multithreaded. Each thread will access
I have a multithreaded NHibernate application with ThreadStaticSessionContext. I bind un each thread a
I have a multithreaded application, where each thread has a variable of integer type.
I have a multithreaded application that activate multiple Mono domains from native code. Each
I currently work on a multithreaded application where I receive data using the following
I have a multithreaded application that runs using a custom thread pool class. The
I have an application that processes data stored in a number of files from
I have a multithreaded application, in which I'm trying to render with different threads.
I have a multithreaded application that has many concurrent operations going on at once.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.