IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Get system time in micro second or clock uint.


IBM Mainframe Forums -> CICS
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
lind sh

New User


Joined: 04 Feb 2015
Posts: 32
Location: Tajikestan

PostPosted: Mon Sep 05, 2016 11:14 pm
Reply with quote

Dear friends
How can I get CICS or system time in micro-second unit. I need to take the time in high precision.
I know it's possible by STCK in assembly but I need a sample to understand it.
When I run the following program, the system take abend 0C4.!!!
Code:
STCKCON1 CSECT                                                           
STCKCON1 AMODE 31                                                         
STCKCON1 RMODE 24                                                         
         STM   14,12,12(13)                                               
         LR    12,15                                                     
         USING STCKCON1,12                                               
         LA    15,SAVE                                                   
         ST    15,8(13)                                                   
         ST    13,4(15)                                                   
         LR    13,15                                                     
         STCK TODCLOCK                                                   
TODCLOCK DS XL8                                       TOD CLOCK VALUE     
*#         WTO   TODCLOCK                                                 
         L     13,4(13)                                                   
         XC    8(4,13),8(13)                                             
         LM    14,12,12(13)                                               
         DROP  12                                                         
         SR    15,15                                                     
         BR    14                                                         
         END                                                               

Thanks.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Sep 06, 2016 12:18 am
Reply with quote

Where is the S0C4 showing up? And you do NOT want to use the WTO on that value -- it is a 64-bit binary value with bit 51 representing 1 microsecond, so without some work you won't see anything human-readable from the WTO.

I suspect you're probably getting the S0C4 right after the STCK instruction, because it is unlikely that the value represents valid z/OS OP codes. You need to move the TODCLOCK definition after your return.
Back to top
View user's profile Send private message
steve-myers

Active Member


Joined: 30 Nov 2013
Posts: 917
Location: The Universe

PostPosted: Tue Sep 06, 2016 1:50 am
Reply with quote

Robert Sample wrote:
... And you do NOT want to use the WTO on that value -- it is a 64-bit binary value with bit 51 representing 1 microsecond, so without some work you won't see anything human-readable from the WTO.
Agreed.
Robert Sample wrote:
Where is the S0C4 showing up? ... I suspect you're probably getting the S0C4 right after the STCK instruction, because it is unlikely that the value represents valid z/OS OP codes. You need to move the TODCLOCK definition after your return.
In general, I agree. However, it is quite possible it will be a valid operation. I just got D14D84B2 83332000 (or MVN 1202(78,R8),819(R8)) running on Hercules. Depending on what's in register 8, the odds are this will 0C4. Of course, what you will get depends on the actual time, though it I think it will be MVN for a while.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Tue Sep 06, 2016 10:54 am
Reply with quote

Code:

         STCK TODCLOCK                                                   
TODCLOCK DS XL8                                       TOD CLOCK VALUE     
*#         WTO   TODCLOCK                                                 
         L     13,4(13)                                                   
 


Executing the TODCLOCK value?

Sorry Robert, you mentioned that already.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue Sep 06, 2016 6:10 pm
Reply with quote

Take a look at the TIME Macro (LINKAGE=SYSTEM) using the MIC (Microseconds) keyword.

You can then return the binary-value 'as-is' or convert this binary-doubleword to a PL16 packed-decimal value, using the 'CVDG' (Convert Decimal Grande) instruction, with the doubleword loaded into a grande-register beforehand via a 'LG' (Load Grande) instruction.

This type of sub-program can be used in both Batch and CICS. But, ensure you're passing re-entrant storage from the COBOL caller so that it remains re-entrant, which is a requirement in CICS.

HTH....
Back to top
View user's profile Send private message
steve-myers

Active Member


Joined: 30 Nov 2013
Posts: 917
Location: The Universe

PostPosted: Wed Sep 07, 2016 6:35 am
Reply with quote

Bill O'Boyle wrote:
Take a look at the TIME Macro (LINKAGE=SYSTEM) using the MIC (Microseconds) keyword.

You can then return the binary-value 'as-is' or convert this binary-doubleword to a PL16 packed-decimal value, using the 'CVDG' (Convert Decimal Grande) instruction, with the doubleword loaded into a grande-register beforehand via a 'LG' (Load Grande) instruction.

This type of sub-program can be used in both Batch and CICS. But, ensure you're passing re-entrant storage from the COBOL caller so that it remains re-entrant, which is a requirement in CICS.

HTH....

Both the raw data and Mr. O'Boyle's proposed quad word are pretty useless without a lot of additional massaging.
Code:
THE RAW TOD CLOCK IS D14F0580 A6DE7000           
 IN DECIMAL IT IS            -3364464346508922880

The primary advantage of TIME MIC is the macro can be persuaded to convert the clock value to local time. This is not terribly difficult to do yourself, but it's one less thing you have to do, and you do not have to do some research (or beg someone here to give you the code).
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Sep 07, 2016 8:23 am
Reply with quote

Since the value represents the number of microseconds since January 1, 1900 the value is actually
Code:
 15,082,279,727,200,628,736
and not a negative integer. My Windows calculator came up with the negative value and 922880 for the last 6 digits, too. This value was computed using Perl with bigint for large-scale arithmetic.
Back to top
View user's profile Send private message
steve-myers

Active Member


Joined: 30 Nov 2013
Posts: 917
Location: The Universe

PostPosted: Wed Sep 07, 2016 9:19 am
Reply with quote

