views:

31

answers:

1

Does this function affect Memory-mapped file performance?

Here's the problem I need to solve:

I have two applications competing for disk access: "reader" and "updater". Whole system runs on Windows Server 2008 R2 x64

"Updater" constantly accesses disk in a linear manner, updating data. They system is set up in such a way that updater always has infinite data to update. Consider that it is constantly approximating a solution of a huge set of equations that takes up entire 2TB disk drive. Updater uses ReadFile and WriteFile to process data in a linear fashion.

"Reader" is occasionally invoked by user to get some pieces of data. Usually user would read several 4kb blocks from the drive and stop. Occasionally user needs to read up to 100mb sequentially. In exceptional cases up to several gigabytes. Reader maps files to memory to get data it needs.

What I would like to achieve is for "reader" to have absolute priority so that "updater" would completely stop if needed so that "reader" could get the data user needs ASAP.

Is this problem solvable by using SetPriorityClass and SetFileBandwidthReservation calls?

I would really hate to put synchronization login in "reader" and "updater" and rather have the OS take care of priorities.

A: 

Functions you've mentioned have nothing to do with your task, IMO.

Seems like are actually asking for simultaneous file access from multiple processes - and OS will just do what you have asked for. Thus, you'll have to do what you ~hate~ add some sync logic to ensure correctness.

According to your description - opening the file for exclusive access from both reader and updater solves a task of making reader uninterrupted by an updater. The second goal is to make updater interruptible by reader's request.

The way to deal with it depends on whether an updater can be stopped in the middle of its work. In the simple case reader may notify an updater that it has to stop its work ASAP and wait.

Andrey