Re: AfxBeginThread startup times and overhead
From: A. J. Rappaport (please.reply.in.newsgroup.only_at_spamsucks.com)
Date: 05/30/04
- Next message: Jerry Coffin: "Re: function used by more than one class"
- Previous message: Michael T. Pudelko: "Re: Is TRACE function is thread-safe?"
- In reply to: Joseph M. Newcomer: "Re: AfxBeginThread startup times and overhead"
- Next in thread: Jerry Coffin: "Re: AfxBeginThread startup times and overhead"
- Reply: Jerry Coffin: "Re: AfxBeginThread startup times and overhead"
- Reply: Joseph M. Newcomer: "Re: AfxBeginThread startup times and overhead"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 29 May 2004 23:29:20 -0400
On Sat, 29 May 2004 22:09:37 -0400, Joseph M. Newcomer
<newcomer@flounder.com> wrote:
>>for ( i = 0; i < 3; ++i )
>>{
>> AfxBeginThread( ThreadStartingFct, &i )
>> Sleep( 5 );
>>}
>>
>>unsigned int ThreadStartingFct( LPVOID seq )
>>{
>> int localSeq = seq;
>****
>This code won't even compile; I have no idea how you could use it. And according to what
>you did, if it compiles, it tries to store into an int-sized variable a pointer-sized
>value, which would lose data.
Of course you are right, I meant to say
int* localSeq = (int*)seq;
... which in fact is what's in my code.
As for spinning on a flag, I understand that's not the "right" way,
but I'm a little curious why you consider that such a bad design in
this specific simple example. Your favored approach of mutexes,
semaphores, etc. are by their nature blocking mechanisms, so
presumably the same types of lockups can happen if the semaphore
doesn't show up or the mutex doesn't get released as if the flag
doesn't get cleared.
As for the rest of what you all have advised me, you have given me a
lot of help and a lot to think about and I thank you.
- Next message: Jerry Coffin: "Re: function used by more than one class"
- Previous message: Michael T. Pudelko: "Re: Is TRACE function is thread-safe?"
- In reply to: Joseph M. Newcomer: "Re: AfxBeginThread startup times and overhead"
- Next in thread: Jerry Coffin: "Re: AfxBeginThread startup times and overhead"
- Reply: Jerry Coffin: "Re: AfxBeginThread startup times and overhead"
- Reply: Joseph M. Newcomer: "Re: AfxBeginThread startup times and overhead"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|