Thread & Exception

Hi All,

We have global data structure that is shared across all the threads of the
application. Sometime one of the thread causes exception which results in an
abrupt behavior with the data structure. Is is possible that the exception
may cause corrupting the global data structure such as Semaphore or global
data.

Regards,
Debasish Pramanik


0
7/21/2004 11:46:36 AM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
566 Views

Similar Articles

[PageSpeed] 51

Have you done synchronization with the structure? YOu dod not actually give anything other
than the vague description "global data structure", which is pretty meaningless when it
comes to answering detailed questions about multithreaded access.

Without synchronization, the number of things that can go wrong is so huge there is not
time to eplain everything before I have to leave tonight (in about three hours).

Semaphore would be completely inappropriate. Mutex, or for ideal performance
CRITICAL_SECTION, would be useful for those items which require synchronization, and you
almost certainly do NOT want to use a single global lock for the entire structure or you
will spend all your time wainting to get access.

Tell us something useful about the nature of the structure. Is it just scalars? Are there
pointers? Do you use CString, CArray, CMap, or CList? 

The exception doesn't CAUSE corruption of the structure; the corruption has occurred
because you almost certainly failed to do proper synchronization. The exception is merely
report that corruption has already occurred.
				joe

On Wed, 21 Jul 2004 17:16:36 +0530, "Debasish Pramanik" <debasish.pramanik@assetlink.com>
wrote:

>Hi All,
>
>We have global data structure that is shared across all the threads of the
>application. Sometime one of the thread causes exception which results in an
>abrupt behavior with the data structure. Is is possible that the exception
>may cause corrupting the global data structure such as Semaphore or global
>data.
>
>Regards,
>Debasish Pramanik
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15973)
7/21/2004 10:46:36 PM
There is a structure and a semaphore... what will happen to happen semaphore

regards,
debasish
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
news:sastf0pisrr1iv51qippuesoemtj5ondca@4ax.com...
> Have you done synchronization with the structure? YOu dod not actually
give anything other
> than the vague description "global data structure", which is pretty
meaningless when it
> comes to answering detailed questions about multithreaded access.
>
> Without synchronization, the number of things that can go wrong is so huge
there is not
> time to eplain everything before I have to leave tonight (in about three
hours).
>
> Semaphore would be completely inappropriate. Mutex, or for ideal
performance
> CRITICAL_SECTION, would be useful for those items which require
synchronization, and you
> almost certainly do NOT want to use a single global lock for the entire
structure or you
> will spend all your time wainting to get access.
>
> Tell us something useful about the nature of the structure. Is it just
scalars? Are there
> pointers? Do you use CString, CArray, CMap, or CList?
>
> The exception doesn't CAUSE corruption of the structure; the corruption
has occurred
> because you almost certainly failed to do proper synchronization. The
exception is merely
> report that corruption has already occurred.
> joe
>
> On Wed, 21 Jul 2004 17:16:36 +0530, "Debasish Pramanik"
<debasish.pramanik@assetlink.com>
> wrote:
>
> >Hi All,
> >
> >We have global data structure that is shared across all the threads of
the
> >application. Sometime one of the thread causes exception which results in
an
> >abrupt behavior with the data structure. Is is possible that the
exception
> >may cause corrupting the global data structure such as Semaphore or
global
> >data.
> >
> >Regards,
> >Debasish Pramanik
> >
>
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm


0
7/24/2004 6:43:38 AM
Reply:

Similar Artilces:

MRP Exception
Is there a way to see what MRP is recommending when we receive an MRP exception message of "Item is over supplied"? It states to "Review Orders", but something with more information would be very helpful. Thanks! Elliot ...

Problem with blocking of main thread with other thread
I have a problem with blocking of main thread: My application contains an interpreter and I need to write a debugger for it. The mainframe creates a thread that is interpreting instructions. When I need to break execution of instruction thread, I use WaitForSingleObject(m_WaitEventHandle, INFINITE); in the interpreter thread. Everything works fine until the window is opened from the interpreter. Then the mainframe freezes. When I break execution in VC the call stack for interpreter thread shows: � NTDLL! � KERNEL32! � CDebugManager::CheckBreakpoints() � CInterpreterThread::Run() � _Afx...

