what is the advantage of sync class

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to refer the data field?

1808


What is rmode(any) ?

686


can you please let me know if there is any walkins for COBOL/PLI/DB2/IMS/JCL in pune other than IBM and ITC infotech

1954


how can i see junk values in dclgen or in hostvariable of comp ?

2544


how do you reference the esds vsam file formats from cobol programs

632






How do you reference the fixed block file formats from cobol programs

703


If you are current on the owner of a set, what is the difference between obtain next and obtain first?

644


Why would you use find and get rather than to obtain?

683


which is Best IBM Mainframe Training and Placement Institute in Ameerpet Hyderabad

1022


How many bytes S(8) comp field occupy and its maximum value?

1630


What is link edit in cobol?

772


input= ,,,, mainframe training ,,, hyderabad .... location.... output1=$ mainframe training in hyderabad location$ output2=**** mainframe training in hyderabad location ****. In this pgn when we give input considering the spaces the output is displayed in this format.Like in the place of ,,,, $ should be displayed likewise.So please helpmeout.

1783


What are the different data types in cobol?

793


What type of SDLC u followed? Why?

1519


What is the use of intialize verb?

746