Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Pthread sleep cycle problem

Reply
Thread Tools

Pthread sleep cycle problem

 
 
lokb
Guest
Posts: n/a
 
      07-14-2004
Hi,
I am creating a detach thread as shown below and caling pthread_create in
a while loop where the file names in the directory are fetched and is
passed as a parmater to pthread create. The apilcation is running fine
except for the sleep cycle.
My sleep cylce is sleep(5) which is halting all the threads created from
execution. What i need here is the main thread creating the pthread should
only sleep but not all the threads created.
Is there any best way other than sleep to do that.
Plz suggest.
I am including the snapshot of the code to be more precise in what we
are doing.

code snapshot
=============
pthread_attr_t tThreadAttr;
pthread_t tThreadId;
pthread_attr_init(&tThreadAttr);

pthread_attr_setdetachstate(&tThreadAttr, PTHREAD_CREATE_DETACHED);

pthread_attr_setstacksize(&tThreadAttr, iSetStackSize);
//picGetInputpath is the directory path name where it
//has to look for the files
if ((dirBuff = opendir(picGetInputpath)) != NULL){
while ((direntBuff = readdir(dirBuff)) != NULL){
//picExtension is the entension of the file name to which
//am comparing with.
if (!(iCOMPARE(direntBuff->d_name, picExtension))){
picFullPath = new char[strlen(picGetInputpath) +
strlen(direntBuff->d_name)+ strlen(picRenameExtension) + 2];
strcpy (picFullPath, picGetInputpath);
strcat (picFullPath, "/");
strcat (picFullPath, direntBuff->d_name);
pthread_create (&tThreadId, &tThreadAttr, PCLoadINDOUT,
(void*)picFullPath);
}
sleep(5); // main problem -- making all the threads already created to
sleep.
}
}

pthread_attr_destroy(&tThreadAttr);

Let me know if you need any more information.
Thanks,
lokb

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      07-14-2004
lokb wrote:
> I am creating a detach thread as shown below and caling pthread_create in
> a while loop where the file names in the directory are fetched and is
> passed as a parmater to pthread create. The apilcation is running fine
> except for the sleep cycle.
> My sleep cylce is sleep(5) which is halting all the threads created from
> execution. What i need here is the main thread creating the pthread should
> only sleep but not all the threads created.
> Is there any best way other than sleep to do that.
> Plz suggest.


Nether mentioned function is part of C++ standard library. As such
their behaviour is unknown here. Post your platform-specific question
to a platform-specific newsgroup, please.

V
 
Reply With Quote
 
 
 
 
lokb
Guest
Posts: n/a
 
      07-14-2004
I am building this application on AIX 5L, using c++.

Tha C++ library used is pthread.h

 
Reply With Quote
 
Howard
Guest
Posts: n/a
 
      07-14-2004

"lokb" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) lkaboutprogramming.com...
> I am building this application on AIX 5L, using c++.
>
> Tha C++ library used is pthread.h
>


Understood. But that doesn't make it topical to this newsgroup. This is a
language newsgroup, where the discussions are intended to revolve the C++
language, as defined by the C++ Standard. It's not a group for discussing
issues with implementing C++ code on specific platforms, or for
platform-specific tasks such as threads, graphics, file systems, etc.

You'll get much better responses in a newsgroup devoted to the platform
(operating system) or toolset you're programming for.

-Howard



 
Reply With Quote
 
Peter van Merkerk
Guest
Posts: n/a
 
      07-14-2004
lokb wrote:
> Hi,
> I am creating a detach thread as shown below and caling pthread_create in
> a while loop where the file names in the directory are fetched and is
> passed as a parmater to pthread create. The apilcation is running fine
> except for the sleep cycle.
> My sleep cylce is sleep(5) which is halting all the threads created from
> execution. What i need here is the main thread creating the pthread should
> only sleep but not all the threads created.
> Is there any best way other than sleep to do that.


pthread functions are not part of the standard C++ library, so your
question is not topical here. Your question would be more topical in
comp.programming.threads or in a newsgroup dedicated to your operating
system.

--
Peter van Merkerk
peter.van.merkerk(at)dse.nl
 
Reply With Quote
 
lokb
Guest
Posts: n/a
 
      07-14-2004
Hey
sorry for the posting, I am searching for a forum to post this question
and i posted in same question in couple of forums but didn't get a
response.
Can u plz let me know whats the newsgroup under talkabout programming
this question would fit.
Thanks in advance for directing me.
Thanks,
lokesh

 
Reply With Quote
 
lokb
Guest
Posts: n/a
 
      07-14-2004
Hey
sorry for the posting, I am searching for a forum to post this question
and i posted in same question in couple of forums but didn't get a
response.
Can u plz let me know whats the newsgroup under talkabout programming
this question would fit.
Thanks in advance for directing me.
Thanks,
lokesh

 
Reply With Quote
 
red floyd
Guest
Posts: n/a
 
      07-14-2004
lokb wrote:
> Hey
> sorry for the posting, I am searching for a forum to post this question
> and i posted in same question in couple of forums but didn't get a
> response.
> Can u plz let me know whats the newsgroup under talkabout programming
> this question would fit.
> Thanks in advance for directing me.
> Thanks,
> lokesh
>

comp.programming.threads
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sleep 0.2 acts more like sleep 1 Richard Ruby 7 05-22-2007 08:02 PM
STL map and pthread performance problem on Linux/GCC nan.li.g@gmail.com C++ 9 08-18-2005 03:26 PM
pulling my hair out, why won't Kernel.sleep(0) sleep? Sam Roberts Ruby 16 02-18-2005 08:27 PM
What is the difference between Thread.sleep(10) and Thread.currentThread().sleep(10) ? Gonzalo Moreno Java 2 04-05-2004 05:41 PM
PThread Problem (Urgent Help Needed) R Mar Java 0 01-03-2004 12:33 PM



Advertisments