what is the advantage of sync class

Answers were Sorted based on User's Feedback



what is the advantage of sync class..

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

what is the advantage of sync class..

Answer / ch.mohan

access will be fast wether it intraduce some slack bytes

Is This Answer Correct ?    3 Yes 1 No

what is the advantage of sync class..

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

Post New Answer

More COBOL Interview Questions

what is the difference between PA & PF keys?

1 Answers   IBM,


What is the default value of DISP parameter?

3 Answers   IBM,


what is the difference between Plan & package?

1 Answers   IBM,


we can use set true for condition names.. similarly can we code set to false in cobol pgm? will it work?

1 Answers  


How to increase the logical record length of existing PS file?

7 Answers  






Can you call an OS VS COBOL pgm from a VS COBOL II pgm ?

3 Answers   Microsoft,


Hi, My interviewer ask A calls B and C calls B, a and b are static c and b are dynamic.what happens if they compile and execute at same time.

3 Answers   iGate,


Can anybody give me example of subscript and index

5 Answers  


how many bytes does s9(7)COMP-3 field occupies?

6 Answers   ADP,


i want to learn mainframes. i completed MCA ,whats the future of mainframes

5 Answers  


how to code in cobol while using variable block file?

1 Answers  


what is amode(24), amode(31), rmode(24) and rmode(any)?

0 Answers  


Categories