Where is my thread?
I posted a question about "Search for a value in multi-dimensionla array" an hour ago; where did that go? On 5/17/2010 17:38, Rick wrote: > I posted a question about "Search for a value in multi-dimensionla array" an > hour ago; where did that go? If you mean the one beginning with "Seach", posted almost half an hour before this one, it is there. :) On 5/17/2010 11:51 AM, Jackie wrote: > On 5/17/2010 17:38, Rick wrote: >> I posted a question about "Search for a value in multi-dimensionla >> array" an >> hour ag...

Unhandled script exception: #2
I get the following error when I am revaluing the P&L. I think it is because in the middle of revaluing, I went elsewhere in GP at the same time. Index 51 of local array is out of range in script 'MCP_To_GL_BB'. Script terminated. EXCEPTION_CLASS_SCRIPT_OUT_OF_RANGE SCRIPT_CMD_NEWLINDEX Any thoughts would be appreciated! Thanks! Found the following: It seems the batch is too large for the system; in this case, you need to run revaluation 3 times for three separate account ranges. Hope this helps, rc "K-" wrote: > I get the following error when I am rev...

Simple Thread
I have created a thread in my MFC Dialog based application, in the thread function i want to have access to a user interface control that is attached to the main dialog. How can I do it? Regards, Mystique Mystique wrote: > I have created a thread in my MFC Dialog based application, in the thread > function i want to have access to a user interface control that is attached > to the main dialog. > How can I do it? > > Regards, > Mystique > > Indirectly, by posting a message to the main thread asking it to update the control. http://www.mvps.org/vcfaq/mfc/12.ht...

Need Help with Busy Dialog Thread
my application would perform a task. I want to stop the user from using the application's GUI untill the the BG task is finished. At first using Modal Dlg did not do the trick as every one now (apart from me) the the CDialog::DoModal() function has to return some how. So, I made a bit of research on the net and found a trick to display the Dialog using CWinThread derived class without stoping the main app window for executing the background task as follows: (1) In your header file define a CWinThread-derived class... class CDialogThread : public CWinThread { DECLARE_DYNCREATE(CDial...

Diaglog/Threading Data Exchange Question
Greetings, I have learned a lot from all of you, and I hope to over come my latest road block. I have a smal IRC Chat client I am making. I have a Dialog Box with Control and I use a worker thread for connecting to IRC - That Thread will update controls on the Dialog by sending PostMessages. Now my problem is in the ListBox Control that I have extended to do popup menu with various commands. I need to be able to read that controls methods from within the Thread. so I need to do this from within my IRC Socket thread: (code not exact - pseudo code) CListBoxEx myUsers; //Defined in my ...

Killing thread from outside thread in MFC App
Hi, Thanks to all those who offered advise on my last query. I successfully used the worker thread method to give control back to the dialog box whilst background processing was being carried out. The issue I have now is closing that thread externally. The method I've used to create the thread uses a volatile boolean variable. Whilever it is set to TRUE, the thread remains alive. However, when I set the variable to FALSE from the calling process (user wants to end processing), it has no effect. The thread continues to run. I thought that declaring the variable as 'volatile'...

