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 |
How to get the last record in vsam file in cluster? And how can you get the kids file records into your cobol program?
What is the difference between a binary search and a sequential search? What are the pertinent cobol commands?
01 MOVE 10 TO N 05 PERFOM PARA1 TIMES STOP RUN WAT WILL HAPPEN?? WILL IT RUN INFINITELY OR AN ERROR WIL BE THER BECAUSE NO OF TIMES IS NOT GIVEN??
How many maximum number of procedures can we write in one COBOL program?
if you give cylinder(1,1)how many cylinders it will be allocate?
SIGN TRAILING SEPARATE field occupy ?
What type of Call you would use if you don;t want the control back to the calling program?
what is sysncpoint?
i made it to stage 3 of an interview process wednessday they will quiz my knowledge again face to face for an analyst role recruiter said it will be based on Business requirements system is cobol and good ideas what they might ask etc
What is the difference between a subscript and an index in a table definition?
I have 100 records in a file.. i want to sort the records from 5 to 5o... give the syntax...
how the control comes back from subprogram to mainprogram