From: "Theewara Vorakosit" <thvo@ksc.th.com>
To: linux-c-programming@vger.kernel.org
Subject: Pthread consume 100% CPU
Date: Mon, 19 Aug 2002 21:20:38 +0700 [thread overview]
Message-ID: <001101c2478b$97519e50$1e226c9e@eternity> (raw)
Dear All,
I developer multithread programming on linux using pthread. I use C++
language. I implement my thread as a class. Here is my class:
static void *thread_func(void *rv)
{
((Thread *) rv)->run();
return NULL;
}
int Thread::start(void)
{
int retval;
sigfillset(&newset);
pthread_sigmask(SIG_BLOCK, &newset, &oldset);
pthread_attr_init(&attr);
retval = pthread_create(&(this->pt), NULL, thread_func, this);
pthread_sigmask(SIG_UNBLOCK, &newset, &oldset);
return retval;
}
int Thread::join(void)
{
int retval;
pdebugl();
retval = pthread_join(this->pt, NULL);
pdebugl();
return retval;
}
To create thread, inherited this class, new it and call start method. After
call pthread_create, there are 3 processes of my program, right? I call
method join, and exit from my main. My program exits normally. However,
there is thread process still running at 100% reported by top. I also get
command prompt from my shell. Would you please tell what cause this problem?
Thanks,
Theewara
reply other threads:[~2002-08-19 14:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='001101c2478b$97519e50$1e226c9e@eternity' \
--to=thvo@ksc.th.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).