Re: Prioritize my own app's disk access
Re: Prioritize my own app's disk access
- Subject: Re: Prioritize my own app's disk access
- From: Jonathan Taylor <email@hidden>
- Date: Tue, 05 Jul 2016 16:41:11 +0100
Thanks Alastair. Mark Allan’s email set me off reading things in that area, and I am indeed reading the man page for setiopolicy_np at this very moment!
Certainly sounds like the API I am looking for although, as you say, it’s not clear where the “default” policy fits into the hierarchy. The man page states that [IOPOL_IMPORTANT] "is the default I/O policy for new threads”, and so if true then that would suggest that all a program can do is DOWNgrade its priority. However, the man page is evidently not entirely correct, based on the result you got, so who knows!
I also wonder what priority the Finder would use for copying a folder. I might hope it would set itself to STANDARD or THROTTLE; if it does do that, then that would suggest that even this is not proving enough to prevent my code getting backlogged…
On 5 Jul 2016, at 16:34, Alastair Houghton <email@hidden> wrote:
> On 5 Jul 2016, at 13:36, Jonathan Taylor <email@hidden> wrote:
>>
>> This is a long shot, but I thought I would ask in case an API exists to do what I want. One of the roles of my code is to record video to disk as it is received from a camera. A magnetic hard disk can normally keep up with this, but if the user is also doing other things on the computer (e.g. long file copy in the Finder) then we are unable to keep up, and accumulate an ever-increasing backlog of frames waiting to be saved. This eventually leads to running out of memory, thrashing, and an unresponsive computer. Dropping frames is not an option. In this case, the computer is a dedicated workstation running my code, so it *is* correct for me to consider my code to be the number 1 priority on the computer.
>>
>> What I am wondering is whether there is some way I can communicate this requirement, to cause other apps such as the finder to get disk access at lower priority. Or alternatively, a way that I can demand high priority temporarily, at times when I identify that we have accumulated a save backlog?
>
> Take a look at get/setiopolicy_np(). It isn’t clear from the documentation exactly what the default behaviour is; when I tried calling getiopolicy_np() I got IOPOL_DEFAULT, which isn’t even mentioned as a value on the man page, but you may find that setting your thread/process’s IO policy to IOPOL_IMPORTANT solves your problem.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden