Fedora Linux Support Community & Resources Center
  #1  
Old 15th December 2004, 02:02 AM
mnguyen Offline
Registered User
 
Join Date: Sep 2004
Posts: 49
A way to make a thread sleep

Hi guys,

I'm working on my school project using C/C++ languages. There is a module in which I need to do tasks simultaneously. So I am using the POSIX thread (pthread library) available in the libc.

My problem is : sometimes, i want my thread to suspend an amount of time (say 500ms). The current function I am using is sleep(). However, this function suspends the thread in term of "second" (I remember that the sleep() function of Java works in term of millisecond). Do you know any way to force my thread to suspend in term of milisecond ? (not using a loop since it would keep the CPU busy)
Reply With Quote
  #2  
Old 15th December 2004, 02:42 AM
james_in_denver Offline
Registered User
 
Join Date: Oct 2004
Posts: 1,227
Looks like you can use "getitimer", throw an exception or a signal when the timer expires, and either catch the exception, or trap the signal......
__________________
Only dead fish go with the flow....

Hmmm, what did I miss?
Reply With Quote
  #3  
Old 15th December 2004, 05:36 AM
rogue Offline
Registered User
 
Join Date: May 2004
Posts: 129
The usleep() function will suspend thread execution for the specified number of microseconds... with all of the signals and interrupts that go on, I wouldn't count on any degree of accuracy though.

Real Time Linux is meant to overcome that limitation of the kernel, but last I heard Linus rejected all of the patches. It was too ambitious for 2.6 stable but maybe RT is something to look for in 2.7?
Reply With Quote
Reply

Tags
make, sleep, thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
main-notification can't make me sleep GalGavu Using Fedora 2 10th September 2009 12:41 PM
make a kernel module sleep or delay by few seconds Maninder Using Fedora 0 1st May 2008 09:03 AM
Need Thread Tool to mark thread Solved fc3user Suggestions & Feedback 5 9th May 2005 04:29 PM
Force the author of a thread to close the thread before authoring a new post ben_leah Suggestions & Feedback 2 12th April 2005 12:48 PM


Current GMT-time: 13:08 (Thursday, 23-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat