/*** Write lock test* Open thread 1*/Require ("file_lock.php ");$ Lock = new File_Lock (dirname (_ FILE _). "/FileLock. lock ");/** The lock speed of a single thread is 30 thousand times per second. **//** Two threads write, 20 thousand of the data is about 7 s *//** Write data in one thread. The data size of 10 thousand is about 3.9 s. The two files are written at the same time, which is faster *//** If the lock is not performed, it takes about 2.8 seconds for a process to w
(unsigned int seconds );Sleep () will cause the current program to fall into "hibernation" seconds, unless it receives a "uncertain" signal.If sleep () is not full, it returns the remaining sleep time; otherwise, it returns zero.
Void usleep (unsigned long USEC );Usleep is similar to sleep (), and the unit of seconds is 10e-6 seconds.
Int select (0, null, struct timeval * TV );You can use the select functi
. Suppose you don't want the data for Send () to be cached locally until a certain number is sent, but send () How many times it is sent. The safe way is to call the Usleep () function after each send , giving the system a response time. below The sample demonstrates the send () The speed of the call to the data whether the packaging effect, staring at Server usleep (
Tcp_nodelay is
three different kinds of sleep accuracy1.sleep#include RETURN VALUEZero If the requested time has a elapsed, or the number of seconds left to sleep,If the call is interrupted by a signal handler.Example int sleeptime = 5;do{ sleeptime = Sleep (sleeptime);} while (Sleeptime > 0);2.usleep (in microseconds)int Usleep (useconds_t usec);The type useconds_t is a unsigned integer type capable of holding integer
Information Store:
The database is designed as information ID (msgid), Sender (sender), receiver (receiver), information content, set Senderread and Receiverread to mark whether the information has been read, read after the change of the mark, To distinguish whether the information has been read.
CREATE TABLE msg{
MsgId int not null primary key auto_increment,
sender char not NULL,
receiver Char (a) Not NULL, content
text,//message contents with text type, storage up to 65535 chara
1. The default frequency of the system timer in the x86 architecture is 100, that is, the clock interrupts 100 times per second on i386 processing. Therefore, a clock interrupt is generated every 10ms in the i386. 2, the process scheduling, may be the initiative to give up the CPU, or may be the clock interrupt to let the CPU. 3, control CPU utilization, is actually control CPU in totaltime time busy time busytime. The ratio of busytime and totaltime is CPU utilization. 4, there are many ways to
If you are under Linux, first confirm whether to add Ob_start () and Ob_flush ().
Copy Code code as follows:
Ob_start ();
For ($i =1 $i echo $i. " Ob_flush ();
Flush ();
Usleep (500000);
}
If you still can't output, precede the code with the header information
Copy Code code as follows:
Header ("CONTENT-TYPE:TEXT/HTML;CHARSET=UTF8;");
Ob_start ();
For ($i =1 $i echo $i. " Ob_flush ();
Flush ();
The purpose of using a timer is to perform a task periodically, or to perform a task at a specified time. In order to achieve this goal, there are generally two common and more effective methods. One is to use the Linux internal three timers, the other is with sleep, usleep function let the process sleeps for a period of time, in fact, there is a way, it is to use Gettimeofday, difftime and so on their own to calculate the time interval, and then time
file downloads. That's why browsers know the download progress.
For example, here I wrote a virtual script to simulate a slow download.
// it"s a zip fileheader("Content-Type: application/zip");// 1 million bytes (about 1megabyte)header("Content-Length: 1000000");// load a download dialogue, and save it as download.zipheader("Content-Disposition: attachment; filename="download.zip"");// 1000 times 1000 bytes of datafor ($i = 0; $i echo str_repeat(".",1000); // sleep to slow down the download
Recently to use PHP process to send the reward, because to be accurate to the second execution, the Linux system timing is not used, so wrote a dead loop, usleep is necessary, otherwise the system CPU occupies a very high system CPU.A problem was encountered when executing, and the process was terminated after shutting down the terminal. The workaround is documented here.Define(' In_web ', ' true ');Set_time_limit(0);include(dirname(__file__)." /.. /c
running with the system. You can customize the start-up service here, and press F1 to see a description of each service. Introduction to the system services.
3 Appendices
3.1 Examples of service script files
#!/bin/bash
#
# Autoruntest The shell script takes care of Autoruntest auto start and stop
#
# chkconfig:2345 20 80
# Description:autoruntest
# ProcessName:/etc/rc.d/init.d/autoruntest
Exec_path=/home/robin/code
Exec=autoruntest
Pid_file=/var/
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.