No, it doesn't work that way. There are two issues.
  1. Going back to my raw TOD clock, those 3 low order hexadecimal 0s represent bits 52 through 63. In other words, they represent a precision of less than 1 micro second.
  2. Now, the -value I formatted is from the CVDG; in terms of ordinary math, -D... is a 2's complement negative number, CVDG produced a negative packed decimal number. Now I suppose I could change the D to a C in the packed decimal number, or change the D... to microseconds before the CVDG with

    LM evenreg,oddreg,CLOCKVAL
    SRDL evenreg,12
    STM evenreg,oddreg,CLOCKVAL
    LG reg,CLOCKVAL
    CVDG reg,QUADWORD

    which would give me 000D... to convert and a positive number in microseconds. But then you have lost the fraction of microseconds. Back in the days when I used a real z machine rather than Hercules, all 12 of those fraction of a microsecond bits were used!

    Yes, there is an SRLG instruction, but a quick read of Principles of Operation leaves me confused as you specify 2 registers and they interact in some way I'm not sure I understand without some experimentation I can't do quickly enough for this post.
Back to top
View user's profile Send private message
steve-myers

Active Member


Joined: 30 Nov 2013
Posts: 917
Location: The Universe

PostPosted: Wed Sep 07, 2016 7:02 pm
Reply with quote

Bill O'Boyle wrote:
Take a look at the TIME Macro (LINKAGE=SYSTEM) using the MIC (Microseconds) keyword.

You can then return the binary-value 'as-is' or convert this binary-doubleword to a PL16 packed-decimal value, using the 'CVDG' (Convert Decimal Grande) instruction, with the doubleword loaded into a grande-register beforehand via a 'LG' (Load Grande) instruction.

This type of sub-program can be used in both Batch and CICS. But, ensure you're passing re-entrant storage from the COBOL caller so that it remains re-entrant, which is a requirement in CICS.

HTH....

MVS Programming Assembler Services Reference ... wrote:
MIC returns the time of day in microseconds. The value is returned as 8 bytes of information where bit 51 is equivalent to one microsecond.

I think both Mr. O'Boyle and I goofed. I think we both thought TIME MIC returned the TOD clock with micro seconds in bit 63. Oops. Then I thought to actually test this, and the TIME MIC value was, well, rather low! Then I actually RTFM!

On the other hand, the time will always be positive, so the CVDG instruction will produce a positive 16 byte packed decimal number. It's just not what we thought.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Sep 07, 2016 7:35 pm
Reply with quote

2-s complement arithmetic has no bearing on the TOD clock. OA48941 shows this, saying in part:
Quote:
In the reported problem, iconv() calls the Unicode Services,
conversion information service, CUNLINFO or CUN4LINF, during a
character conversion and receives RC8 RSNB when the create time
of the UCCB time is D0000000 0000000 or greater. An identical
request does not fail when the time is CFFFFFFF FFFFFFFF
(12/15/2015 13:24:57.238527) or less.
If 2-s complement arithmetic were being used, CFFFFFFF FFFFFFFF would NOT roll over to D0000000 00000000.

From the POP manual, page 4-41:
Quote:
Time-of-Day Clock
The time-of-day (TOD) clock provides a high-resolution
measure of real time suitable for the indication of date
and time of day. The cycle of the clock is approxi-
mately 143 years. A single TOD clock is shared by
all CPUs in the configuration.
Format
The TOD clock is a 104-bit register. It is a binary
counter with the format shown in the following
illustration.
The TOD clock nominally is incremented by adding a one
in bit position 51 every microsecond. In models
having a higher or lower resolution, a different bit
position is incremented at such a frequency that the rate
of advancing the clock is the same as if a one were
added in bit position 51 every microsecond. The
resolution of the TOD clock is such that the
incrementing rate is comparable to the instruction
execution rate of the model.
When incrementing of the clock causes a carry to be
propagated out of bit position 0, the carry is ignored,
and counting continues from zero. The program
is not alerted, and no interruption condition is
generated as a result of the overflow.
and page 4-43:
Quote:
Setting the clock replaces the values in all bit posi-
tions from bit position 0 through the rightmost posi-
tion that is incremented when the clock is running.
However, on some models, the rightmost bits starting
at or to the right of bit 52 of the specified value are
ignored, and zeros are placed in the corresponding
positions of the clock. Zeros are also placed in posi-
tions to the right of bit position 63 of the clock.
I've written a COBOL TOD translator, and your D14F0580 A6DE7000 represents September 7, 2016 at 12:33:19.628736 AM (which probably does not include the GMT offset
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Wed Sep 07, 2016 9:15 pm
Reply with quote

TIME Macro usage in Assembler and/or Get current timestamp without using SQL query, If this helps unlocking the thread which is more elaborative of what is being discussed.
But if REXX is enabled for your CICS then try REXX's function TIME('L').
Back to top
View user's profile Send private message
steve-myers

Active Member


Joined: 30 Nov 2013
Posts: 917
Location: The Universe

PostPosted: Wed Sep 07, 2016 11:59 pm
Reply with quote

Robert Sample wrote:
2-s complement arithmetic has no bearing on the TOD clock. ...I've written a COBOL TOD translator, and your D14F0580 A6DE7000 represents September 7, 2016 at 12:33:19.628736 AM (which probably does not include the GMT offset

No argument. But it does matter to CVDG.

Actually there are two conversions to get local time; first you add CVTLDTOL (the main conversion) and then subtract CVTLSO (leap seconds). Do not use CVTTZ because you lose precision and it does not include leap seconds. FWIW, you are correct; D14F0580 A6DE7000 is not adjusted.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CICS

 


Similar Topics
Topic Forum Replies
No new posts Sysplex System won't IPL at DR site I... All Other Mainframe Topics 2
No new posts To get the the current time DFSORT/ICETOOL 13
No new posts RC query -Time column CA Products 3
No new posts C Compile time time stamps Java & MQSeries 10
No new posts Parallelization in CICS to reduce res... CICS 4
Search our Forums:

Back to Top