The latency in the Linux shell script is still using the sleep or Usleep function.
Detailed as follows: 1, sleep: default is seconds.Sleep 1s indicates a second delaySleep 1m indicates a minute delaySleep 1h indicates a delay of one hourSleep 1d indicates a day delay
2, Usleep: Default to microseconds.
1s = 1000ms = 1000000us
Difference: Sleep can specify not only the seconds, but also the deferr
Timer Timer application Scenarios are very wide, under Linux, there are several ways:
1, using sleep () and Usleep ()
Sleep accuracy is 1 seconds, usleep precision is 1 subtle, the specific code is not written. The disadvantage of using this method is obvious, in Linux system, the Sleep class function can not guarantee the accuracy, especially in the system load is relatively large, sleep will generally h
/item.htm?id=5522416710
http://item.taobao.com/item.htm?id=16551116403
http://item.taobao.com/item.htm?id=14088310973
The principles of the experimental design and the format of the test results are briefly explained: In order to ensure the reliability of the results, each group of experiments repeated 20 times, in a single experiment, given the same set of interface URLs, respectively measuring classic (referring to the classical concurrency mechanism) and rolling (refers to the improved con
Tags: variable tree structure usleep traversal Development port C + + stack process environmentConceptProgram: A file stored on disk that specifies the code to be executed and the action to be performed when it is run.Process: The process of loading a program into a piece of data in memory, the process of executing a program, producing, developing, and dying.Threads: Unix's smallest dispatch unit, a process can have multiple threads, share process IDs
Tags: can usleep stdout col system tin set file Linux1#include 2#include 3#include 4#include 5 6 voidusage ()7 {8 fprintf (stderr,9 "\nusage:mcu_dload [OPTIONS] *.bin\n"Ten "- A specify device i²c slave address (7Bit), eg:-a 5E, default is 0x58\n" One "- D Download binary code for MCU only\n" A "- h This page.\n\n" - ); -Exit0); the } - -uint8_t Asc2hex (CharAsccode) - { + uint8_t ret; - if('0''
microsecond, enough to meet the needs of daily timing. Muduo: Timestamp uses an int64_t to represent the number of microseconds from Epoch to the present, and its range is up to 0.3 million years.Why timerfd _ * is selected:
Sleep/alarm/usleep may use SIGALRM in implementation. processing signals in multi-threaded programs is quite troublesome and should be avoided as much as possible. (Recently I will write a blog to talk about "multithreading, RAII
A summary of several methods for obtaining time and calculating difference between windows and C + +One, standard C and C + + are available1, get time with time_t times (time_t * timer), calculate the difference between using doubleDifftime (time_t timer1, time_t Timer0). Accurate to seconds.The test procedure is as follows:1#include 2#include 3 4 intMain ()5 {6 time_t start, end;7 DoubleCost ;8 9Time (start);TenSleep1); OneTime (end); Acost=Difftime (end,start); -printf"%f\n", cost); -
) { die("$errstr($errno)"); } Else { $msg=Trim($argv[1]); for($i= 0;$i$i++) { $res=fwrite($socket _client, "$msg($i)"); Usleep(100000);//A delay of 1 microseconds (micro second) with a specified number of microseconds is one out of 10,000 seconds. Echo' W ';//number of print writes//debug (fread ($socket _client, 1024));//will generate a deadlock because fread will wait for the data to be read in blocking mode
why the radio permission is the same,
Rild socket cannot be opened here.
As a test, we use include $ (BUILD_EXECUTABLE) to compile an executable file.
You can only change the permission requirements of RILD.
If the program exits immediately after the data is sent to rild, an error is reported;
Cause the server to report: ECONNRESET 104 error connection reset by peer reset connection;
Therefore, you need to perform some latency in the function and cannot end the program running immediately.
Linux/unix systems, this happens.So before using flock, be sure to consider carefully.So there's no solution? In fact, it is not the case. If Flock () is used properly, it is possible to solve the deadlock problem. Of course, if you do not consider the use of the flock () function, there will also be a good solution to solve our problem.Scenario One: When the file is locked, set a time-out.The approximate implementation is as follows:if ($fp = fopen ($fileName, ' a ')) {$startTime = Microtime (
, $ RecvData );If ($ WriteLen === false){// Due to the online shopping problem, there is currently no way to import data.// First sleep for 0.1 seconds and then wait for a while.Usleep (100000 );Continue;}If ($ WriteLen = 0){// The program is being executed on the terminal. The program is closed.Echo "Remote Write Connection Close \ n ";Return;}// When the information retrieved from the external store has been completely sent to the VNC, it will be in the middle of the loop.If ($ WriteLen = strl
;
Int tm_year; relative value, + 1900
Int tm_wday;
Int tm_yday; the day of the current year
Int tm_isdst;}; daylight saving time
4. convert the time in tm format to a string for easy Display
A) Char * asctime (const struct tm * tm)
5. convert the calendar time to a local time string for easy Display
A) Char * ctime (const time_t * timep)
6. obtain the time difference from the early morning of the current day. it is often used for time consumption, end time, and initial
Simulate flock to implement file lock. It mainly provides an idea. $ Lock0 and $ lock1 are the object lock Identifiers. when a file is opened by a user, $ lock0 and $ lock1 are generated, when the file is not opened, there is no primary idea.
$ Lock0 and $ lock1 are the identifier of the file lock. when the file is opened by a user, $ lock0 and $ lock1 are generated. when the file is not opened, it does not exist.
In fact, the most important thing is to have an identifier to indicate the current
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.