File: /home/oboss/Users/gec/sources/Basic_Services/Resource_Manager/resource_manager.ads
1 --% Compilation Unit: Resource_Manager
2 --
3 --% Category: Generic Package Declaration
4 --
5 --% Release: $Name: $
6 --
7 --% Version: $Revision: 2.0 $
8 --
9 --% Author: $Author: gec $
10 --
11 --% Revision Log:
12 -- $Log: resource_manager.ads,v $
13 -- Revision 2.0 2003/04/04 08:50:12 gec
14 -- Initial release of source files serving as baseline for OBOSS-III project.
15 --
16 -- Revision 1.1.1.1 2003/04/04 08:13:03 gec
17 -- Imported using TkCVS
18 --
19 --
20 --
21 --% Project: OBOSS
22 --
23 --% Copyright (C) 2003 by Terma A/S
24 -- Proprietary and intellectual rights of Terma A/S, Denmark,
25 -- are involved in the subject-matter of this material and
26 -- all manufacturing, reproduction, use, disclosure, and
27 -- sales rights pertaining to such subject-matter are
28 -- expressly reserved. This material is submitted for a
29 -- specific purpose as agreed, and the recipient by
30 -- accepting this material agrees that this material will
31 -- not be used, copied, or reproduced in whole or in part
32 -- nor its contents revealed in any manner or to any person,
33 -- except to meet the purpose for which it was submitted and
34 -- subject to the terms of the agreement.
35 --
36 --% Target Dependencies:
37 -- None
38 --% Compiler Dependencies:
39 -- None
40
41 --~-----------------------------------------------------------------------------
42
43 with Task_Priority_Control;
44 generic
45
46 --% Generic Parameter Constraints:
47 --> Resource_Manager_Priority - Must be at least the ceiling of
48 --+ priorities of all tasks calling provided operations.
49
50 -- Representation of resource to be managed by resource manager.
51 type Resource is (<>);
52
53 -- Priority assigned to task implementing critical sections around provided
54 --+ operations.
55 Resource_Manager_Priority
56 : in Task_Priority_Control.
57 Passive_Task_Priority;
58
59 package Resource_Manager is
60
61 --% Library Package:
62 -- Resource_Manager manages a heap of Resource items with Reference
63 --+ Counting for allocated resources.
64 -- Initially no resources are allocated.
65 --% Active Tasks:
66 --> None
67 --% Passive Tasks:
68 --> Allocator - Critical region ensuring atomic execution of operations.
69
70 -- Not_Allocated indicates that an operation has been performed on an
71 --+ un-allocated resource.
72 Not_Allocated : exception;
73
74 -- No_Resources_Available indicates that an Allocate operation has failed
75 --+ due to lack of free resources.
76 No_Resources_Available : exception;
77
78 --% Subprogram:
79 -- Predicate indicating whether resource R is currently allocated.
80 --% Parameter Constraints:
81 --> None
82 --% Exceptions Raised:
83 --> None
84 function Is_Allocated
85 (R : Resource)
86 return Boolean;
87
88 --% Subprogram:
89 -- Allocates one of the resources if a free one exists.
90 --% Parameter Constraints:
91 --> None
92 --% Exceptions Raised:
93 --> No_Resources_Available - No free resources to allocate.
94 function Allocate
95 return Resource;
96
97 --% Subprogram:
98 -- Deallocate decreases the reference count for a resource and performs a
99 --+ real deallocation when reference count reaches zero.
100 --% Parameter Constraints:
101 --> None
102 --% Exceptions Raised:
103 --> Not_Allocated - R is not in the list of allocated resources.
104 procedure Deallocate
105 (R : in Resource);
106
107 --% Subprogram:
108 -- Share increments the reference count for the resource.
109 --% Parameter Constraints:
110 --> None
111 --% Exceptions Raised:
112 --> Not_Allocated - R is not in the list of allocated resources.
113 procedure Share
114 (R : in Resource);
115
116 end Resource_Manager;
117
118 --~-----------------------------------------------------------------------------
119