Comments (3)
I think the whole point of a thread pool (statically created threads at init time) is to avoid the overhead of creating/destroying threads repeatedly during run time. The penalty for having idle threads in the background is basically none, so it's not worth the effort to destroy them.
from c-thread-pool.
I think the whole point of a thread pool (statically created threads at init time) is to avoid the overhead of creating/destroying threads repeatedly during run time. The penalty for having idle threads in the background is basically none, so it's not worth the effort to destroy them.
Sure, creating/destroying threads may bring some overhead, but is it significant performance overhead?It may be difficult to estimate each workload when creating threads statically. Too many static threads may waste resources, and too few threads can not deal with tasks well. That is why I think it is meaningful to create/destroy threads dynamically.
from c-thread-pool.
Late to the party but my two cents
Other than the fact that dynamically allocating the threads would make this not a thread pool: embedded applications and other applications where heap space and cycles are severely limited exist, and using malloc
in many codebases is frowned upon. The main point of a threadpool is that you can have a sort of fake dynamic allocation depending on how many jobs come through, because malloc
and free
are very expensive operations compared to leaving a thread idle.
from c-thread-pool.
Related Issues (20)
- If a child thread holding a mutex is terminated by "thpool_destroy(thpool)", what will happen to the mutex?
- example.c: fix a warning HOT 1
- Support for a priority queue for the jobqueue.
- support to zephyr RTOS HOT 1
- Can I pass multiple parameters to the thpool_add_work() method? HOT 2
- Why is `threads_keepalive` a global variable? HOT 1
- why do you define bsem *has_jobs; ? HOT 1
- When a thread is in an endless loop, can it not exit and be destroyed? HOT 1
- unexcpected output HOT 1
- Reinitialization of mutex and cond in bsem_reset is a bug
- Why don't threadpool lock num_threads_working? HOT 1
- Does not improve runtime while using this threadpool implementation
- Is it possible to wait for a specific task?
- Doesn't release memory until job queue is empty? HOT 1
- thpool.c has leftovers after some merge HOT 1
- question about threads_keepalive variable. HOT 1
- 'SIGUSR1' undeclared HOT 1
- Errors when compiling with C++
- Any question weclomed in https://github.com/52coder/C-Thread-Pool
- The execution result seems to be something wrong while I use the Thread pool? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from c-thread-pool.