IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Multi threading calls from COBOL


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Wed Feb 15, 2012 6:55 pm
Reply with quote

I have to optimise my current CPU utilization.
Scenario: I have to call 3 subprogrames from main program, so currently these programes are getting called one after another, but is there any way of calling these programes simultaneously?? if this can be achieved thru any of the CICS features then also its fine.
Please let me know in case of additional info.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Feb 15, 2012 7:00 pm
Reply with quote

How is calling 3 subprograms in parallel going to have any impact on CPU time? They are all doing the same work, and using the same resources, so there's no CPU impact from what you want to do.

In CICS you can use START to create an independent transaction, so if you recode the subprograms to run as transactions, you could run all three of them in parallel. This may require massive changes to the application, of course, as they no longer would be subprograms but independent main programs, but it could be done. Of course, total CPU utilization will probably go up from the CICS overhead of starting three more transactions.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Feb 15, 2012 7:28 pm
Reply with quote

Rohit, perhaps you can describe your problem to us, rather than look for a solution which may not help you at all.

By "CPU utilization" you mean the user wants a better response time, for instance?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Feb 15, 2012 7:32 pm
Reply with quote

is this a batch application or cics?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Feb 15, 2012 7:43 pm
Reply with quote

a brief scenario of what your program does would help us to make suggestions.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Thu Feb 16, 2012 8:35 am
Reply with quote

Thank you for all your replies..
Actually in the current project, we have various services that needs to be called from CICS environment.So currently I am taking very small example here, I am calling three services(Sub programes) from a driver CICS program(CICS) so they are getting executed seqentially, now my question was like instead of calling it sequentiall, is there any of calling/executing them parallel?
@Robert: You said is perfectly, but this change will not be only for 3 subprograms, as a mass level these would be hundreds of program that may get impacted.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Thu Feb 16, 2012 8:37 am
Reply with quote

And yes, I really don't guess, how would CPU stats will be looking after this change, but yes certainly it will help to reduce the execution time.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Thu Feb 16, 2012 8:41 am
Reply with quote

Also in a Batch, is there any way where we call the subprogram and don't expect control back again in the calling program? in CICS we have XCTL concept so anything similar to that in a batch?
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Thu Feb 16, 2012 10:21 am
Reply with quote

Something to think about your last question- how do you end the called program; GOBACK or STOP RUN..? Not a good programming practice, IMHO.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Feb 16, 2012 1:13 pm
Reply with quote

"Hundreds" of modules? Batch as well?

What is it you are imagining that you can do in this way? You need to be doing discrete tasks on discrete data guaranteed to be unaffected by other things happening at the time, in reality or potentiality. I'd really like to see how you imagine doing this for hundreds of different modules.

One thing you'd have to ensure is that users don't access the same data for update at the same time. That'd be fun.

And in batch?

Exactly, in some detail, outline what you imagine you would like to do, along with the benefits you'd feel would accrue, please.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Feb 16, 2012 2:39 pm
Reply with quote

use TD queues with ATI in CICS if you want to have tasks started without returning.

in batch, use MQS with ATI to start tasks, which will not return.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Thu Feb 16, 2012 3:41 pm
Reply with quote

Thank you for all your inputs,
We are fianally thinking of implementing this by the use of MQs.

@Bill:
Also in a batch is there any way of doing the same stuff??
I am imaging below things,
1)ProgA calls ProgB,ProgC,ProgD sequentially and each subprogram is updating into some DB2 table, and these sub programes are independent on each other(No common tables between them)
2)Now instead of calling them sequentially, Can we call them parallel and get the updations done as the total elapsed time in a job can be reduced?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Feb 16, 2012 4:07 pm
Reply with quote

Quote:
Can we call them parallel and get the updations done as the total elapsed time in a job can be reduced?


as explained earlier, initiating separate enclaves (batch multi-threading)
actually uses more resoures than simple CALLs within a thread.

and, the only way you are going to reduce elapsed time is:
  1. buy more hardware
  2. reduce the number of jobs running
  3. find the bottlenecks in you code and optimize
  4. redesign


and actually, 3 and 4 will only reduce CPU, which may or may not affect ELAPSED,
especially if 1 and 2 are not optimal.

suggestion: forget about multi-threading as a solution to your problem.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Feb 16, 2012 4:20 pm
Reply with quote

the whole topic is a complete waste of time ....
mostly due to poor terminology
let's start with
Quote:
I have to call 3 subprogrames from main program,

the sentence implies that after each call the control is returned to the main program
and running the 3 subprogram in <parallel> means some synchronization has to take place so that the main program resumes it' s flow only after all the 3 subprogram have finished their processing.
now if the subprograms were doing each a 10000by10000 matrix inversion
it might be worth to try to run them in parallel, but ....

... and now at the end it comes out that they are going to use MQ

most puzzling topic around
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Thu Feb 16, 2012 5:34 pm
Reply with quote

Thanks a ton again!!
@Enrico:
I would certainly have enrich my terminology, so as to avoid the confusion.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Feb 16, 2012 6:37 pm
Reply with quote

For batch it is simple. Design your system so that related tasks are in one job, unrelated tasks in others. Of course, don't do this and have each processing a huge amount of input, most of which is ignored..
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Feb 17, 2012 12:16 am
Reply with quote

you mention DB2.


how often are you issuing COMMITs?
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Fri Feb 17, 2012 12:59 pm
Reply with quote

I am issuing commit once in the main program( i.e when call to all the sub progs are successful).
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Feb 17, 2012 1:11 pm
Reply with quote

Quote:
We are fianally thinking of implementing this by the use of MQs.


Quote:
I am issuing commit once in the main program( i.e when call to all the sub progs are successful).

so You need a <synchronization> point after all the subprograms have <finished>
how does MQ fit in all this?

the hole is getting deeper and deeper ...
icon_eek.gif
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Feb 17, 2012 2:09 pm
Reply with quote

If you want to improve throughput, why not look at the problems in the existing programs, rather than try to invent some way around it?

You seem to be introducing extra complexity without any surety of benefit as regards throughput. Test it thoroughly with a dummy set of modules to prove the concept as it applies to your system. For performance issues the biggest improvements, after things caused by plain stupidity, are from changes to how existing logic is implemented, but to the extent of doing it "better" rather than doing the same thing is some magic new way.

By the way, can we assume you mean you commit once after each set of calls, rather than "once" fullstop?
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Mon Feb 20, 2012 7:25 pm
Reply with quote

@Bill: Yes, I commit once after all 3 calls.
This was just a thought, that came to my mind of having MQs used..Let me now test this and if it really takes less time with 100% fuctionality then would be key success, otherwise I still need to think of some other thing around.
Thanks you All again for your thoughts/suggesstions.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top