what is the advantage of sync class
Answers were Sorted based on User's Feedback
Answer / rajini
The SYNCHRONIZED clause is sometimes used with USAGE IS
COMP or USAGE IS INDEX items. It is used to optimize speed
of processing but it does so at the expense of increased
storage requirements.
Many computer memories are organized in such a way that
there are natural addressing boundaries - such as word
boundaries. If no special action is taken some data items
in memory may straddle theses boundaries. This may cause a
processing overhead as the CPU may need two fetch cycles to
retrieve the data from memory.
The SYNCHRONIZED clause is used to explicitly align COMP
and INDEX items along their natural word boundaries.
Without the SYNCHRONIZED clause, data-items are aligned on
byte boundaries.
The word SYNC can be used instead of SYNCHRONIZED.
For the purpose of illustrating how the SYNCHRONIZED clause
works let us assume that a COBOL program is running on a
word-oriented computer where the CPU fetches data from
memory a word at a time.
01 three-byte pic x(3) value 'dog'.
01 two-byte pic s9(4) comp .
In this program we want to perform a calculation on the
number stored in the variable TwoBytes (as declared in the
diagram below). Because of the way the data items have been
declared, the number stored in TwoBytes straddles a word
boundary.
In order to use the number, the CPU has to execute two
fetch cycles - one to get the first part of the number in
Word2 and the second to get the second part of the number
in Word3. This double fetch slows down calculations.
01 three-byte pic x(3) value 'dog'.
01 two-byte pic s9(4) comp sync .
Now consider the impact of using the SYNCHRONIZED clause.
The number in TwoBytes is now aligned along the word
boundary, so the CPU only has to do one fetch cycle to
retrieve the number from memory. This speeds up processing
but at the expense of wasting some storage (the second byte
of Word2 is no longer used).
Is This Answer Correct ? | 9 Yes | 1 No |
Answer / ch.mohan
access will be fast wether it intraduce some slack bytes
Is This Answer Correct ? | 3 Yes | 1 No |
Answer / nagaraj ramamoorthy
The purpose of the SYNC clause (when it was introduced) was
to align the data names to the natural machine word
boundaries so that it will be efficient to retrieve data.
This was introduced when the processing speed was very slow
and system was built on word architecture. Modern systems
are quite fast and this does not make significant
difference.
It can be used to numeric and alphanumeric data items. you
can also specify how to align RIGHT/LEFT. if you do not
specify, complier will take the best one that is efficient.
It should be used with 01 and 77 levels and it should not
be used with group items, because compiler will add
bits/bytes in between group items so finding the exact size
will be difficult for the programmer.
Is This Answer Correct ? | 0 Yes | 1 No |
perform I from 0 by 1 until I=5?How maney times it will executes
how do you reference the variable block file formats from cobol programs
what is meaning by design document? who can repared for this?
plz,could any one tell me? what about EBCDIC in cobol?briefly?
What is a subscript ?
Read a flat file and write last but one (I have n records in a file I have to write n-1th) record in another flat file. Could you please provide me the code in COBOL?
What will happen if we generate GDG (+2) version without generating (+1) version?
how to transfer the file from pc to mainframe??
How can we increase the size of an existing PDS to include more no. of modules. I tried the answer posted by Jagan(TSO PDS 'pds name') but did not find it working. The answer posted by kamal i know very well. Please suggest me a answer so that we don't need to delete the existing PDS and still we can change the size as well.
what are the error codes in cobol, db2, cics, vsam , and jcl
How does IDMS communicate with CICS?
what is the meaning of pic 9(09)v99-