@X @~
~V7 56 2 -5
~D10
~H                    MUSS
~
~
~D10
~H             SYS081
~D10
~MMANCHESTER UNIVERSITY  -  CONFIDENTIAL
~
~
                                                           ISSUE 11~
~V9 -1
~P
~YSYS081
~M~OSYS IMPLEMENTATION DESCRIPTION
~
~M~OSection 8 Version 1
~S1~OSection 8.1 Real Time Clock
~S1~O1. General Description
~BThis module provides access to the real time and date,
and services the real time clock interrupt. Its principal function
is to trigger other modules which require regular activation,
and to provide a timing out operation for use by interrupt level activities.
~S1~O2. Interfaces~
Other modules used~
   Section 15 (Message Management)~
   Section 17 (User Management)~
Hardware registers used~
   V.TIME~
   V.MILLI.TIME~
   V.CLOCK~
Interrupt level interface procedures~
   START.DEVICE.CLOCK (ACTIVITY)~
   STOP.DEVICE.CLOCK ()~
Organisational commands~
   TIME.AND.DATE ()~
~S1~O2.1 Hardware Interface~
~BThe real time clock is read as V.TIME, which contains
the number of seconds since midnight on the 1st January 1900
(i.e. the turn of the century). The clock also
generates a system-based interrupt once a second; this
is extinguished by writing zero to V.CLOCK.
A more accurate timer is available by reading V.MILLI.TIME, which
returns the time in milliseconds since the system was last restarted.
~S1~O2.2 Software Interface
~
1) START.DEVICE.CLOCK (ACTIVITY)
~BThis procedure starts the interrupt level timeout mechanism
for a particular activity. The specified activity will be freed
after one complete second (at least) has elapsed, unless it stops or
re-starts the device clock in the meantime. The principal use
of this mechanism is to ensure that the activity in control of
a device can regain control even if the device itself fails to
interrupt when expected.~
~
2) STOP.DEVICE.CLOCK ()~
~BThis procedure cancels any timeout request outstanding for the
current activity.
~S1~O3. Implementation
~S1~O3.1 Outline of Operation
~BNone
~S1~O3.2 Data Structures~
~
~T% 10
~
BUSY~Ia bit pattern, indicating which interrupt level activities
are to be timed out at the next clock interrupt.~
STARTED~Ia bit pattern, indicating which interrupt level activities
currently have timeout requests outstanding.~
~S1~O3.3 Special Notes
~BNone
~
~Y
~V9 -1
~P
~V9 -1
~D15
~HFLOWCHARTS
~
~
~H                SYS081
~V9 -1
~F
@TITLE SYS08(1,11)
@COL 1S-2R-3R-4R-5R-6F
@FLOW 1-2-3-4-5-6
@BOX 1.0
REAL TIME CLOCK
@BOX 4.0
PROCEDURES IN MODULE:
   INT1 CLOCK INTERRUPT
   INT2 START DEVICE CLOCK
   INT3 STOP DEVICE CLOCK
   CMD1 TIME AND DATE
   CMD2 SET TIME AND DATE
@BOX 6.0
END
@BOX 1.1
#SYS08/1
MODULE SYS08 (CLOCK.INTERRUPT, START.DEVICE.CLOCK, STOP.DEVICE.CLOCK,
   TIME.AND.DATE, SET.TIME.AND.DATE, STATS.TYPE);
@BOX 2.1
TYPE STATS.TYPE IS
   INTEGER32 RUN.TIME;
@BOX 3.1
*GLOBAL 5;
LOGICAL BUSY, STARTED;
ADDR STATS.TYPE STATS;
@BOX 4.1
::*INIT %6000;
*CODE 2;
PSPEC CLOCK.INTERRUPT ();
PSPEC STOP.DEVICE.CLOCK (LOGICAL);
PSPEC START.DEVICE.CLOCK (LOGICAL);
   #SYSINT08.1
   #SYSINT08.2
   #SYSINT08.3
::*INIT %7000;
*CODE 15;
LSPEC TIME.AND.DATE ();
LSPEC SET.TIME.AND.DATE (LOGICAL64, LOGICAL64);
   #SYSCMD08.1
   #SYSCMD08.2
@BOX 5.1
::*INIT %6000;
*CODE 7;
PSPEC INIT.SYS08 ();
INIT.SYS08 ();
PROC INIT.SYS08;
MAKE (STATS.TYPE, 0, SYS21.GET.STATS (8)) => STATS;
0 => BUSY => STARTED;
END
@BOX 6.1
*END
@END
@TITLE SYS08/1(1,11)
@COL 1S-2R-3R-4R
@FLOW 1-2-3-4

