Product Documentation
Cadence Interprocess Communication SKILL Reference
Product Version IC23.1, June 2023

Communication with Child Processes

A child process can be a program that executes normally under the given operating system. Design Framework II runs non-Cadence software as a child process. A child process can be as simple as execution of an Operating System utility, such as, mail, wc, cat, ls, stand-alone simulator, a batch program, and so forth. Basically any process can be a child process, and run in parallel with the parent process that created it.

The parent process communicates with a child process by writing to the child process’s stdin channel and reading from its stdout and stderr channels. Communication can be carried out in one of two modes: synchronous or asynchronous.

Child Process Output

When using SKILL interprocess communication, you should be aware of two possible modes of dealing with output from a child process. You can synchronize the flow of a program with child process output by performing blocking read operations. A blocking read operation will wait until data arrives from the child process thereby guaranteeing sequential flow of your program.

Alternatively, you can choose to deal with output from a child process by registering a call-back function (referred to in this document as outputHandler). This function will be called asynchronously whenever data is received from a child process and the event manager in the parent program is ready to handle the data.

There is only one mode of operation for the write function. Write always returns with a success/failure status. When a call to write returns, it does not always mean that the child process received the data. It just means that the data was dispatched successfully.

Blocking Reads and the SKILL Evaluation Process

You should determine in advance whether the use for SKILL IPC requires synchronous or asynchronous input and output handling, in which case either blocking reads or handlers should be the mode of operation. Synchronous and asynchronous output handling should not be mixed. An errHandler, once defined for a process, always receives the error messages despite a blocking read.

Remember when writing asynchronous data handling code that the SKILL evaluation process blocks out any incoming messages. These messages cannot be gathered until the evaluator winds down and control returns to the top level.

It is sometimes necessary to open gaps in the evaluator to collect incoming messages. These gaps can be opened using one of the following methods:

Tune the Handlers to Avoid Freezing Graphics

The data handlers are routines invoked by the SKILL interpreter in a non-deterministic fashion. You must tune their performance with respect to the frequency of incoming data because their activation can disrupt the responsiveness of the user interface graphics. Remember, it can be annoying to a user when the system feels unresponsive during the time data handlers are executing.

Wait for the Child to Become Active

The ipcBeginProcess and ipcSkillProcess function calls initiate a child process and return without waiting for that child to become active.

To synchronize the activity of the parent process with that of the child process spawning and being ready for communication, use the ipcWaitForProcess function to force the parent process to wait until the child process is ready to communicate.

Data Buffers

The input and output performed by child processes must take into account buffer limitations. The standard IO channels have a 4096 byte buffer. For example, child process output may not always get flushed immediately after the child writes to stdout. A child process may have to flush data at appropriate points so the parent process can receive the data.

Buffer limits do not apply to the SKILL-based parent process. For example, child process data is buffered in the parent process using memory pools limited only by the availability of runtime memory.

Data written to a child process’s stdin channel should be read by the child process frequently. When using the Windows Operating System, if the stdin channel buffer fills up then the parent process discards data to prevent blocking on write.

Child Process Handles

A child process handle returned from a call to ipcBeginProcess, ipcSkillProcess, or ipcBatchProcess is an opaque data structure.

Child Process Read-Only Properties

A child process handle has the following read-only properties that can be accessed programmatically using the -> syntax.

Property Meaning

command

Name of the command

host

Name of the host machine running the process

processPid

Process id of the child process on host

exitStatus

Exit status of the child process

priority

Priority given to the child process

type

Begin, SKILL, or Batch process

state

Active, Dead, or Stopped

Some of these properties are only meaningful if the child process is active. Once the child process expires, only state and exitStatus are guaranteed to have meaningful results.

Formatting Child to Parent SKILL Communication

Processes invoked using ipcSkillProcess send SKILL commands back to the parent for execution. Each command sent by the child must be formatted in the following way to ensure error-free execution.

Surround Each Command with Parentheses

For example, to send two println commands, format the string this way:

(println x) (println y) 

When the child performs multiple print statements in sequence, the parentheses are needed:

..printf("(println x) ");printf("(println x) "); 

Insert Spaces at the End of Each Command

Alternatively, use the SKILL prog construct to send compound statements to SKILL. SKILL commands sent by a child process can become packed together in one string and sent to SKILL to evaluate. Therefore, exercise care in using the correct syntax as in the example above.

This is similar to typing more than one command per line at the Command Interpreter Window. In fact, the CIW is a good place to experiment with formats of compound statements.

Detecting Child Process Termination

There are two ways of detecting child process termination:

Behavior is undefined if you mix the use of synchronous and asynchronous child process exit detection.

Related Topics

Interprocess Communication (IPC) SKILL


Return to top
 ⠀
X