21
Thu, Nov
1 New Articles

Exploring Open Source on IBM i: The PASE Environment

Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

If you want to run open source solutions on IBM i, you need to know PASE. Follow this guidance to get started

Editor’s note: This article is excerpted from chapter 2 of Open Source Starter Guide for IBM i Developers.

PASE is an acronym for Portable Application Solutions Environment (after being initially called the Private Address Space Environment). In my book, it’s the Pretty Awesome Software Environment, where it seems like just about anything is possible.

PASE is important because it’s like Oz in The Wizard of Oz, where you suddenly leave the black and white world of RPG and then land, sometimes with a thud, into the color-filled world of open source. But what the heck is it? It’s an integrated runtime environment that allows you to run most AIX programs unaltered, right there on IBM i! It isn’t an emulation environment, nor is it interpreted. It is simply an AIX runtime with access to the full range of IBM i resources. It’s designed for accommodation, particularly for C and C++ programs, but also a full range of others.

PASE and ILE

There are really worlds that live in complete harmony on IBM i (for example, the ILE world and the PASE world). And the remarkable thing is that these worlds peacefully coexist, sharing many resources across what would seem to be an impenetrable wall. Here is just some of what is shared in these environments:

  • User/group profiles
  • Process structures
  • Thread structures
  • Database (DB2)
  • Integrated File System (IFS)
  • System Licensed Internal Code (SLIC) kernel, below Machine Interface (MI)
  • PowerPC machine instruction set (no emulation)
  • Most everything ... even “underwear”—such as hardware resources (disk, memory, CPU, and so on)

The IBM i really does have quite a unique architecture, and you are welcome to grub around on the Internet for more information, but I think the success of the architecture and the reason that PASE and ILE live so comfortably together is that the operating system lives well above the hardware; so much of what goes on with processor changes has little to no effect on the existing running applications. Sure, they run faster, but they also still run.

When was the last time you ran a DOS program from 1985 in Windows 10? OK, who would want to? Sometimes I hear complaints that folks make the latest POWER8 system look like a dinosaur because they are still running apps written in 1990 (or earlier) on IBM i. “Pshaw,” I say! Move some applications that run in PHP, or Ruby/Rails out of the constantly patched environments of Windows and get settled in on PASE or ILE on IBM i. Free up some admin time to have some fun, for goodness sakes. Life is too short to spend it patching security holes …, but let’s not go there right now. Classic buffer overflow exploits that fall over into some privilege-escalation bug just don’t happen in the PASE Garden of Eden. You are safe and secure there.

The beauty of sharing in PASE and ILE makes it the perfect place to leverage rock-solid business apps with nice, cutting-edge Web technologies like Node.js. What are the differences between the two? Let’s look at Table 1 below.

Table 2.1: Differences Between the PASE and ILE Environments

PASE

ILE

/QOpenSys/IBM

LIB/FILE.MBR

Debuggers “unlimited”

Debuggers “very limited”

Allows code generation

No code generation

Uses syscalls to kernel

Uses MI to kernel

ASCII

EBCDIC

Float, double, int, char

Adds packed, zoned

Main program (/PATH/mypgm)

ILE *PGM

Shared objects (lib.a, lib.so)

ILE *SRVPGM

Use env vars (PATH, LIBPATH)

Uses *LIBL

Shells (qp2term, ssh, bash …)

QSH (*PGMs)

Call ILE (_PGMCALL, _ILECALL)

Call PASE (Qp2RunPase, Qp2CallPase, QP2SHELL)


Even with these differences, there is much similarity. What I find in common particularly within each environment is the way you can leverage programs to work together. ILE allows for multiple languages and program objects to play well together. The same applies to PASE. Combined, PASE and ILE take advantage of the power of IBM i and maximize the flexibility in which you can approach building solutions. And, as much as I love to play within that garden of flexibility, the real value is that when it comes to running a business, you have a broad world of programming and solutions at your fingertips.

Installing PASE

