Car*_*loS 3 iphone grand-central-dispatch ios
正如文件所说:
DISPATCH_QUEUE_PRIORITY_BACKGROUND调度到队列的项目将以后台优先级运行,即在调度所有优先级较高的队列后,队列将被调度执行,系统将根据setpriority(2)在具有后台状态的线程上运行此队列中的项目(2)(即磁盘I/O被限制,线程的调度优先级设置为最低值.
文件的最后一部分,"disk I/O is throttled"这里的意思是什么?
是否意味着在DISPATCH_QUEUE_PRIORITY_BACKGROUND级别运行的任务无法访问磁盘?
我们可以从文档中推断出的是DISPATCH_QUEUE_PRIORITY_BACKGROUND在具有"按setpriority(2)的背景状态"的线程上运行.
setpriority(2) has a parameter prio which can be set to either 0 or PRIO_DARWIN_BG. I assume this means that PRIO_DARWIN_BG is used and the documentation describes this as:
When a thread or process is in a background state the scheduling priority is set to the lowest value, disk IO is throttled (with behavior similar to using setiopolicy_np(3) to set a throttleable policy), and network IO is throttled for any sockets opened after going into background state. Any previously opened sockets are not affected.
setiopolicy_np(3) can set the thread I/O policy to IOPOL_IMPORTANT, IOPOL_STANDARD, IOPOL_UTILITY, IOPOL_THROTTLE, or IOPOL_PASSIVE. It describes the effect of throttled disk I/O as:
If a throttleable request occurs within a small time window of a request of higher priority, the thread that issued the throttleable I/O is forced to a sleep for a short period. (Both this window and the sleep period are dependent on the policy of the throttleable I/O.) This slows down the thread that issues the throttleable I/O so that higher-priority I/Os can complete with low-latency and receive a greater share of the disk bandwidth. Furthermore, an IMPORTANT I/O request may bypass a previously issued throttleable I/O request in kernel or driver queues and be sent to the device first. In some circumstances, very large throttleable I/O requests will be broken into smaller requests which are then issued serially.
Which basically means that reading and writing to disk may be slowed or delayed, if another thread with higher priority is also accessing the disk. So no, it does not prevent tasks running at DISPATCH_QUEUE_PRIORITY_BACKGROUND from accessing the disk.
| 归档时间: |
|
| 查看次数: |
1392 次 |
| 最近记录: |