简体   繁体   English

iOS GCD:DISPATCH_QUEUE_PRIORITY_BACKGROUND,文件中“磁盘I / O被限制”是什么意思?

[英]iOS GCD: DISPATCH_QUEUE_PRIORITY_BACKGROUND, what does “disk I/O is throttled” mean in document?

As the document says: 正如文件所说:

DISPATCH_QUEUE_PRIORITY_BACKGROUND Items dispatched to the queue will run at background priority, ie the queue will be scheduled for execution after all higher priority queues have been scheduled and the system will run items on this queue on a thread with background status as per setpriority(2) (ie disk I/O is throttled and the thread's scheduling priority is set to lowest value). DISPATCH_QUEUE_PRIORITY_BACKGROUND调度到队列的项目将以后台优先级运行,即在调度所有优先级较高的队列后,队列将被调度执行,系统将根据setpriority(2)在具有后台状态的线程上运行此队列中的项目(2)(即磁盘I / O被限制,线程的调度优先级设置为最低值。

The last part of the document, what does "disk I/O is throttled" mean here? 文档的最后一部分, "disk I/O is throttled"是什么意思?

Does it mean that tasks running at DISPATCH_QUEUE_PRIORITY_BACKGROUND level can't access disk? 是否意味着在DISPATCH_QUEUE_PRIORITY_BACKGROUND级别运行的任务无法访问磁盘?

What we can deduce from the documentation is that DISPATCH_QUEUE_PRIORITY_BACKGROUND is run on a thread with “background status as per setpriority(2) ”. 我们可以从文档中推断出, DISPATCH_QUEUE_PRIORITY_BACKGROUND在具有“按setpriority(2)的背景状态”的线程上运行。

setpriority(2) has a parameter prio which can be set to either 0 or PRIO_DARWIN_BG . setpriority(2)有一个参数prio其可以设置为0PRIO_DARWIN_BG I assume this means that PRIO_DARWIN_BG is used and the documentation describes this as: 我假设这意味着使用了PRIO_DARWIN_BG ,文档将其描述为:

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. 当线程或进程处于后台状态时,调度优先级设置为最低值,磁盘IO受到限制(行为类似于使用setiopolicy_np(3)设置可限制策略),并且对于打开的任何套接字都会限制网络IO进入后台状态后。 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 . setiopolicy_np(3)可以将线程I / O策略设置为IOPOL_IMPORTANTIOPOL_STANDARDIOPOL_UTILITYIOPOL_THROTTLEIOPOL_PASSIVE It describes the effect of throttled disk I/O as: 它描述了受限制的磁盘I / O的影响:

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. 如果在较高优先级的请求的小时间窗口内发生可节流请求,则发出可节制I / O的线程被迫短时间休眠。 (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. (此窗口和休眠周期都取决于可节流I / O的策略。)这会降低发出可节流I / O的线程的速度,以便可以以低延迟完成更高优先级的I / O并接收更大的磁盘带宽份额。 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. 此外,重要的I / O请求可以绕过先前在内核或驱动程序队列中发出的可节流I / O请求,并首先发送到设备。 In some circumstances, very large throttleable I/O requests will be broken into smaller requests which are then issued serially. 在某些情况下,非常大的可节流I / O请求将被分解为较小的请求,然后以串行方式发出。

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. 所以不,它不会阻止在DISPATCH_QUEUE_PRIORITY_BACKGROUND运行的任务访问磁盘。

throttling means it controls the rate of I/O based on available resources. 限制意味着它根据可用资源控制I / O速率。 On low memery condition it many reduce the number of I/O process, and slows down. 在低memery条件下,它会减少I / O进程的数量,并减慢速度。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iOS GCD:任何全局队列与具有后台优先级的队列(DISPATCH_QUEUE_PRIORITY_BACKGROUND)之间的区别? - iOS GCD: Difference between any global queue and the one with background priority (DISPATCH_QUEUE_PRIORITY_BACKGROUND)? 检查DISPATCH_QUEUE_PRIORITY_BACKGROUND是否存在的最佳做法? - Best practice for checking if DISPATCH_QUEUE_PRIORITY_BACKGROUND exists? 为什么在使用DISPATCH_QUEUE_PRIORITY_BACKGROUND时dispatch_sync在主线程上进行工作? - Why is dispatch_sync doing work on the main thread when it uses DISPATCH_QUEUE_PRIORITY_BACKGROUND? GCD DISPATCH_QUEUE_SERIAL它将运行什么优先级? - GCD DISPATCH_QUEUE_SERIAL what priority is it going to run on? 为什么主队列上的GCD dispatch_async会导致后台队列出现死锁? - Why does GCD dispatch_async on main queue causes a deadlock from background queue? GCD-dispatch_async在主队列上工作,但在后台队列上崩溃 - GCD - dispatch_async works on main queue but crashes on a background queue Dispatch Queue 中的 Dispatch Queue Priority 和 QoS 有什么区别? - What is difference between Dispatch Queue Priority and QoS in Dispatch Queue? GCD dispatch_async DISPATCH_QUEUE_PRIORITY_DEFAULT EXC_BAD_ACCESS崩溃 - GCD dispatch_async DISPATCH_QUEUE_PRIORITY_DEFAULT EXC_BAD_ACCESS crash iOS 3.x 中的 GCD 串行调度队列等价物 - Equivalent of GCD serial dispatch queue in iOS 3.x 串行分派队列中的块未执行-GCD iOS Objective-C - Block in serial dispatch queue not executing - GCD iOS Objective-C
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM