global variable. Each time one ticket is sold, the number of tickets is reduced by one. The synchronized pthread_mutex_t is also a global variable, which is used for thread synchronization.
void* HelloWorld::th_run(void *r){Student *s=(Student*)(r);CCLog("name is %s,and age is %d,sex is %s",s->name.c_str(),s->age,s->sex.c_str());delete s;while(true){pthread_mutex_lock(mutex);if(ticket>0){CCLog("thread run sell %d",ticket);ticket--;pthread_mutex_unlock(mutex);}else{pthread_mutex_unlock(mutex);b
parameter to the default value */
Beep_parms_t parms = {default_freq, default_length, default_reps, default_delay };
/* Analyze parameters. If possible, update the audible parameters */
Parse_command_line (argv, parms );
/* Open the console and terminate the program if it fails */
If (console_fd = open ("/dev/DSP", o_wronly) =-1)
{
Fprintf (stderr, "failed to open console./N ");
Perror ("open ");
Exit (1 );
}
/* Start to let the speaker speak */
For (I = 0; I
{/* Do not know
receiver is incomplete.
(4) there may be other reasons. Please add them later.
[Solution]
(1) Check the serial port parameter settings of the sender and receiver. In addition, check the serial code at both ends carefully.
(2) Close the serial port instead of opening it frequently.
(3) Add the latency code to the sender program.
[Latency function]
The latency function in Ubuntu is:Sleep () // secondsUsleep () // millisecond level, 1 second = 10 ^ 6 millisecondsNanosleep () // nanoseconds, 1
Application:# Include Usleep (n) // n microsecondsSleep (n) // n MsSleep (n) // n secondsDriver:# Include Mdelay (n) // milliseconds implementation# Ifdef notdef# Define mdelay (N )(/{Unsigned long MSEC = (n); While (MSEC --) udelay (1000 );})# Else# Define mdelay (N )(/(_ Builtin_constant_p (n) (n) ({Unsigned long MSEC = (n); While (MSEC --) udelay (1000 );}))# EndifCall the udelay of ASM/delay. h. The udelay should be a latency of nanoseconds.
DoS:
the spin-Wait loop. Http://blog.csdn.net/misterliwei/article/details/3951103 D. Waiting for a long time or not get the lock, had to let out the CPU. But must let out a very small for a while. Otherwise it will not be called spin lock. How to let out the CPU, but there can be quickly back? The kernel provides the sched_yield () function sched_yield (). The main function is to run a thread with another level equal to or higher than the current thread. If there is no qualified thread, the function
you have time to video, you can use a timer (reduce power consumption) to open a thread.
H264 and AMR-NB are transplanted from opencore, the mobile phone with baseline enough. If you want to support AAC, you can use the AAC decoder of Helix or opencore AAC decoder.
The latency caused by JNI decoding and re-transmission to the display on the Java layer is intolerable. Therefore, you can directly render the image and sound on the ndk layer. You can refer to the practices in the android FFMPEG ope
the receiver, so that the read and write operations will continue. When the buffer zone is full, the eagain error will occur (refer to manAnd ignore the data sent in this request. therefore, the socket_send () function needs to be encapsulated to handle this situation. This function will try to write the data and then return it. "-1" indicates an error. Within socket_send (), when the write buffer is full (send () returns-1 and errno is eagain), the system will wait and try again. this method i
This article provides a detailed analysis of the solution for flush () not output in sequence. For more information, see if you want to add ob_start () in linux () and ob_flush ().
The code is as follows:
Ob_start ();
For ($ I = 1; $ I Echo $ I ."
\ N ";
Ob_flush ();
Flush ();
Usleep (500000 );
}
If the output is still unavailable, add the header information before the code.
The code is as follows:
Header ("Content-Type: text/html;
file_size and file_size_new are both 0.
Update the file_size_new file size in the loop. Note that before getting the file size in php, run the clearstatcache () function to clear the file status cache. Otherwise, the file size may be deviated.
Calculate add_size = file_size_new-file_size to check whether the file size has changed. if there is any change, move the file pointer to the specified position, and then output the newly added content to update the file_size value to new_file_
Linux registration system service registers a system service and starts it automatically upon startup. www.2cto.com 1 script # vim test. sh [python] #! /Bin/bash # description: hello. sh # chkconfig: 2345 20 81 EXEC_PATH =/usr/local/EXEC = hello. sh DAEMON =/usr/local/hello. sh PID_FILE =/var/run/hello. sh. pid. /etc/rc. d/init. d/functions if [! -X $ EXEC_PATH/$ EXEC]; then echo "ERROR: $ DAEMON not found" exit 1 fi stop () {echo "Stoping $ EXEC... "ps aux | grep" $ DAEMON "| kill-9 'awk' {prin
Analysis of run loop in iOSAnalysis of run loop in iOS
Although runloop is an important concept related to thread thinking, runloop in cocoa is not used much at all, but it is not getting started with its "why" in related blog posts ". So a few days of study, I have to share a rough text, as a note, write down its own. I am not very grateful for any errors or errors.Run loop
After the thread is executed, it will be destroyed. To keep the thread running, we can get a run loop in the thread to kee
functions from Windows to Linux
Suppose you have some code written in the Windows environment. If you want them to run in the Linux environment, the condition is that you must keep the original API signature called. For example, if Sleep exists in Windows and the corresponding function in Linux is usleep, how can we keep the original function name called? The following code is used as an example:
Void Sleep (unsigned int useconds){// 1 mill
Note:
1. When socket_bind is used, the IP address cannot be a real loopback address, for example, 127.0.0.1.
2. When server. php is running in the backgroundNohup PHP server. php>/var/tmp/a. log 2> 1
I. UDP
1) server. php
PHP // Error_reporting (e_all ); Set_time_limit (0 ); Ob_implicit_flush (); $ Socket = Socket_create (af_inet, sock_dgram, Sol_udp ); If ($ Socket === False ){ Echo "Socket_create () failed: reason:". socket_strerror (socket_last_error (). "\ n" ;} $ OK =
PHP5 common function list overview. The usleep () function delays code execution in several microseconds. The unpack () function unpacks data from binary strings. The uniqid () function generates a unique
The usleep () function delays code execution in several microseconds.
The unpack () function unpacks data from binary strings.
The uniqid () function generates a unique ID based on the current time in mic
Analysis and Research on process lock issues .? Php *** write lock test * open thread 1 * require (file_lock.php); $ locknewFile_Lock (dirname (_ FILE __)). fileLock. lock); ** the lock speed of a single thread is 1.
/**
* 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 d
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.