No biggie here. You install using the Install Licensed Programs menu or command (you choose). The product is 5770-SS1 Option 33. It is a free licensed program, and actually this thing should come installed with the base OS, in my humble opinion. It seems to be an increasingly essential component of everything I run into. Keep it current with PTFs. Actually, as a runtime, I really never gave it a second thought after I installed it. Like the IBM i OS, it just runs.

PASE Applications

Remember that 5733OPS ships with a bunch of PASE-ready applications. They are already compiled for PASE, most likely for AIX version 5.1, which is the lowest common denominator for all currently supported versions of IBM i.

Theoretically (remember this is technology, not science), you can take binaries compiled for the corresponding AIX release and drop them into PASE, and they might work. Several websites have binaries ready for download and installation. The Young i Professionals website (http://yips.idevcloud.com/wiki/) is one, and the perzl.org website is another.

You can also compile your own binaries if you have an adventurous spirit and a lack of good common sense. I can’t remember exactly what year it was, maybe 2004 or so, that I was compiling PHP in PASE during the Thanksgiving holiday. It was an excruciating learning curve for a “seat of the pants” RPG programmer like me, but the gleeful happy dance that resulted from a clean compile was worth the effort. Nothing like trying something new and finally getting it to work! I just love this stuff. So, if a hack like me could figure it out from scratch over a decade ago, you certainly can do it today. There is plenty of help from many very good minds that know the PASE environment and can steer you through the ins and outs of compiling C code (it’s mostly C with some C++). The GNU compiler is now included as part of the 5733OPS license code offering. It’s practically begging you to try!

PASE apps can be written in C, C++, Fortran, or PowerPC assembler (!). PASE apps use the same binary executable format as AIX PowerPC applications, which is cool and very compatible. Those PASE binaries run in an IBM i job, and as I mentioned, PASE programs use IBM i system functions, such as file systems, security, and sockets. So, again, this is not an operating system within an operating system. The AIX runtime isn’t emulated; it is running on top of SLIC, just like RPG or COBOL, so not only do you have the full range of AIX APIs available, but they run fast. The best of both worlds. There is a broad subset of AIX technology available in PASE, including:

  • Standard C and C++ runtime (both threadsafe and non-threadsafe)
  • Fortran runtime (both threadsafe and non-threadsafe)
  • pthreads threading package
  • iconv services for data conversion (handy and available in ILE)
  • Berkeley Software Distributions (BSD) equivalent support
  • X Window System client support with Motif widget set
  • Pseudo terminal (PTY) support


You have your choice of shells, so you can be opinionated about such things (I'm a BASH guy myself). And if you happen to spend a bit of time in Linux distros, like I do, it eventually becomes as comfortable as that overstuffed chair you lounge in. You can enter the PASE world from the IBM i command line by calling QP2TERM, but why would you want to run a terminal emulator from within a terminal emulator? And the shell is terrible (OK, see, now I am opinionated about shells). Typically, you’d have a happier experience using SSH to access the PASE environment, and I highly recommend you do so. The open source Secure Shell (SSH) and Telnet client PuTTY is what I use, but there are several, and any of them will do the job.

Using PASE

You can call PASE programs from the ILE world, and vice versa. Table 2 shows a list of the commands that take you from one world to another (although the jump really isn’t that far).

Table 2: PASE to ILE and Vice Versa

PASE to ILE

ILE to PASE

_PGMCALL—Call *PGM

Qp2RunPase—Run PASE program (main)

_ILELOADX—Load *SRVPGM

Qp2dlopen—Load PASE module (*.a, *.so)

_ILESYMX—Find export symbol (proc)

Qp2dlsym—Find export symbol (function)

_ILECALLX—Call export procedure

Qp2CallPase—Call PASE function

_CVTSSP—Convert space pointer

Qp2dlclose—Close load

_CVTTS64—Convert teraspace addr

Qp2dlerror—Get last error dl operation

_GETTS64—Get teraspace addr

Qp2malloc—Alloc PASE heap memory

GETTS64SPP—Get teraspace addr

Qp2free—Free PASE heap memory

_GETTS64M—Get multiple teraspace

Qp2SignalPase—Post signal to PASE

_SETSPP—Set space pointer

Qp2EndPase—End PASE

SETSPPTS64—Set space pointer

Qp2jobCCSID—Get PASE job CCSID (last)

_SETSPPM—Set multiple space pointers

Qp2paseCCSID—Get PASE CCSID (last)

systemCL()—Run CL command

Qp2ptrsize—Get ptr size running PASE job


It’s actually pretty simple. Take a look at this CL program that runs the ls program in PASE (ls is the “list files” command similar to dir). It’s the “cheater’s” way to do it because I am just invoking the PASE shell and running the command within it.

PGM                                            

DCL VAR(&CMD) TYPE(*CHAR) LEN(20) VALUE('/QOpenSys/bin/ls')

DCL VAR(&PARM1) TYPE(*CHAR) LEN(10) VALUE('/')

DCL VAR(&NULL) TYPE(*CHAR) LEN(1) VALUE(X'00')

CHGVAR VAR(&CMD) VALUE(&CMD *TCAT &NULL)

CHGVAR VAR(&PARM1) VALUE(&PARM1 *TCAT &NULL)

CALL PGM(QP2SHELL) PARM(&CMD &PARM1)

ENDIT:

ENDPGM

The flip side is to invoke an ILE CL program from PASE. That takes a C language program, compiled in PASE:

/* sampleCL.c

example to demonstrate use of sampleCL to run a CL command

Compile with a command similar to the following.

xlc -o sampleCL -I /whatever/pase -bI:/whatever/pase/as400_libc.exp sampleCL.c

Example program using QP2SHELL() follows.

call qp2shell (’sampleCL’ ’wrkactjob’) */

#include <stdio.h>

#include <stdlib.h>

#include <errno.h>

#include <as400_types.h> /* PASE header */

#include <as400_protos.h> /* PASE header */

void main(int argc, char* argv[])

{

int rc;

if (argc!=2)

{

printf("usage: %s \"CL command\"\n", argv[0]);

exit(1);

}

printf("running CL command: \"%s\"\n", argv[1]);

/* process the CL command */

rc = systemCL(argv[1], /* use first parameter for CL command */

SYSTEMCL_MSG_STDOUT

SYSTEMCL_MSG_STDERR ); /* collect messages */

printf("systemCL returned %d. \n", rc);

if (rc != 0)

{

perror("systemCL");

exit(rc);

}

}

You may not be a C programmer, but I bet you can follow the coding here. You have a standard set of C header files—such as stdio.h, stdlib.h, and errno.h—and then some PASE-specific headers that reference the APIs and constants needed to make the CL call. In this case, you aren’t “shelling into” the IBM i command line and back out. The results will be piped directly back to the C program and displayed on the command line.

These examples, and a host of others, can be found in the IBM Knowledge Center PDF, IBM PASE for i (https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_71/rzalf/rzalfmstpdf.htm). My preference is for agonizing detail, explaining stuff that even the author thinks the audience should know, but this document is a little light on details in some places. If you can get the examples to compile, though, that learning curve alone should be a good grounding.

PASE is where all the action is in the IBM i open source software world. It’s a lush garden of goodness! Enjoy!

Peter Helgren

Peter Helgren is programmer/team lead at Bible Study Fellowship International. Pete is an experienced programmer in the ILE RPG, PHP, Java, Ruby/Rails, C++, and C# languages with more than 25 years of system 3X/AS400/iSeries/IBM i experience. He holds certifications as a GIAC certified Secure Software Programmer-Java and as an MCSE. He is currently executive vice president on the COMMON Board of Directors and is active on several COMMON committees. His passion has always been in system integration, and he focuses on open-source applications and integration activities on IBM i. Pete is a speaker/trainer in RPG modernization, open-source integration, mobile application development, Java programming, and PHP and actively blogs at petesworkshop.com.


MC Press books written by Peter Helgren available now on the MC Press Bookstore.

Open Source Starter Guide for IBM i Developers Open Source Starter Guide for IBM i Developers
Check out this practical introduction to open-source development options, including XMLSERVICE, Ruby/Rails, PHP, Python, Node.js, and Apache Tomcat.
List Price $59.95

Now On Sale

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: