Reputation: 93
I'd like to confirm that this interview question is essentially impossible:
The goal of this project is to create an implementation of a device that can write files to a directory and then to design a write scheduling system for a set of devices. The write scheduler system should consist of an interface named WriteScheduler and at least two concrete implementations of it. The first should be a fair round robin scheduler and the second should be a write scheduler that uses some combination of pending writes, total writes, and total bytes written to optimize the writes in some way. All code for this project should be thread-safe.
Given an unspecified interface, how could a scheduler be optimized with just that data?
Upvotes: 1
Views: 109
Reputation: 1659
I presume, that the tag c++ was a mistake?
Ok, to the subject:
I can imagine an interface from what you provide us as this...
IDevice: this interface can be even empty interface
Device:
Now IWriteScheduler:
Device behaviour:
WriteScheduler:
Other scheduling methods simply by inheriting from WriteScheduler, overriding the:
virtual Task WriteAsync(IDevice device, int size, Action writing_task);
Task chaining allows to put even delays on write operations and many more tricks.
For scheduiling based on on the pending_writes, total_writes and total_bytes, well there is many ways to schedule and build specific rules that such data structure could handle:
I hope it was helpful, I provided analysis on implementation of the interface and some ideas for scheduling scenarios...
/IP/
Upvotes: 1
Reputation: 490408
It says "...to optimize the writes in some way".
So exactly what you attempt to optimize for is apparently pretty much up to you. For that matter, it may not even be particularly important that your attempted optimization be highly (or at all) successful.
If I had to guess, I'd say they're probably mostly interesting in the basic idea that you can define an abstract interface, then write a couple of implementations of that interface that differ in at least some semi-meaningful way (but still meet the interface's specification).
Upvotes: 1