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 |
C1 C2 C3 are three conditions whose TRUTH values are as folloes. C1-TRUE C2-FALSE C3-TRUE A,B,C are defined as given below A:C1 AND(NOT C2) OR C3 B.(NOT C1) OR (NOT C2 AND NOT C3) C.(C1 OR C2)AND C3 D.C1 AND C2 OR C3 given the above information which of the following statements are valid? a.only A,B and C are TRUE b.only A,C and D are TRUE c.A,B,C and D are TRUE d.only C and D are TRUE
I have 100 records in a file.. i want to sort the records from 5 to 5o... give the syntax...
What is the difference between a binary search and a sequential search what are the pertinent cobol?
What is diff between vsam and db2?what is advantage of db2 over vsam?which is best suited one?
when SE37 SB37 and sd37 occurs how to increase the volume , primary quantity and secondary quantity?
What are declaratives and what are their uses in cobol?
A LESS 1200 IF B GREATER 25 MOVE 47 TOC ELSE MOVE 57 TO C IF A GREATER 249 MOVE 67 TO C ELSE NEXT SENTENCE ELSE IF B LESS 67 MOVE 27 TO C What will be the value of C, when A is 137 and b is 25
What is XDC ?
waht is inspect verb? where it can be in real time?
If i initialize the 01 level variable in array, will it initialize all the array elements (occurs)?
How does IDMS insure data integrity?
Can printer files (having 133 characters) be of variable length?