CLW
May 5th, 2001, 01:57 AM
I need to write a generic resource controller that can regulate access to certain finite resources.
Since the resources can be shared by different client applications. It is to be written as a COM object. Now I basically need to store the maximum no. of resources available, and current resourses used up before granting or denying a request for the particular resource.
The algorithm is simple and as follows:
2 pieces of data need persistent storage - MaxResources and ResourcesUsed.
When client application requests resource from resource manager, the resource manager pseudocode is as below:
PersistentStorage.Lock
if ResourcesUsed>=MaxResourses
GrantRequest=false
else
ResourcesUsed=ResoursesUsed+1
GrantRequest=true
end if
PersistentStorage.Unlock
If GrantRequest
GrantAccessToResources
else
DenyAccessToResources
End if
As a result, I need to store these pieces of data in persistent storage. However, I am handicapped by the requirement that there are no databases available. Thus it appears to me that my only options are to either store the data in a file, or store the data in registry.
Now in order for the resource controller to function correctly, all requests need to be completely serialized, meaning that I need to be able to lock the data in persistent storage.
My concern therefore, with storing the data, in a file, is the performance issue. If I were to use registry, my concern is with both performance, as well as my ability to lock the particular entry in registry (I haven't figured out a way to lock an entry in registry while it is being accessed).
I'd like to know firstly, if there are any other means available to store the data persistently(which also has a locking mechanism), and secondly, what I can do to improve the performance if I were to store the data in a file.
TIA
CLW
Since the resources can be shared by different client applications. It is to be written as a COM object. Now I basically need to store the maximum no. of resources available, and current resourses used up before granting or denying a request for the particular resource.
The algorithm is simple and as follows:
2 pieces of data need persistent storage - MaxResources and ResourcesUsed.
When client application requests resource from resource manager, the resource manager pseudocode is as below:
PersistentStorage.Lock
if ResourcesUsed>=MaxResourses
GrantRequest=false
else
ResourcesUsed=ResoursesUsed+1
GrantRequest=true
end if
PersistentStorage.Unlock
If GrantRequest
GrantAccessToResources
else
DenyAccessToResources
End if
As a result, I need to store these pieces of data in persistent storage. However, I am handicapped by the requirement that there are no databases available. Thus it appears to me that my only options are to either store the data in a file, or store the data in registry.
Now in order for the resource controller to function correctly, all requests need to be completely serialized, meaning that I need to be able to lock the data in persistent storage.
My concern therefore, with storing the data, in a file, is the performance issue. If I were to use registry, my concern is with both performance, as well as my ability to lock the particular entry in registry (I haven't figured out a way to lock an entry in registry while it is being accessed).
I'd like to know firstly, if there are any other means available to store the data persistently(which also has a locking mechanism), and secondly, what I can do to improve the performance if I were to store the data in a file.
TIA
CLW