Deadlock avoidance: How does the system know in advance about the number of resources required by a process? While studying about Deadlock Avoidance I came across a paragraph which states as given below:


  When the system needs to issue any resource to any process, then in making this decision the system must consider the resources currently available, the resources currently allocated to each process, and the future requests and releases of each process.


So my question is that how can the system know in advance about the number of resources that a particular process will require/request in future?
For many systems, it's impossible to know (for instance, your home computer). In a very controlled system, you could know in advance about the number of resources that a process requires and when these requests occur (for example, an embedded system).

You could probably create some sort of heuristic for what resources might be requested in the future based on previous knowledge (such as past program execution or code analysis) for the impossible cases. I'm not sure how much this is done in practice though.