Chinaunix首页 | 论坛 | 博客
  • 博客访问: 354778
  • 博文数量: 90
  • 博客积分: 847
  • 博客等级: 准尉
  • 技术积分: 1373
  • 用 户 组: 普通用户
  • 注册时间: 2012-08-02 10:54
个人简介

跌打滚爬中的小菜鸟...

文章分类

全部博文(90)

文章存档

2015年(5)

2013年(47)

2012年(38)

我的朋友

分类: 系统运维

2012-10-25 13:49:38

先讨论CALL    CALLB     CALLP


CALL   Call a Program

说明应该是当前libl中现有的pgm,因此能直接CALLAPI应该是系统已经写好的现成程序了。。。有些API可以直接用CALL调用,例如QSNDDTA, QRCVDTA, QCMDEXC等。


CALLB  Call a Bound Procedure

不用声明而直接CALLB目标Procedure,这种调用要求在Bind(即装载)时所有的引用都已确定,因此CALLB是用来调用程序内部的Procedure的,但我不确定Module程序中的其它Module内的Procedure算不算‘内部’。这中调用方法一定是静态调用的,因为在编译时就需要确定。


CALLP  Call a Prototyped Procedure or Program

调用声明原型的Procedure或者Program,即必定在D表有相应的原型声明;其keywordEXTPGMEXTPROC中必须选一个,因此这里很容易理解,CALLP不仅能调用Procedure,也能调用Program,但是无论调用什么,都需要有原型声明!!!

The compiler then uses the prototype name to obtain an external name, if required, for the call. If the keyword EXTPGM is specified on the prototype, the call will be a dynamic external call; otherwise it will be a bound procedure call.

当指定EXTPGM时动态调用外部已存在的Program。否则,即EXTPROC静态调用Procedurecall bound Procedure)。

CALLP是用来调用外部的ProgramProcedure的。



再讨论CALLP中的 EXTPGM  EXTPROC


先看IBM信息中心关于两个API的说明     sleep()       QCMDEXC

sleep()--Suspend Processing for Interval of Time

  Syntax
#include unsigned int sleep( unsigned int seconds );
  Service Program Name: QPOSSRV1

  Default Public Authority: *USE

  Threadsafe: Yes

The sleep() function suspends a thread for a specified number of seconds. (Because of processor delays, the thread can sleep slightly longer than this specified time.) If an unblocked signal is received during this time and its action is to call a signal-catching function, to end the request, or to end the process, sleep() returns immediately with the amount of sleep time remaining.

If a SIGALRM signal is generated for the calling process while sleep() is running and if the SIGALRM signal is being ignored or blocked from delivery, sleep() does not return when the SIGALRM signal is scheduled. If the SIGALRM signal is blocked from delivery, the SIGALRM remains pending after sleep() returns.

If a SIGALRM signal is generated for the calling process while sleep() is running (except as a result of a previous call to alarm()) and if the SIGALRM is not being ignored or blocked from delivery, the SIGALRM signal has no effect on sleep() other than causing it to return.

A signal-catching function that interrupts sleep() can examine and change the time a SIGALRM is scheduled to be generated, the action associated with the SIGALRM signal, and whether SIGALRM is blocked from delivery.

If a signal-catching function interrupts sleep() and calls siglongjmp() or longjmp() to restore an environment saved prior to sleep(), thesleep() function is canceled. The action associated with the SIGALRM signal and the time at which a SIGALRM signal is scheduled to be generated are unchanged. The SIGALRM blocking action remains unchanged, unless the thread's signal mask is restored as part of the environment.

注意看红色部分


Execute Command (QCMDEXC) API


  Required Parameter Group:

1Command stringInputChar(*)
2Length of command stringInputPacked (15,5)

  Optional Parameter:

3IGC process controlINPUTChar(3)

  Default Public Authority: *USE

  Threadsafe: Yes.

   See  for command considerations.

The Execute Command (QCMDEXC) API runs a single command. It is used to run a command from within a high-level language (HLL) program or from within a CL program where it is not known at compile time what command is to be run or what parameters are to be used.

QCMDEXC is called from within your HLL program and the command it runs is passed to it as a parameter on the CALL command.

After the command runs, control returns to your HLL program.

Notes:

  1. Command strings in System/38 syntax can use the QCAEXEC API. The QCAEXEC API accepts the same parameters as QCMDEXC.
  2. The Process Commands (QCAPCMD) API also provides similar functions.Start of change
  3. If the command to be executed is a proxy command, the QCMDEXC API will resolve to the target command. If the target command is also a proxy, the process repeats until either a non-proxy command is found, or the proxy chain becomes greater than the allowed maximum. Once a non-proxy command is found, the resolved command will replace the proxy command in the command string to be executed.
  4. Proxy commands will be resolved before the command exit points QIBM_QCA_CHG_COMMAND and QIBM_QCA_RTV_COMMAND are called.End of change
这个API的说明就没说‘Service Program Name’。。。


很显然,系统中的API有两种方式:

①将某一API单独封装成一个独立的PGM

②将若干API集体封装成一个公用的Service Program

帖子http://blog.chinaunix.net/uid-27247475-id-3376864.html

中有使用这两个API的实际代码


对于第一种方式的API,可以直接使用CALL(即不声明原型),也可以使用CALLP EXTPGM(必须声明原型,并且声明时使用EXTPGM关键字)。


对于第二种方式的API,只能使用CALLP EXTPROC(必须声明原型,并且声明时使用EXTPROC关键字)。


To be continued...

阅读(3013) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~