To Thread or not to thread
I am using a CRecordset object to retrieve data from a remote server. The time to retrieve the data is highly variable because of network traffic etc etc etc and has varied from a few ms to almost a minute. Question: Is it a good practice to use a worker thread to handle the database exchange to avoid having my main thread block for long periods of time? I assume that I would let the exchange timeout and then check the return status and a global variable to determine if it should keep trying until it returned data ( might be null but that's ok). Ron H. Ron, While it may be a tin...

Anyone care to offer advice for my Client / Server threading model
I'm a bit of a sockets newbie and not too sure what the established ways of handling CAsyncSockets are. I need to handle two way comms between two or more handheld pcs and a server. WIth the server I've got: 1 Thread polling for new connections 1 Thread per client connection. The client thread is stuck in a loop called from CWinThread::InitInstance and sits and calls the CAsyncSocket::Receive function until something arrives. It uses peekmessage and postmessage in this loop to see if the app wants me to send anything to the client. This is working erratically though - peekmessage know...

Threads in MFC
Hi to all... I've made a multithreaded Application (with MFC of course) and it works well on some PC, but in others PC's with the same OS (Win2000SP4) it throws "access Violation" immediatly just when a thread starts. (No matter which one... just the first). I've supposed it was some lib missing, and I've installed VC6... it didn't solve anything. any suggestion? I had a similar problem when I didn't realize I was trying to distribute a DEBUG version of the program. Otherwise, can you post a code snippet? On Mon, 19 Apr 2004 16:55:16 +0200, Nicola Bam...

multi-threaded control not destroyed on exiting the page?
I have created an ActiveX control (subclassing COleControl) which uses the afxRegFreeThreading model, and I have a small sample web page which inserts the control using an <object> tag. I noticed that when my page places the control inside the <head> tag, the control's destructor is called when my browser goes to a different page. But if the control is inside the <body> tag, the destructor is not called when I leave the page. The control's destructor is eventually called when I exit my browser, but I fear that my control is continuing to occupy system resources unt...

MAD monitoring thread?
I have Exchange 2000 running on a Win2K Server. I have a trust to an NT4 domain with an Exchange 5.5 Server. Both are in the same site and my goal is to move the mailboxes and whatnot to the Exchange 2000 box. So far, just getting 2000 to operate has been a problem. It's installed and running but my MS Exchange Info Store and MTA stacks won't start in the services. If I reboot, they start, but stop within a few minutes. I have errors in my application log for MSExchangeSA that say, "The MAD monitoring thread was unable to read its configuration from the DS." I have MSEx...

BUG: CArchive exception: badClass
When using CMapStringToOb to serialize the object elements to disk from inside an MFC DLL, the following error occurs: Warning: Cannot load CDAFilter from archive. Class not defined. CArchive exception: badClass. First-chance exception at 0x77e73887 in DA.exe: Microsoft C++ exception: CArchiveException @ 0x0012e74c. It appears that this was a know bug for Visual Studio .NET 2002 http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q322621 but why has it still not been fixed in Visual Studio .NET 2003 ?? If i move the exact same source code to outside the DLL it works perfectly. Similarly...

A thread within a thread...
Hi, If i create a thread within a thread, something like... void threadA(void lparam ) { ... (HANDLE)_beginthread(ThreadB,0,someotherlparam); ... // do more work _endthread(); // done } My question is what happens to the thread i created, (threadB), if it is not finished? Is it safe, good?, to stop threadA without waiting for threadB. Many thanks Sims There is no concept of "a thread within a thread". All threads are within a process, and they are all peers of each other. DO NOT use _beginthread in an MFC program. This is asking for trouble. An...

why CStatic.m_hWnd not valid use realtime thread
Hi All I build an MFC app, and loadlibrary a dll which use high priority (realtime level ) threads for serial communication but after freelibrary the dll, some CStatic and CEdit objects not valid, their m_hWnd becomes to NULL How can I restore these CWnd objects? Is OS release them thanks, waiting online ...

threads #2
I have a server/client application that communicates using threads. The server class uses a while loop inside a thread to wait for new connections in accept state, like this: var a = new var( ); while( (server.Accept(connection)) ) { ...... ...... } I have declared a variable (var) right before this loop which uses memory. I want to free/delete this variable at the end of the while loop, but the control never reaches there. How can I make sure that this variable gets deleted before the server side exits? Thanks. Jessica Jessica Weiner wrote: > I have a server/client applicatio...

Destroy thread and Terminate thread
Hi, is there any difference between "Destroy thread and Terminate thread" regds vinay "Vinay" <v.sheel@mailcity.com> wrote in message news:uXR4ntHIEHA.2576@TK2MSFTNGP09.phx.gbl... > Hi, > is there any difference between > "Destroy thread and Terminate thread" > regds > > vinay > > A quote from the docs: "TerminateThread is a dangerous function that should only be used in the most extreme cases." destroyThread, on the other hand, deletes the thread object created by createThread. The thread should be terminated by some o...

Start background thread when a UI button is clicked, and Update UI button from background thread
I was asked these questions during a technical interview: 1) When the user clicks on a button on the form and that invokes a lot of heavy-duty calculations, what would you do? My answer: I would use "BeginInvoke" to start a background worker thread to do the heavy-duty calculations, in order to avoid blocking the main UI thread. Then he asked, "What does 'BeginInvoke' do"? I said it was a .NET pattern to start a background thread from a UI thread. Did I get it right? 2) Why can't you simply update a button on the UI thread from a background ...

