Click here to Skip to main content
16,003,693 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: how to save my data in notepad or excel Pin
Hamid_RT18-Jun-08 23:44
Hamid_RT18-Jun-08 23:44 
GeneralRe: how to save my data in notepad or excel Pin
gentleguy18-Jun-08 23:59
gentleguy18-Jun-08 23:59 
GeneralRe: how to save my data in notepad or excel Pin
Hamid_RT19-Jun-08 0:04
Hamid_RT19-Jun-08 0:04 
QuestionRe: how to save my data in notepad or excel Pin
David Crow19-Jun-08 3:41
David Crow19-Jun-08 3:41 
QuestionThread synchronization problems Pin
ss43118-Jun-08 21:20
ss43118-Jun-08 21:20 
AnswerRe: Thread synchronization problems Pin
Jijo.Raj18-Jun-08 21:47
Jijo.Raj18-Jun-08 21:47 
GeneralRe: Thread synchronization problems Pin
ss43118-Jun-08 22:51
ss43118-Jun-08 22:51 
AnswerRe: Thread synchronization problems Pin
Roger Stoltz19-Jun-08 0:04
Roger Stoltz19-Jun-08 0:04 
ss431 wrote:
Now my question is "What happens if a thread which locks a resource crashes/terminates without unlocking it?"


Well, it depends what kind of resource it is and what kind of synchronization object you've used to control the access to the resource.

If the resource resides only within your process, you should use a critical section (also known as a fast mutex) to synchronize access to the resource from different threads in the process. If the process crashes, you don't have a problem since the resource is gone as well.
A critical section is not a kernel object and is used to synchronize resources between threads in the same process.

If it's a global resource you cannot use a critical section to control access to it, you have to use a kernel object such as a mutex and give it a name (identity) in order for other processes to use the same mutex when accessing the same resource.
If a process that has locked the global resource with a mutex crashes, the mutex remains locked, preventing other processes from locking it and obviously preventing other processes from using the global resource. This scenario will likely freeze your computer.

Mutexes, semaphores and events are kernel objects and can be used for synchronization of access to global resources between processes.
Critical sections are not kernel objects and can only be used within a single process to synchronize access to process local resources such as queues shared between threads.

Reading tips:
To avoid common pitfalls when starting out with multithreaded programming, read this excellent article[^].
To know how to distinguish between when synchronization can or should be avoided and when it's absolutely necessary, read this article[^].
To know how to use synchronization objects, read this article[^].


"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown


AnswerRe: Thread synchronization problems Pin
Mark Salsbery19-Jun-08 6:25
Mark Salsbery19-Jun-08 6:25 
QuestionCombining 2 projects in 1 workspace Pin
kindaichinisan18-Jun-08 21:11
kindaichinisan18-Jun-08 21:11 
AnswerRe: Combining 2 projects in 1 workspace Pin
Cedric Moonen18-Jun-08 21:25
Cedric Moonen18-Jun-08 21:25 
QuestionRe: Combining 2 projects in 1 workspace Pin
kindaichinisan18-Jun-08 22:02
kindaichinisan18-Jun-08 22:02 
AnswerRe: Combining 2 projects in 1 workspace Pin
Cedric Moonen18-Jun-08 22:48
Cedric Moonen18-Jun-08 22:48 
GeneralRe: Combining 2 projects in 1 workspace Pin
kindaichinisan18-Jun-08 23:07
kindaichinisan18-Jun-08 23:07 
GeneralRe: Combining 2 projects in 1 workspace Pin
Rajesh R Subramanian18-Jun-08 23:21
professionalRajesh R Subramanian18-Jun-08 23:21 
JokeRe: Combining 2 projects in 1 workspace Pin
Hamid_RT19-Jun-08 0:06
Hamid_RT19-Jun-08 0:06 
GeneralRe: Combining 2 projects in 1 workspace Pin
Rajesh R Subramanian19-Jun-08 0:24
professionalRajesh R Subramanian19-Jun-08 0:24 
GeneralRe: Combining 2 projects in 1 workspace Pin
Cedric Moonen19-Jun-08 0:09
Cedric Moonen19-Jun-08 0:09 
AnswerRe: Combining 2 projects in 1 workspace Pin
bulg19-Jun-08 11:39
bulg19-Jun-08 11:39 
GeneralRe: Combining 2 projects in 1 workspace Pin
kindaichinisan19-Jun-08 16:14
kindaichinisan19-Jun-08 16:14 
QuestionDebug Assertion Failed! Pin
Le@rner18-Jun-08 21:01
Le@rner18-Jun-08 21:01 
AnswerRe: Debug Assertion Failed! Pin
Cedric Moonen18-Jun-08 21:04
Cedric Moonen18-Jun-08 21:04 
AnswerRe: Debug Assertion Failed! Pin
Hamid_RT18-Jun-08 23:59
Hamid_RT18-Jun-08 23:59 
QuestionRe: Debug Assertion Failed! Pin
David Crow19-Jun-08 3:19
David Crow19-Jun-08 3:19 
QuestionHow to convert a DLL into an exe? Pin
Rennie7618-Jun-08 20:59
Rennie7618-Jun-08 20:59 

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.