Re: pthreads slows computer & kills program



Ian Semmel <anyone@xxxxxxxxxxxxxxxxx> wrote:


"Rainer Weikusat" <rweikusat@xxxxxxxxxxx> wrote in message
news:87abjfmq2s.fsf@xxxxxxxxxxxxxxxxx:

"Ian Semmel" <anyone@xxxxxxxxxxxxxxxxx> writes:

[...]


If you read my post, you might see what the real question was.


Quoting this:

,----
| I basically have
|
| pthread_mutex_init ( & mutex, 0 );
| pthread_cond_init ( & cond, 0 );
| pthread_mutex_lock ( & mutex );
| cerr << "Ready to call cond_wait" << endl; // does this
| pthread_cond_wait(& cond, & mutex);
| cerr << "Got past cond_wait " << rc << endl; // doesn't get here
|
| Computer just slows down and eventually a 'Killed' message is displayed
`----

Expanded into something which actually compiles:

#include <pthread.h>
#include <stdio.h>

int main(void)
{
pthread_mutex_t mutex;
pthread_cond_t cond;
int rc;

pthread_mutex_init ( & mutex, 0 );
pthread_cond_init ( & cond, 0 );
pthread_mutex_lock ( & mutex );

fputs("Ready to call cond_wait\n", stderr);

rc = pthread_cond_wait(& cond, & mutex);

fprintf(stderr, "Got past cond wait: %d\n", rc);
return 0;
}

Compiling this with gcc a.c -lpthread yields an exectuable which just
blocks, consuming no CPU time at all.

Conclusion: Your problem is that you believe to be suffering harmful
effects caused by phenomena which are demonstrably absent. Consider
consulting a psychatrist.

HTH.

Well, that is what it is supposed to do until it is signalled. It is in
a thread.

I suppose I could have included the 12000 lines or so of the program in
the post but I thought I was dealing with experienced programmers.

I should have known better.

You might lost the attitude. You're _asking_ people to help you with
your problem, they aren't getting _paid_ to help you, and you haven't
asked a recognizable question, just posted some code with prceious
little explanation. I'd suggest you actually _read_ some of the
references on how to ask an _intelligent_ question.

Jerry

.



Relevant Pages

  • Re: pthreads slows computer & kills program
    ... Quoting this: ... Expanded into something which actually compiles: ... int main ... I suppose I could have included the 12000 lines or so of the program in the post but I thought I was dealing with experienced programmers. ...
    (comp.os.linux.development.apps)
  • Problem in compiling a C code with MSVC++6.00
    ... When I save the file as a cpp file, it compiles and runs ... int p1; ... void checkfile; ... printf("cannot allocate memory for elements!"); ...
    (comp.lang.c)
  • Re: Errors in compilation of simple programme
    ... using namespace std; ... cin>> i; ... it compiles without a problem on Visual C++ ... int main ...
    (microsoft.public.vc.language)
  • Re: Prime Numbers
    ... /*This code finally compiles as a 'c' code ... One more question....if i don't free up the memory allocated at the end ... it would appear that we are best served by an array ... prime numbers can be represented by an unsigned long int. ...
    (comp.lang.c)
  • Re: Newbie questions
    ... It compiles ... float getLowest(float array, int length); ... float getLowest(float array[], int length) { ... before printing a second prompt. ...
    (comp.lang.c)