how to get thread view in newsgroups?
I used to access newsgroups via Outlook Express where all messages within newsgroups were grouped in their threads with a collapse/expand plus or minus sign which was convenient and intuitive. Each one would indent according to which previous message was answered. Having moved to Windows Live Mail and accessing my newsgroups via this prog. now, I don't seem to be able to find the same kind of display option. All messages display independently in date order, and I can't find a way to group them in their normal thread except by entering something from the thread in the ...

Message Threads
Is there a way to organize a mail folder so that messages are organized similar to newsgroups? Based on whether or not the message is a reply? Thanks in advance for your help (Outlook 2003 in Windows XP Pro) Dave Have you tried the Arrange By Conversation view? -- Jocelyn Fiorello MVP - Outlook *** Messages sent to my e-mail address will NOT be answered -- please reply only to the newsgroup to preserve the message thread. *** In news:eYJDeGJ%23DHA.2212@TK2MSFTNGP10.phx.gbl, Dave wrote: > Is there a way to organize a mail folder so that messages are > organized similar to news...

Thread Pool Class?
Can anyone recommend a good thread pool class? "Don Gurr" <dongurr@REMOVEshaw.ca> ha scritto nel messaggio news:2do6n.2339$RS6.61@newsfe15.iad... > Can anyone recommend a good thread pool class? Have you tried CThreadPool from ATL (I believe it can be used in MFC code as well)? http://msdn.microsoft.com/en-us/library/9tz6fz1e(VS.80).aspx HTH, Giovanni Thanks, it appears to work. "Giovanni Dicanio" <giovanniDOTdicanio@REMOVEMEgmail.com> wrote in message news:Ose%23WA7mKHA.2544@TK2MSFTNGP04.phx.gbl... > "Don Gurr"...

My Threads
I just cant seem to figure out how to see all my postings since i started how do i see my own only thanks On Thu, 29 Apr 2010 11:27:01 -0700, Amin <Amin@discussions.microsoft.com> wrote: >I just cant seem to figure out how to see all my postings since i started how >do i see my own only thanks The Search function on the Microsoft webpage is broken; I've never been able to get it to work. What you can do instead is use a competitor's product: http://groups.google.com. Use Advanced Search to search for your posts, e.g. searching for amin@discussions.microso...

how to end a thread from the main thread
how to end a thread from the main thread Regards, Mystique Mystique wrote: > how to end a thread from the main thread Ending a thread directly from another thread should always be considered not an option. If you want to end a UI thread, post a WM_CLOSE message to it and let it terminate itself. If you want to end a worker thread, use a variable to signal to the thread that it's time to shut down. If you need to wait until the thread is shutdown, wait on it's handle in the main thread. Which type of thread are you using? Josh McFarlane See my essay on worker threads on...

Off group subject but...how do MVPs follow threads ?s
I've been curious as to how a MVPs (or others with many posts and replies) keeps track of posts/threads? Do you download all threads? Or leave online and let your "newsreader" maintain all history? Or ____? I've always done the former. I manage all newsgroup activity in my mail program. I send a copy of my posts to myself and redirect a copy of all replies. I often, well sometimes ;), access those archived posts but it is somewhat time consuming process and I'm interested if there are more efficient alternatives. I've posted similar questions to t...