IOS function Accumulation

Source: Internet
Author: User

Header file: units. H

Syntax: void usleep (int micro_seconds);

return value: None

Description: This function temporarily causes the program to stop executing. The parameter micro_seconds is the subtle number to pause (US).

Description

This function does not work in the Windows operating system. Used under the test environment of Linux

See also: Usleep () is similar to sleep () for delaying the suspend process. The process is suspended and placed in the Reday queue.

In general, use the sleep () function whenever possible, when the delay is the magnitude of the second S. If the delay time is dozens of milliseconds MS or less, use the Usleep () function whenever possible. This will make the best use of CPU time.

Clock Unit conversions:

Subtlety (US: English microsecond)

1us = 1/1000000 s;

1s = 1000ms; Milliseconds

1ms = + us; Microseconds

1us = ns; Na-Sec

1ns = PS; Leather seconds

Flock () function:

Flock () function prototype: int flock (int fd, int operation);

wherein, the parameter FD represents the file descriptor; The parameter operation specifies the lock operation to take, which has the following values:

Lock_sh: Means to create a shared lock, at any time, a shared lock of a file can be owned by multiple processes;

LOCK_EX: Represents the creation of an exclusive lock, at any time, the exclusive lock of a file can only be owned by a process;

Lock_un: Represents the deletion of the lock created by the process;

Lock_mand: It is primarily used for shared-lock-mode forced locks, which can be used in conjunction with Lock_read or lock_write to indicate whether to run concurrent read operations or concurrent write operations.

Normally, if the lock clear autumn cannot be immediately satisfied, then system call flock () will block the current process. For example: The process wants to request an exclusive lock, but at this point, there are other processes that have acquired the lock, and the process will be blocked. If you want to not block the process without obtaining this exclusive lock, you can use LOCK_NB and lock_sh or lock_ex together, and the system will not block the process. The lock added by flock () will work for the entire file.

Attention:

1. File lock invalidation for close () operation of the file;

2. Similarly, the file lock fails after the process is finished;

3. The lock_ex of Flock () is to advise the lock, the system kernel does not force check the state of the lock, need to be in the code where the file operation to show the check to take effect.

IOS function Accumulation

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.