ACCOUNTING_DAEMON ----------------- The Daemon's main function is to track the accounting file ACCOUNTNG.DAT and to create a parallel billing file complete with cost information. To do this, it maintains several internal databases, generally in linked list form. One list contains charging rate information for the various queues. Another contains information about each process on the system, including how much money each spent the last time it looked. Costs are maintained in an incremental manner, which allows for rate changes in the midst of a session. Most of the work performed by the Daemon is driven by ASTs. The main exception to this is writing out "snapshot" information periodically, which is sufficiently time consuming that it is interruptable by nearly any other activity. Non-periodic activity (COST requests, LOGIN/OUT requests, closing accounting files, etc.) are initiated by the receipt of a request from the user interface via a VMS mailbox. Periodic activities are entirely AST driven. Major Functions: ---------------- Reading mailbox - The mailbox is read and the requests are parsed. Requests for LOGIN cause creation of a new entry in the active process list. COST updates an existing entry. LOGOUT calulates a final session cost and marks the entry for deletion. Reading binary - The Digital file ACCOUNTNG.DAT is read sequentially and a UWO CCS accounting record is cut whenever a new record is encountered in the binary file. If a LOGOUT entry is discovered this way, a final COST is calculated and the internal entry is marked for deletion at that time. Snapshot - The entries for all processes in the linked list are updated. The entire linked list is then written to disk. Entries marked for deletion are removed from the list. Reading rates - The rates are read at UWO CCS hourly since all rate change boundaries are on the hour. This involves reading the rate file, and remembering the appropriate rates for the coming hour. Cost - On demand, the rate information and incremental resources used by a process is transformed into an incremental charge, which is then added to the previous total. Basic Algorithom ---------------- When the Daemon is started, it reads initialization files. For a "normal" startup, the "snapshot" file is ignored. However, the Daemon is "restartable" (for example after closing its files at midnight). A restart operation requires that the snapshot file be read and charges up to that time be remembered. The Daemon mailbox is then created. Event flags are set and a QIO request to read the mailbox is issued. At this point the Daemon loops servicing mailbox requests and timed event requests. The only way out of the loop is the receipt of a NEW_DAY request, at which time the Daemon finishes up with a final snapshot, and tidies up its billing files before it exits. The NEW_DAY request is always followed immediately with a Daemon "restart", to maintain continuity. Christopher D. Lee CHRIS@UWOVAX.UWO.CDN