The Question is incomplete. The question doesn't specify the maximum number resources a process needs to finish its execution.
Let me rephrase the question:
Suppose we have N number of resources (all are independent of each other), then what is the maximum number of process that can run simultaneously, using at least one of the resources and maximum M resources by each process, such that there will be no deadlock?
Answer:
Let, the number of available resources = N, the maximum number of resources a process can hold simultaneously = M and number of process = P.
The system is in safe mode if following condition is satisfied.
N >= P ( M - 1 ) + 1
Maximum number of processes,
P <= ( N - 1) / ( M - 1)
For example, if the number of available resources is 6 (N=6) and each process uses at most 2 (M=2) resources to finish execution, the maximum number of processes is 5. And the system is still safe.
Let, illustrate another scenario. the number of available resources is 6 (N=6) and each process uses at most 3 (M=3) resources to finish execution
Now, we have 6 processes in the system. All possible resources allocations are:
P1 | P2 | P3 | P4 | P5 | P6 | Available | Safe | Comment
| | | | | | resources | |
--------|-------|-------|-------|-------|-------|---------------|-----------|-----------------------------------------------------------
1 | 1 | 1 | 1 | 1 | 1 | 0 | No |each process requires at least 2 resources to finish
| | | | | | | |But no resource is available
Now, we have 5 processes in the system. All possible resources allocations are:
P1 | P2 | P3 | P4 | P5 | Available | Safe | Comment
| | | | | resources | |
--------|-------|-------|-------|-------|---------------|-----------|-----------------------------------------------------------
1 | 1 | 1 | 1 | 1 | 1 | No |each process requires at least 2 resources to finish
| | | | | | | |But only one resource is available
--------|-------|-------|-------|-------|---------------|-----------|-----------------------------------------------------------
2 | 1 | 1 | 1 | 1 | 0 | No |P1 requires at least 1 resource to finish
| | | | | | | |But no resource is available
Now, we have 4 processes in the system. All possible resources allocations are:
P1 | P2 | P3 | P4 | Available | Safe | Comment
| | | | resources | |
--------|-------|-------|-------|---------------|-----------|-----------------------------------------------------------
1 | 1 | 1 | 1 | 2 | Yes |
--------|-------|-------|-------|---------------|-----------|-----------------------------------------------------------
2 | 1 | 1 | 1 | 1 | Yes |P1 requires at least 1 resources to finish
| | | | | |and 1 resource is available. So the system is safe for this allocation.
--------|-------|-------|-------|---------------|-----------|-----------------------------------------------------------
2 | 2 | 1 | 1 | 0 | No |
Now, we have 3 processes in the system. All possible resources allocations are:
P1 | P2 | P3 | Available | Safe | Comment
| | | resources | |
--------|-------|-------|---------------|-----------|-----------------------------------------------------------
1 | 1 | 1 | 3 | Yes |
2 | 1 | 1 | 2 | Yes |
2 | 2 | 1 | 1 | Yes |
2 | 2 | 2 | 0 | No |
Now, we have 2 processes in the system. All possible resources allocations are:
P1 | P2 | Available | Safe | Comment
| | resources | |
--------|-------|---------------|-----------|-----------------------------------------------------------
1 | 1 | 4 | Yes |
2 | 1 | 3 | Yes |
2 | 2 | 2 | Yes |
If the maximum no of processes is 2, the system will be safe whatever the resources allocations are.
So using the given formula above,
For, the number of available resources, N = 6
And the maximum number of resources required by each process, M = 3
The maximum number processes, P <= (6-1) / (3-1) = 2.5 = 2 (apx.)