Click here to Skip to main content
16,014,591 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralAlpha in GDI Pin
Joel Holdsworth11-Sep-04 9:32
Joel Holdsworth11-Sep-04 9:32 
GeneralRe: Alpha in GDI Pin
Iain Clarke, Warrior Programmer13-Sep-04 3:41
Iain Clarke, Warrior Programmer13-Sep-04 3:41 
GeneralRe: Alpha in GDI Pin
Joel Holdsworth13-Sep-04 7:39
Joel Holdsworth13-Sep-04 7:39 
GeneralReplicating an instance in a multi-threaded app Pin
0v3rloader11-Sep-04 8:56
0v3rloader11-Sep-04 8:56 
GeneralRe: Replicating an instance in a multi-threaded app Pin
Gary R. Wheeler12-Sep-04 2:58
Gary R. Wheeler12-Sep-04 2:58 
GeneralRe: Replicating an instance in a multi-threaded app Pin
0v3rloader12-Sep-04 5:48
0v3rloader12-Sep-04 5:48 
GeneralUsing a critical section in a high priority thread Pin
Chris Hills11-Sep-04 5:28
Chris Hills11-Sep-04 5:28 
GeneralRe: Using a critical section in a high priority thread Pin
Baris Kurtlutepe11-Sep-04 8:33
Baris Kurtlutepe11-Sep-04 8:33 
Hi Chris,

1) I don't think that I really do understand what you mean with timer interrupts, but the call to EnterCriticalSection() on the "normal" thread will cause the "realtime" thread to block on the EnterCriticalSection() call and this will give the processing cycles back to your "normal" thread, which will be happily executing until it calls LeaveCriticalSection(). Ie it is like having a high priority thread calling Sleep, so regardless of the priority of the thread, the processing time will be granted to other threads.

2) There is no need to worry about the "normal" thread, it will most probably still get the same amount of processing time (maybe even more than) that it used to get before. (Beware that I'm not saying that this processing time is enough for your normal thread to be 'responsive enough') The thing about the "realtime" thread is, you're correct it will block until the "normal" thread calls LeaveCriticalSection() so your realtime operation will probably stall. Instead of doing this you can call TryEnterCriticalSection on the realtime thread, and if it returns zero, you can skip trying to read that information and retry on the next loop.

3) As you probably already know, using real time priority in a thread is strongly discouraged and I'm not sure that all versions of Windows provides the same flexibility on multithreading (especially Win9x series) and you should expect lock-ups due to the realtime priority of your thread.

Besides that, if you're concerned about corruption in single read-write's of 32bit values, I'd like to remind you that in Win32 all 32 bit operations are guaranteed to be atomic, so there is no need for synchronization if you're just reading from or writing to an integer from multiple threads. There will be no problem if in one thread you are just reading an integer and in the other thread just updating it.
GeneralRe: Using a critical section in a high priority thread Pin
Andrew Walker12-Sep-04 14:37
Andrew Walker12-Sep-04 14:37 
GeneralRe: Using a critical section in a high priority thread Pin
Blake Miller13-Sep-04 6:17
Blake Miller13-Sep-04 6:17 
GeneralRe: Using a critical section in a high priority thread Pin
Andrew Walker13-Sep-04 12:58
Andrew Walker13-Sep-04 12:58 
GeneralVC++6 WinXP - Find Dialog and SerializeRaw don't work Pin
Kwakas11-Sep-04 4:49
Kwakas11-Sep-04 4:49 
GeneralMulti select list control Pin
Tyrus18211-Sep-04 4:17
Tyrus18211-Sep-04 4:17 
GeneralRe: Multi select list control Pin
Gary R. Wheeler12-Sep-04 3:02
Gary R. Wheeler12-Sep-04 3:02 
QuestionHow to issue the mouse_event without "SendInput" Pin
Member 244207211-Sep-04 3:50
Member 244207211-Sep-04 3:50 
GeneralMultiple document templates Pin
Jens Christiansen11-Sep-04 3:10
Jens Christiansen11-Sep-04 3:10 
Generalcalculating response time for a http request Pin
emmatty11-Sep-04 0:36
emmatty11-Sep-04 0:36 
GeneralRe: calculating response time for a http request Pin
Alexander M.,12-Sep-04 4:28
Alexander M.,12-Sep-04 4:28 
Generallist control selection Pin
Tyrus18210-Sep-04 18:51
Tyrus18210-Sep-04 18:51 
GeneralRe: list control selection Pin
Branislav11-Sep-04 4:05
Branislav11-Sep-04 4:05 
GeneralRe: list control selection Pin
Tyrus18211-Sep-04 4:20
Tyrus18211-Sep-04 4:20 
GeneralRe: list control selection Pin
Branislav11-Sep-04 5:04
Branislav11-Sep-04 5:04 
GeneralRe: list control selection Pin
Ravi Bhavnani11-Sep-04 5:07
professionalRavi Bhavnani11-Sep-04 5:07 
GeneralADO MySQL query problem Pin
Graham Holdaway10-Sep-04 16:34
Graham Holdaway10-Sep-04 16:34 
GeneralRe: ADO MySQL query problem Pin
Arsalan Malik10-Sep-04 20:23
Arsalan Malik10-Sep-04 20:23 

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.