Re: AfxBeginThread startup times and overhead

From: A. J. Rappaport (please.reply.in.newsgroup.only_at_spamsucks.com)
Date: 05/30/04


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.



Relevant Pages

  • Re: Linux 2.6.30.2: does not boot
    ... Yes, as Marcel Beister pointed, it resulted some binutils bug. ... Wolfgang hasn't actually tried to compile without the -fno-strict-overflow ... flag yet, and maybe his hang is the same binutils bug. ... maybe I missed some gcc flag confirmation that wasn't cc'd to ...
    (Linux-Kernel)
  • Re: Real-Time Preemption and UML?
    ... of the stuff I needed to change to at least get it to compile: ... One of the problems was use of direct architecture specific semaphores ... look at the code told me that completions ought to be ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: Using Rake to compile FreeBASIC code
    ... compiled twice, once normally for use as a library, and once with the ... especially the flags that are sent to the compile. ... double check the -m flag. ... Still learning ruby but now I want to run ...
    (comp.lang.ruby)
  • RE: Compile error on RH 9
    ... I removed the -DSYSV flag, ... Compile error on RH 9 ... Anyone have a clue why there's a parse error on that line? ... -- redhat-list mailing list unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe ...
    (RedHat)
  • Re: Real-Time Preemption and UML?
    ... > some of the stuff I needed to change to at least get it to compile: ... Therefore I changed two semaphores to completions ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)