Click here to Skip to main content
15,905,558 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: how can this program work correctly Pin
ludi042312-Jul-09 20:26
ludi042312-Jul-09 20:26 
GeneralRe: how can this program work correctly Pin
carter200012-Jul-09 20:36
carter200012-Jul-09 20:36 
AnswerRe: how can this program work correctly Pin
«_Superman_»12-Jul-09 21:03
professional«_Superman_»12-Jul-09 21:03 
Questionc++ source code for acm 2004-2005 problems Pin
dv200912-Jul-09 13:09
dv200912-Jul-09 13:09 
AnswerRe: c++ source code for acm 2004-2005 problems Pin
Chandrasekharan P12-Jul-09 19:03
Chandrasekharan P12-Jul-09 19:03 
AnswerRe: c++ source code for acm 2004-2005 problems Pin
killabyte12-Jul-09 19:03
killabyte12-Jul-09 19:03 
AnswerRe: c++ source code for acm 2004-2005 problems Pin
santosh10313-Jul-09 0:28
santosh10313-Jul-09 0:28 
QuestionReport on Threadpool Scheduling Techniques -- Need Feedback Pin
Cyrilix12-Jul-09 11:26
Cyrilix12-Jul-09 11:26 
Concurrency is one of those things that gets me all worked up and interested, and part of the reason for this is because I find it great fun to be creating some sort of framework that others might be able to use, in order to increase their scalability, where all they have to do is figure out which parts are scalable, and leave the gory details of handling concurrency to the framework. Anyway, I'm looking to do some research and experimentation (and write a short document on my findings) on something concurrency related on Windows.

I've read some articles in the past on how to properly/efficiently use threadpools (by Herb Sutter, other concurrency gurus, and such), and one of the problems mentioned was a thread in a threadpool waiting on another thread in the threadpool, since you've effectively reduced your concurrency. I'd like to attempt to solve this problem in C++ by attempting a couple of techniques:

- Using fibers to emulate explicit wait API calls (WaitForSingleObject, etc.) so that waits essentially cause a switch to a different threadpool task, until the wait is ready.

The idea behind this is that we can preserve the number of threads in a threadpool, and have them switch between fibers while one is waiting on another thread, and then have them switch back to the original fiber when it's ready to run. This is because a thread can have multiple fibers. For those that don't know, a fiber can be sort of seen as a lightweight thread with its own stack space that is attached to an actual thread. Of course, feel free to correct me if I'm wrong, since I'm fairly new to this.

- Optimizing a threadpool by using more threads than can be efficiently used concurrently.

The idea behind this is that in a 4-core system, 4 active tasks can be performed at a time, but if one of these tasks waits on another task, then only 3 active tasks are working, so we optimize the threadpool by having for instance 6 tasks in all (4 running, 2 blocked), and when necessary to preserve maximum concurrency, we unblock the blocked tasks, and block them again where possible (I've seen allusions to the fact that we can do this, but this will require some more research).

I've already crafted (in previous attempts at research and testing), my own somewhat generic C++ threadpool framework, and my idea is to add the above concepts to what I currently have, to answer a few questions at least:

- Are my ideas feasible and not overly complicated?
- Is it possible to generalize what I'm trying to do in a framework?
- What are the scalability and performance benefits (or losses) that I can expect to see from implementing such functionality?

Any input or feedback into what I'm doing would be much appreciated. I'm not looking for existing code that already does what I want to do, but rather good lessons to be learned or things that I should know beforehand (things to avoid doing, traps, pitfalls, etc.), since I'm trying to learn myself, or at least, build on existing tools (though I doubt there's something I want to do that hasn't already been attempted). I estimate the scope of this project is something that I want to get done in 2 weeks worth of good work, coding and testing. I have a relatively good background in concurrency-related topics (my last two study projects were basic threadpooling and lockless synchronization techniques), but I'm still unsure if this is too much to take on at a time.

Sorry for the long post, and thanks in advance for reading!
AnswerRe: Report on Threadpool Scheduling Techniques -- Need Feedback Pin
Stuart Dootson12-Jul-09 13:14
professionalStuart Dootson12-Jul-09 13:14 
GeneralRe: Report on Threadpool Scheduling Techniques -- Need Feedback [modified] Pin
Cyrilix12-Jul-09 14:15
Cyrilix12-Jul-09 14:15 
AnswerRe: Report on Threadpool Scheduling Techniques -- Need Feedback Pin
killabyte12-Jul-09 18:59
killabyte12-Jul-09 18:59 
GeneralRe: Report on Threadpool Scheduling Techniques -- Need Feedback Pin
Cyrilix12-Jul-09 19:05
Cyrilix12-Jul-09 19:05 
GeneralRe: Report on Threadpool Scheduling Techniques -- Need Feedback Pin
killabyte12-Jul-09 19:13
killabyte12-Jul-09 19:13 
Questionhello well i get a very weird error and cant fix it i know it has do to something with brackets ) Pin
nah133712-Jul-09 10:31
nah133712-Jul-09 10:31 
AnswerRe: hello well i get a very weird error and cant fix it i know it has do to something with brackets ) Pin
Stuart Dootson12-Jul-09 13:29
professionalStuart Dootson12-Jul-09 13:29 
AnswerRe: hello well i get a very weird error and cant fix it i know it has do to something with brackets ) Pin
«_Superman_»12-Jul-09 16:45
professional«_Superman_»12-Jul-09 16:45 
GeneralRe: hello well i get a very weird error and cant fix it i know it has do to something with brackets ) Pin
nah133713-Jul-09 10:50
nah133713-Jul-09 10:50 
GeneralRe: hello well i get a very weird error and cant fix it i know it has do to something with brackets ) Pin
«_Superman_»13-Jul-09 16:52
professional«_Superman_»13-Jul-09 16:52 
GeneralRe: hello well i get a very weird error and cant fix it i know it has do to something with brackets ) Pin
nah133714-Jul-09 9:57
nah133714-Jul-09 9:57 
QuestionHEAP: Heap block at 003BCB48 modified at 003BCC6C past requested size of 11c Pin
transoft12-Jul-09 8:27
transoft12-Jul-09 8:27 
AnswerRe: HEAP: Heap block at 003BCB48 modified at 003BCC6C past requested size of 11c Pin
Luc Pattyn12-Jul-09 8:36
sitebuilderLuc Pattyn12-Jul-09 8:36 
AnswerRe: HEAP: Heap block at 003BCB48 modified at 003BCC6C past requested size of 11c Pin
Stuart Dootson12-Jul-09 8:37
professionalStuart Dootson12-Jul-09 8:37 
AnswerRe: HEAP: Heap block at 003BCB48 modified at 003BCC6C past requested size of 11c Pin
Luc Pattyn12-Jul-09 9:58
sitebuilderLuc Pattyn12-Jul-09 9:58 
Questionvptr help? [modified] Pin
sam_psycho12-Jul-09 6:20
sam_psycho12-Jul-09 6:20 
AnswerRe: vptr help? Pin
Stuart Dootson12-Jul-09 8:08
professionalStuart Dootson12-Jul-09 8:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.