@BOX 1.0
OTHER MODULES REFERENCED
@BOX 4.0
SYS01 COORDINATOR
SYS15 MESSAGE SYSTEM
SYS17 USER MANAGEMENT
@BOX 1.1
::EXTERNAL ENVIRONMENT
@BOX 2.1
IMPORT VSTORE V.CLOCK;
IMPORT VSTORE LOGICAL32 V.TIME, V.MILLI.TIME;
@BOX 4.1
PSPEC SYS01.NEXT.ACTIVITY ();
PSPEC SYS01.SET.INTERRUPT (LOGICAL, LOGICAL);
PSPEC SYS15.CHECK.WAIT.TIME (INTEGER32);
PSPEC SYS17.UPDATE.ACCOUNTS (INTEGER32);
PSPEC SYS21.GET.STATS (INTEGER) / ADDR;
ADDR PW0;
LOGICAL64 PWW1, PWW2;
@END
@TITLE SYSINT08.1(1,7)
@COL 1S-2R-3R-6R-4R-5R-7R-8F
@FLOW 1-2-3-6-4-5-7-2
@BOX 1.0
CLOCK INTERRUPT
@BOX 2.0
WAIT FOR NEXT
CLOCK INTERRUPT
[SYS01]
@BOX 3.0
INCREMENT 1 SECOND
COUNT
@BOX 4.0
CHECK WAIT TIME
[SYS 15]
@BOX 5.0
UPDATE ACCOUNTS
[SYS 17]
@BOX 6.0
SET SOFTWARE INTERRUPT
FOR OVERDUE DEVICES
[SYS01]
@BOX 7.0
CLEAR INTERRUPT
@BOX 8.0
END
@BOX 1.1
PROC CLOCK.INTERRUPT;
@BOX 2.1
SYS01.NEXT.ACTIVITY ();
@BOX 3.1
1 +> RUN.TIME OF STATS^;
@BOX 4.1
SYS15.CHECK.WAIT.TIME (V.TIME);
@BOX 5.1
SYS17.UPDATE.ACCOUNTS (V.TIME);
@BOX 6.1
SYS01.SET.INTERRUPT (BUSY, 0);
BUSY -=> STARTED => BUSY;
@BOX 7.1
0 => V.CLOCK;
@BOX 8.1
END
@END
@TITLE SYSINT08.2(1,6)
@COL 1S-2R-3F
@FLOW 1-2-3
@BOX 1.0
START.DEVICE.CLOCK (ACTIVITY)
@BOX 2.0
NOTE DEVICE CLOCK STARTED
@BOX 3.0
END
@BOX 1.1
PROC START.DEVICE.CLOCK (ACTIVITY);
@BOX 2.1
ACTIVITY !> STARTED;
@BOX 3.1
END
@END
@TITLE SYSINT08.3(1,6)
@COL 1S-2R-3F
@FLOW 1-2-3
@BOX 1.0
STOP DEVICE CLOCK (ACTIVITY)
@BOX 2.0
NOTE DEVICE IS NO LONGER BUSY
@BOX 3.0
END
@BOX 1.1
PROC STOP.DEVICE.CLOCK (ACTIVITY);
@BOX 2.1
ACTIVITY & STARTED -=> STARTED;
ACTIVITY & BUSY -=> BUSY;
@BOX 3.1
END
@END
@TITLE SYSCMD08.1(1,11)
@COL 1S-2R-3F
@FLOW 1-2-3
@BOX 1.0
TIME AND DATE
@BOX 2.0
READ TIME AND DATE
@BOX 3.0
END
@BOX 1.1
PROC TIME.AND.DATE;
0 => PW0;
@BOX 2.1
V.TIME => PWW1;
V.MILLI.TIME => PWW2;
@BOX 3.1
END
@END
@TITLE SYSCMD08.2(1,8)

@COL 1S-2R-3F

@FLOW 1-2-3

@BOX 1.0
SET TIME AND DATE (TIME, DATE)
@BOX 2.0
SET TIME/DATE V LINE
@BOX 3.0
END
@BOX 1.1
PROC SET.TIME.AND.DATE (TIME, DATE);
INTEGER HRS, MINS, SECS, DAY, MONTH, YR;
0 => PW0;
PSPEC CONVERT (ADDR INTEGER);
PROC CONVERT (NUM);
INTEGER TEMP;
NUM^ ->> 8 - "0" * 10 => TEMP;
NUM^ & %F + TEMP => NUM^;
END
@BOX 2.1
TIME ->> 32 => HRS;
CONVERT (^HRS);
TIME ->> 16 & %FFFF => MINS;
CONVERT (^MINS);
TIME & %FFFF => SECS;
CONVERT (^SECS);
DATE ->> 32 => DAY;
CONVERT (^DAY);
DATE ->> 16 & %FFFF => MONTH;
CONVERT (^MONTH);
DATE & %FFFF => YR;
CONVERT (^YR);
IF 3 -> MONTH < 0 THEN
   12 +> MONTH;
   1 -> YR;
FI
YR * 1461 / 4 + (153 * MONTH + 2 / 5) + DAY + 59 * 24
   + HRS * 60 + MINS * 60 + SECS => V.TIME;
@BOX 3.1
END
@END
