Click here to Skip to main content
15,880,469 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionbitblt prob Pin
Game-point16-Sep-09 21:14
Game-point16-Sep-09 21:14 
AnswerRe: bitblt prob Pin
CPallini16-Sep-09 21:46
mveCPallini16-Sep-09 21:46 
GeneralRe: bitblt prob Pin
Game-point16-Sep-09 22:04
Game-point16-Sep-09 22:04 
GeneralRe: bitblt prob Pin
Nuri Ismail16-Sep-09 22:11
Nuri Ismail16-Sep-09 22:11 
GeneralRe: bitblt prob Pin
CPallini16-Sep-09 22:12
mveCPallini16-Sep-09 22:12 
QuestionHow to get threads in a custom threadpool to not require locks when enabling/disabling threads? Pin
Cyrilix16-Sep-09 21:00
Cyrilix16-Sep-09 21:00 
AnswerRe: How to get threads in a custom threadpool to not require locks when enabling/disabling threads? Pin
Stuart Dootson16-Sep-09 21:24
professionalStuart Dootson16-Sep-09 21:24 
GeneralRe: How to get threads in a custom threadpool to not require locks when enabling/disabling threads? Pin
Cyrilix17-Sep-09 6:25
Cyrilix17-Sep-09 6:25 
You need to make your two actions atomic - the only way to do that is to serialize access to a combination of work queue and event, using a mutex or critical section.

I sort of figured that might be the case.

If the overhead of calling critical section is significant compared to amount of work being done in the thread, your work items are much too small.

What I use for work items is something in the order of a hundred multiplications/divisions. So, for instance, say I want to multiply two square matrices matrices or equal size using the naive method, I split up the work so that each <column,row> entry of the resulting matrix is a single work item. If I have a 100x100 matrix multiplied by a 100x100 matrix, then that gives me 100 multiplications and 100 additions for each of 100x100 (10000) work items. This seems to really stress my threadpool implementation since the single-threaded version of this naive matrix multiplication is a lot faster, and it's definitely due to the overhead of my threadpool. I was thinking that a more efficient use of synchronization (if possible) might alleviate this problem, however, I haven't actually extensively profiled my program. What I do know, however, is that the vast majority of the time is being spent on queueing the work, rather than doing the actual work.

A different way might be for the thing that's pushing the work to select the thread that's to do the work and, by having an event per thread, signal the selected thread to pick up a work item. If there are no waiting threads, do nothing. And when a thread enters a waiting state, it can look at the work queue before entering the waiting state and pick the next work item.

OK, that's some food for thought. I'll think about this and see if I can implement something accordingly.

Thanks for your comments.
GeneralRe: How to get threads in a custom threadpool to not require locks when enabling/disabling threads? Pin
Stuart Dootson17-Sep-09 6:53
professionalStuart Dootson17-Sep-09 6:53 
AnswerRe: How to get threads in a custom threadpool to not require locks when enabling/disabling threads? Pin
Randor 17-Sep-09 7:31
professional Randor 17-Sep-09 7:31 
GeneralRe: How to get threads in a custom threadpool to not require locks when enabling/disabling threads? Pin
Cyrilix17-Sep-09 7:53
Cyrilix17-Sep-09 7:53 
QuestionWeb Filter Pin
Aseem Sharma16-Sep-09 17:44
Aseem Sharma16-Sep-09 17:44 
AnswerRe: Web Filter Pin
N a v a n e e t h16-Sep-09 18:38
N a v a n e e t h16-Sep-09 18:38 
QuestionClass or Library to support MFC Document Windows borders Pin
WylieCoyoteUsa16-Sep-09 17:21
WylieCoyoteUsa16-Sep-09 17:21 
QuestionRe: Class or Library to support MFC Document Windows borders Pin
CPallini16-Sep-09 21:06
mveCPallini16-Sep-09 21:06 
AnswerRe: Class or Library to support MFC Document Windows borders Pin
WylieCoyoteUsa17-Sep-09 2:58
WylieCoyoteUsa17-Sep-09 2:58 
QuestionPassing Objects UI threads VS worker threads Pin
ForNow16-Sep-09 14:57
ForNow16-Sep-09 14:57 
AnswerRe: Passing Objects UI threads VS worker threads Pin
Chris Losinger16-Sep-09 16:03
professionalChris Losinger16-Sep-09 16:03 
GeneralRe: Passing Objects UI threads VS worker threads Pin
ForNow16-Sep-09 16:31
ForNow16-Sep-09 16:31 
QuestionRecursive maze, so close, probably something stupid Pin
forensicgeek16-Sep-09 14:17
forensicgeek16-Sep-09 14:17 
AnswerRe: Recursive maze, so close, probably something stupid Pin
«_Superman_»16-Sep-09 20:17
professional«_Superman_»16-Sep-09 20:17 
AnswerRe: Recursive maze, so close, probably something stupid Pin
David Crow17-Sep-09 2:43
David Crow17-Sep-09 2:43 
AnswerRe: Recursive maze, so close, probably something stupid Pin
Alan Balkany18-Sep-09 3:58
Alan Balkany18-Sep-09 3:58 
QuestionTime Pin
Bram van Kampen16-Sep-09 13:28
Bram van Kampen16-Sep-09 13:28 
AnswerRe: Time Pin
David Crow17-Sep-09 2:47
David Crow17-Sep-09 2:47 

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.