.; .; This is article for submission to the RSX-MultiTasker .; .; LAST EDIT: 11-NOV-1987 10:22:29 .; .ps 58,80 .lm 10 .rm 75 .c; AS TIME CLUNKS ON .s .c; Peter Stadick .c; Cargill, Inc. .c; Commodity Marketing Division .c; P.O. Drawer AR, Reserve,LA 70084 .s 2 .i 5 Realtime control software is often required to record the time events occured and be able to manipulate those time values. The problem has been the lack of a convenient way to record those times in a format the could be compatible with other software packages, calculate new time values from existing time values and yet do this in some uniform "generic standard". Believe it or not a method does exist, "clunk" time. .s .i 5 A "clunk" is a unit of time equal to 100 nanoseconds or thats 10 million clunks per second. A clunk date is defined as the number of clunks, expressed as a 64 bit unsigned integer, since November 17,1858. This was the date the first photographic plate was exposed at the Smithsonian Astrophysical Laboratory ushering in the age of modern astronomy. Clunks provide very fine time resolution yet when expressed as a 64 bit integer it will take some 58,000 years before it will overflow. .s .i 5 In 1982 Bob Rock of Northern Telecom wrote an artical for the Multitasker on clunks. At that time he had written several routines that converted the DEC date and time stamp into clunks and visa versa. The routines did not actually let you manipulate the clunk values though. .s .i 5 About a year ago I started designed some logistics modeling software in which I needed to record events for later analysis as well as predict when future event should occur. Parts of the model required time calculations over periods of months while in other parts minutes was the order of magnitude. Here is where clunks really payoff. They are just as accurate over many years as over several seconds. To find the difference between two times all that is required is to subrtact the two clunk values and divide by the time unit, in clunks, needed. To calculate a new clunk value in the future or past the reverse of the process is done. .s .i 5 Another major reason that clunk time representation was choosen is because Datatrieve uses clunks as the internal date representation for fields declared 'USAGE DATE'. The software involved using Datatrieve for some of the report generation and OMSI pascal to perform the modeling calculations. Here, clunks proved a way to represent dates in a format compatable with both software packages. Datatrieve does however only displays clunks as whole dates and will truncate the hours, minutes and seconds off any report. .s .i 5 Clunks do have a problem when it comes to RMS key compatability. There is no 64 bit unsigned integer key type in RMS-11. When a 'USAGE DATE' field in Datatrieve is declared as a key field, Datatrieve sets the key type to an eight character ASCII string. This allows Datatrieve to search for exact matches but will not allow 'greater then' searches. This is because the clunk values are stored least significant word to most significant word. If the clunks were stored in the reverse order 'greater then' searches would be possible. .s .i 5 In real practace, working with 64 bit integers on a PDP-11 does cause a few small problems. Such as their is no instruction to do a 64 bit unsigned integer divide returning the quotient and remainder. But their is no real reason to worry because these problems have been resolved. On the upcoming release of the RSX-SIG tapes will be an overhauled version of Bob Rocks original submission with some new features. The capability to convert between clunks and the DEC date and time stamp is still there but three new functions have been added. The first is a routine to calculate the difference in time between two clunk value returning the number of days and amount of time. The second is the ability to compute a new clunk value by adding or subtracting a specfic amount of time from an existing clunk value. The last function returns which day of the week a given clunk value falls on. The rudimentary routines to do 64 bit unsigned integer adds, subtracts, multiplies and divides is also included. .s .i 5 All nine of the routines use the DEC call site convention to pass parameters. This enables the routines to be used by Fortran, Basic-Plus-II, OMSI pascal or MACRO-11. Great pains were taken when revising and writing the software to write only pure, position independent code. This enables the routines to be built into a shared resident, cluster or supervisor mode library. A resident and supervisor mode library is included in the submission. .s .i 5 I found clunks to be a very useful way of storing and manipulating time values. They didn't have the short comings and pitfalls of other methods I have seen and tried. Now that some of the overhead has been simplified in manipulating time values maybe clunks time has come.