Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Synchronized clause in COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
prabs2006

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Tue Feb 14, 2006 11:32 am    Post subject: Synchronized clause in COBOL
Reply with quote

Hi,

Can someone explain Synchronized clause in COBOL? I would like to have a complete detail to get to know about it.

T & R
Prabs
Back to top
View user's profile Send private message

ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Tue Feb 14, 2006 12:33 pm    Post subject:
Reply with quote

I think you can find a very detailed explanation in the fine manual.

O.
Back to top
View user's profile Send private message
prabs2006

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Tue Feb 14, 2006 5:20 pm    Post subject:
Reply with quote

Hi,

Thanks for the manual, but still unclear. It would be helpful if it can be explained with some examples as this seems to be a standard Q in cobol for all interviews


T & R
Prabs
Back to top
View user's profile Send private message
umeshkmrsh

New User


Joined: 21 Sep 2005
Posts: 79
Location: India

PostPosted: Tue Feb 14, 2006 5:29 pm    Post subject:
Reply with quote

Have u read Computer Organization? Do you know what a bit,byte and memory word means? Is so its a way to make sure that memory allocated to variables start from word boundries. As CPU reads words at a time and not bit or byte.


Hope you got it. If not? Better go to someone personally and ask him to explain it to you.
Back to top
View user's profile Send private message
prabs2006

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Fri Feb 17, 2006 9:56 am    Post subject:
Reply with quote

Hi Umesh,

As you suggest, Iam not that naive to not to know about bit/byte/word. There are other intricacies which are involved in Synchronized clause.
Memory allocated to variables start from word boundries is only the outer crux of it.

T & R
Prabs
Back to top
View user's profile Send private message
umeshkmrsh

New User


Joined: 21 Sep 2005
Posts: 79
Location: India

PostPosted: Fri Feb 17, 2006 11:15 am    Post subject:
Reply with quote

prabs2006 wrote:
Hi Umesh,

As you suggest, Iam not that naive to not to know about bit/byte/word. There are other intricacies which are involved in Synchronized clause.
Memory allocated to variables start from word boundries is only the outer crux of it.



So you know now that synchronized clause make memeory allocation to start from word boundries. Can u tell me what is the advantage of doing so? without knowing how CPU works.
Back to top
View user's profile Send private message
prabs2006

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Fri Feb 17, 2006 11:56 am    Post subject:
Reply with quote

Advantage: Run time performance will be significantly faster.
But What I need is to be xplained with an example so that the confusion in the total no of bytes alloted will be cleared.

01 ws-example.
05 ws-var1 pic x(3).
05 ws-var2 pic s9(04) comp sync.
05 ws-var3 pic 9(5).

How many bytes this will occupy?


T & R
Prabs
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Feb 19, 2006 5:46 am    Post subject:
Reply with quote

Hi Pras,

Have you tried to compile you example?
Back to top
View user's profile Send private message
prabs2006

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Mon Feb 20, 2006 10:01 am    Post subject:
Reply with quote

Hi,

I dont have the luxury of checking and compiling this code as I am in the transition phase. But as per theoretical study of Sync clause, this shud take 11 bytes as there will be a slack byte created by WS-var1
Am I right?

T & R
Prabs
Back to top
View user's profile Send private message
KS

New User


Joined: 28 Feb 2006
Posts: 91
Location: Chennai

PostPosted: Thu Mar 02, 2006 10:47 am    Post subject:
Reply with quote

SYNCHRONIZED clause :

- 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

- 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.

See the following example...declared without SYNC

01 ThreeBytes pic x(3) VALUE "GOD".
01 TwoBytes pic 9(4) COMP.

G O -> Word 1
D Num -> Word 2
ber space -> Word 3

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.

declared with SYNC :

01 ThreeBytes pic x(3) VALUE "GOD".
01 TwoBytes pic 9(4) COMP.

G O -> Word 1
D space -> Word 2
Num ber -> Word 3

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).

Hope this makes it clear..

Thanks,
KS
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm
No new posts COBOL Programming Sandpit? jodrisco COBOL Programming 6 Wed Apr 12, 2017 3:47 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us