- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- USLEEP -vs- NANOSLEEP
Operating System - Linux
1819719
Members
2897
Online
109606
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2010 12:31 PM
тАО04-05-2010 12:31 PM
Hello group;
I have an old laptop that wasn't doing anything, so I loaded Linux on it and wrote a program to send my e-mail in morse code (so I can "listen" to my e-mail while I do other things).
I'm using "usleep" to time the length of the morse code bits.
The problem is that usleep does not appear to work uniformly i.e. I have a formula to change the speed of the morse code - but although the speed should change progressively, it does not.
After reading the manpage I'm guessing that the system is truncating or rounding-off the time (note that the CPU/IO/memory usage is close to nil).
Do [you] think if I rewrite the program to use "nanosleep" that I will see better performance?
regards,
tonyp
(as usual, any reply I get that at least gives me something worth investigating will get 5 points. Replies that lead to the solution will get 10)
I have an old laptop that wasn't doing anything, so I loaded Linux on it and wrote a program to send my e-mail in morse code (so I can "listen" to my e-mail while I do other things).
I'm using "usleep" to time the length of the morse code bits.
The problem is that usleep does not appear to work uniformly i.e. I have a formula to change the speed of the morse code - but although the speed should change progressively, it does not.
After reading the manpage I'm guessing that the system is truncating or rounding-off the time (note that the CPU/IO/memory usage is close to nil).
Do [you] think if I rewrite the program to use "nanosleep" that I will see better performance?
regards,
tonyp
(as usual, any reply I get that at least gives me something worth investigating will get 5 points. Replies that lead to the solution will get 10)
REMEMBER: Once you eliminate your #1 problem, #2 gets a promotion.
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2010 11:01 PM
тАО04-05-2010 11:01 PM
Solution
Hi,
this person seems to think that nanosleep gave him more accurate results.
http://cc.byexamples.com/2007/05/25/nanosleep-is-better-than-sleep-and-usleep/
regards
Matt
this person seems to think that nanosleep gave him more accurate results.
http://cc.byexamples.com/2007/05/25/nanosleep-is-better-than-sleep-and-usleep/
regards
Matt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2010 06:32 PM
тАО04-06-2010 06:32 PM
Re: USLEEP -vs- NANOSLEEP
Matt: thanx for the URL.
They have the answer there. Now all I need to do is figure out how to use their function in my program. :-)
regards,
tonyp
They have the answer there. Now all I need to do is figure out how to use their function in my program. :-)
regards,
tonyp
REMEMBER: Once you eliminate your #1 problem, #2 gets a promotion.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP