ILE COBOL Language Reference

Benefits of Synchronized Data

What is the benefit of synchronizing data? Improved performance in terms of its accessibility. The penalty is some wasted storage, due to increased record size (filler spaces become part of the record).

Level 01 items and pointers are aligned on 16-byte boundaries always, whether synchronization is specified or not. You are allowed to specify synchronization only for elementary items. It is not permitted for group items.

Figure 10 illustrates the concept:

Figure 10. Data Storage Representation Without and With Synchronization


Figure 10 shows that A and B are always aligned on 16 byte boundaries. Without synchronization, A2 and A3 are stored contiguously regardless of size. With synchronization, a 4 byte boundary is chosen (due to A3's type), and A3 is aligned accordingly. There is a one byte filler between A2 and A3. However, A3 should be accessed faster.

Synchronization and Offsets

In the preceding figure, note that A and B do not have to be following each other in actual storage. In other words, you cannot know if B starts 16 bytes after A's start, or 48 bytes (16 x 3), or 16 x N bytes. You must not attempt to retrieve synchronized data by specifying offsets.

+-------------------------------IBM Extension--------------------------------+

The SYNCHRONIZED clause is implicit for pointer data and procedure-pointer data items. Pointer data and procedure-pointer data items declared in the Linkage Section are not synchronized.

The SYNCHRONIZED clause cannot be specified in the same data description entry as the TYPE clause.

The SYNCHRONIZED clause is ignored for a DBCS, national, external floating-point, date, time, or timestamp data item.

The SYNCHRONIZED clause for a COMPUTATIONAL-1 data item aligns the data on a fullword boundary.

The SYNCHRONIZED clause for a COMPUTATIONAL-2 data item aligns the data on a doubleword boundary.

+----------------------------End of IBM Extension----------------------------+

Depending on the USAGE that is specified for an item, the SYNCHRONIZED clause has a particular effect. Table 17 shows how the USAGE of an item determines the effect of the SYNCHRONIZED clause upon it.

Table 17. Data Item USAGE and the SYNCHRONIZATION Clause

If the USAGE is... The SYNCHRONIZED clause...
DISPLAY is syntax checked but does not affect execution
DISPLAY-1 (DBCS) is ignored
NATIONAL is ignored
PACKED-DECIMAL is syntax checked but does not affect execution
COMPUTATIONAL-1 aligns the data on a fullword boundary
COMPUTATIONAL-2 aligns the data on a doubleword boundary
COMPUTATIONAL-3 is syntax checked but does not affect execution
BINARY:
  PIC S9(1) through PIC S9(4)
aligns data item at a multiple of 2 relative to the beginning of the record
BINARY:
  PIC S9(5) through PIC S9(9)
aligns data item at a multiple of 4 relative to the beginning of the record
BINARY:
  PIC S9(10) through PIC S9(18)
aligns data item at a multiple of 8 relative to the beginning of the record
COMPUTATIONAL-4 functions the same as for USAGE BINARY
COMPUTATIONAL is syntax checked but does not affect execution
INDEX is not permitted
POINTER aligns data item at a multiple of 16 relative to the beginning of the record
PROCEDURE-POINTER functions the same as for USAGE POINTER

The length of an elementary item is not affected by the SYNCHRONIZED clause.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]