跌打滚爬中的小菜鸟...
分类: 系统运维
2012-10-25 13:49:38
先讨论CALL CALLB CALLP
CALL Call a Program
说明应该是当前libl中现有的pgm,因此能直接CALL的API应该是系统已经写好的现成程序了。。。有些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表有相应的原型声明;其keyword在EXTPGM和EXTPROC中必须选一个,因此这里很容易理解,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静态调用Procedure(call bound Procedure)。
CALLP是用来调用外部的Program和Procedure的。
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
1 | Command string | Input | Char(*) |
2 | Length of command string | Input | Packed (15,5) |
3 | IGC process control | INPUT | Char(3) |
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:
很显然,系统中的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...