Click here to Skip to main content
16,005,290 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Restarting an application Pin
Mike Dimmick15-Apr-04 23:14
Mike Dimmick15-Apr-04 23:14 
GeneralCDatabase intensive app. pls help!!! Pin
Member 101882315-Apr-04 21:27
Member 101882315-Apr-04 21:27 
GeneralRe: CDatabase intensive app. pls help!!! Pin
cmk15-Apr-04 22:01
cmk15-Apr-04 22:01 
Generalaccessing excel sheet thru vc++ Pin
shiva shankar15-Apr-04 21:07
shiva shankar15-Apr-04 21:07 
GeneralMulti CPU Pin
Do Manh Hung15-Apr-04 20:50
Do Manh Hung15-Apr-04 20:50 
GeneralRe: Multi CPU Pin
Antti Keskinen15-Apr-04 20:59
Antti Keskinen15-Apr-04 20:59 
GeneralRe: Multi CPU Pin
Do Manh Hung15-Apr-04 21:12
Do Manh Hung15-Apr-04 21:12 
GeneralRe: Multi CPU Pin
Mike Dimmick16-Apr-04 0:17
Mike Dimmick16-Apr-04 0:17 
Unless the threads are affinitized using the SetThreadAffinityMask API, any thread can be scheduled to run on any CPU (if a mask is set, the thread can be scheduled on any CPU in its mask) at any point that it is ready to run. Windows tries to run threads on the same CPU they last ran on if possible, to exploit caching, but you can't rely on this - it won't hold up a thread that could run because its preferred CPU is not available.

Only one CPU can run a given thread at a time. A particular thread of instructions will never run in parallel with itself.

Also, Windows uses a pre-emptive scheduler - it can switch between threads in between any two CPU instructions, which means that some operations (for example, incrementing a variable's value) which require copying from memory into a register, modifying the value and writing back to memory can get interrupted before completing. If two threads try to increment a variable simultaneously, even on a single CPU system, you can get a situation where only one increment ends up being written back.

To prevent this, Windows provides synchronization objects and interlocked functions. The interlocked functions allow primitive values (usually a long) to be modified in a way that cannot be interrupted and forces any other CPU to wait before accessing that memory location - an atomic operation.

For more complex data structures, you need to use a synchronization object such as a critical section. For critical sections, only one thread can enter at a time. If the critical section is already taken by a thread, any other thread will block (cease executing and wait - the OS scheduler will not assign it to a CPU) until the owning thread releases the critical section. Some synchronization objects guarantee a particular order in which threads will be released, but the critical section is not one of them.

Stability. What an interesting concept. -- Chris Maunder
GeneralRe: Multi CPU Pin
Michael Dunn15-Apr-04 21:36
sitebuilderMichael Dunn15-Apr-04 21:36 
GeneralRe: Multi CPU Pin
Tim Smith16-Apr-04 4:00
Tim Smith16-Apr-04 4:00 
GeneralRe: Multi CPU Pin
Alexander M.,16-Apr-04 6:33
Alexander M.,16-Apr-04 6:33 
GeneralRe: Multi CPU Pin
Do Manh Hung16-Apr-04 15:53
Do Manh Hung16-Apr-04 15:53 
GeneralCDialog in the Task Bar Pin
mmica15-Apr-04 19:20
mmica15-Apr-04 19:20 
GeneralRe: CDialog in the Task Bar Pin
Nish Nishant15-Apr-04 20:35
sitebuilderNish Nishant15-Apr-04 20:35 
GeneralRe: CDialog in the Task Bar Pin
mmica15-Apr-04 20:47
mmica15-Apr-04 20:47 
GeneralDumb question, but i thought id ask.. Pin
hammackj15-Apr-04 18:24
hammackj15-Apr-04 18:24 
GeneralRe: Dumb question, but i thought id ask.. Pin
Ryan Binns15-Apr-04 18:35
Ryan Binns15-Apr-04 18:35 
GeneralRe: Dumb question, but i thought id ask.. Pin
hammackj15-Apr-04 18:37
hammackj15-Apr-04 18:37 
GeneralRe: Dumb question, but i thought id ask.. Pin
Anonymous15-Apr-04 18:37
Anonymous15-Apr-04 18:37 
GeneralRe: Dumb question, but i thought id ask.. Pin
Balkrishna Talele15-Apr-04 18:39
Balkrishna Talele15-Apr-04 18:39 
GeneralRe: Dumb question, but i thought id ask.. Pin
hammackj15-Apr-04 18:43
hammackj15-Apr-04 18:43 
GeneralRe: Dumb question, but i thought id ask.. Pin
cmk15-Apr-04 22:14
cmk15-Apr-04 22:14 
GeneralRe: Dumb question, but i thought id ask.. Pin
rrrado15-Apr-04 23:17
rrrado15-Apr-04 23:17 
GeneralRe: Dumb question, but i thought id ask.. Pin
Mike Dimmick16-Apr-04 0:36
Mike Dimmick16-Apr-04 0:36 
GeneralShared Memory DLL Pin
Member 99931815-Apr-04 17:55
Member 99931815-Apr-04 17:55 

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.