An Introduction to Mainframes
Rijo Joseph
05-Dec-2007
An Introduction to Mainframes
To
Reena Paulson Alapatt
My sister and best friend…
An Introduction to Mainframes - 2 -
PREFACE
This is a humble effort to introduce mainframes
DISCLAIMER
No author writes a book without enormous help from others. I have drawn insights and ideas from many sources - from the IBM manuals to The Times of India Capital Edition. This book is a best effort on my part; I tried my level best to gather correct information from reliable sources.
COPYRIGHT
You can make as many copies of this book as you wish. I would be happy if you share it with others. You can’t sell it, nor modify the contents of this book, nor claim the material as your own, nor replace my name with another.
ABOUT THE AUTHOR
Rijo Joseph holds Masters Degree in Computer Applications from University of Kerala (India) and at present working as a technical team lead with IBM India Pvt Ltd
The author is IBM certified DB2 Associate, DB2 Application Developer, and Solutions Expert
Your feedback is most welcome; send your comments to rijo.joseph@in.ibm.com
ABOUT THE BOOK
The book has been divided into two parts. The PART-1 contains information about computing history, computers, mainframes and mainframe OS and PART-2 contains Tips and Tricks and technical tidbits in COBOL, JCL, and DB2 etc
BOOK EDITIONS
Dec-05-07 – First Edition
The author shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book.
An Introduction to Mainframes - 3 -
ACKNOWLEDGEMENT
It took me almost 3 years and a rigorous 2 months to complete this work. And I could say those 2 months were the toughest time in my life. The almighty chose those 2 months to teach me few tough lessons in life; however he made sure that my work is completed on time. Strange are your ways O Lord!
I chose Dec 5 to publish this book as today is my sister’s birthday. This book goes as a surprise birthday gift to my sister. She is the one who ignited a change in my life that enabled me to think beyond the boundaries
I express my sincere gratitude to
My parents, AV Joseph and Elsamma Joseph, my brother in law and sister, Paulson Jose Alapatt and Reena Paulson Alapatt, my cousins Fr. Benny Maramparampil and Sr. Tresa John for their love, support, guidance and prayers
My managers at US Technologies - Saju Mathew, Sabu Purushothaman, Rajesh Subramony, Sunil Balakrishnan, Manjith Sundaresan and my managers at IBM India - Rajiv Mittal, Pawan Wig, Gautam K Varma, Santanu Dev for an unmatched support, motivation and guidance
My SMEs, Managers and Technical Staff at Duke Energy/IBM US. This book goes as a souvenir for a 2 year long association with them. The motivation and help provided by Dave Miller, Tom Susman, Jim Kanet, Don Shull, and Grant Marsh were fantastic. They are a group of wonderful people.
My friends, specifically to Lismi Sundaran, Nancy George, Sooraj Puthiyadath and Sarath Babu who made me believe that I could actually complete this work and most of the time they woke me up from my dreams and put me on my writing chair
Sandeep Midha for providing me with the necessary reference books and Prateek Vijayvergia for providing me with necessary software for converting my work in MS Word to a .pdf format
All the ‘ghosts’ who came to interfere in my work, though you could take several days out of my schedule and you could crush me to the maximum, you couldn’t do anything else. The baton is still in my hand and I have the final laugh. I enjoyed your presence, you taught me few lessons too. Thanks for that and better luck next time!
I wanted to write a complete book, but I found it would take more years for me to complete, I followed a prototype approach. I will refine this book as and when I get valuable suggestions and advices from you.
You can send your valuable suggestions to [email protected] or you can post your comments at http://www.geocities.com/rijosmailbox
Rijo Joseph Dec-05-2007
An Introduction to Mainframes - 4 -
TABLE OF CONTENTS
PART - 1
Chapter - 1
1. A Brief History of Computing ...... 16 1.1. Abacus...... 16 1.2. Napier’s Bones...... 17 1.3. Blaise Pascal and Pascaline ...... 18 1.4. Gottfried Wilhelm Leibniz and Leibniz’s calculator ...... 18 1.5. Joseph Marie Jacquard and Punched Cards ...... 19 1.6. Charles Babbage ...... 20 1.7. Herman Hollerith and the Tabulating Machine ...... 21 1.8. History of IBM...... 21 1.9. Generation of Computers...... 22 1.9.1. Evolution of the First Generation of Modern Computers...... 22 1.9.2. The First Generation ...... 23 1.9.2.1. ENIAC ...... 24 1.9.2.2. EDVAC...... 25 1.9.2.3. EDSAC ...... 25 1.9.2.4. UNIVAC – I ...... 25 1.9.3. The Second Generation...... 26 1.9.4. The Third Generation...... 26 1.9.5. The Fourth Generation...... 28 1.9.6. The Fifth Generation...... 30
Chapter - 2
2. Computer Classifications ...... 32 2.1. Digital Computer ...... 32 2.1.1. Special Purpose Computer...... 33 2.1.2. General Purpose Computer...... 33 2.1.3. Microcomputer...... 33 2.1.4. Minicomputer...... 33 2.1.5. Mainframe Computer...... 35 2.1.6. Super Computer ...... 37 2.2. Analog Computer...... 40 2.3. Hybrid Computer ...... 40
An Introduction to Mainframes - 5 -
Chapter - 3
3. More about Mainframes...... 42 3.1. Factors Contributing to Mainframe use ...... 43 3.1.1. Reliability, Availability, and Serviceability...... 43 3.1.2. Security ...... 43 3.1.3. Scalability ...... 43 3.1.4. Continuing Compatibility ...... 44 3.2. Typical Mainframe Workloads ...... 45 3.2.1. Batch Processing...... 45 3.2.2. Online Transactional Processing...... 46 3.3. A peep into the history...... 47 3.3.1. System/360...... 47 3.3.2. System/370...... 49 3.3.2.1. Multiprocessing ...... 52 3.3.2.2. Channels ...... 52 3.3.2.3. PR/SM...... 53 3.3.2.4. LPAR ...... 53 3.3.2.5. I/O Devices ...... 53 3.3.2.5.1. Unit Record Devices...... 53 3.3.2.5.2. Magnetic Tape Devices ...... 54 3.3.2.5.3. Direct Access Device...... 54 3.3.2.6. Data Communications Equipment...... 55 3.3.2.7. Characteristic Features of Mainframe OS ...... 56 3.3.2.7.1. Virtual Storage...... 56 3.3.2.7.2. Multiprogramming...... 57 3.3.2.7.3. Spooling...... 57 3.3.2.7.4. Batch Processing...... 57 3.3.2.7.5. Time Sharing...... 58 3.3.2.8. A small mainframe configuration...... 59 3.3.2.9. MVS Concepts...... 60 3.3.2.9.1. Address Space...... 60 3.3.2.9.2. Paging ...... 61 3.3.2.9.3. Expanded Storage ...... 62 3.3.2.9.4. Swapping ...... 62 3.3.2.10. The MVS system ...... 63 3.3.2.10.1. System Generation...... 63 3.3.2.10.2. System Initialization ...... 64 3.3.2.11. XA and 31 bit addressing ...... 64 3.3.3. System/390...... 65 3.3.4. eServer zSeries 900...... 67 3.3.5. eServer zSeries 990...... 69
An Introduction to Mainframes - 6 -
Chapter - 4
4. z/Architecture and z/OS ...... 73 4.1. Logical Structure of a z/Architecture system with 2 CPUs ...... 73 4.1.1. Main Storage...... 73 4.1.2. Expanded Storage ...... 74 4.1.3. CPU...... 74 4.1.3.1. PSW ...... 74 4.1.3.2. General Registers...... 75 4.1.3.3. Floating Point Registers...... 75 4.1.3.4. Floating Point Control Register ...... 75 4.1.3.5. Control Registers ...... 75 4.1.3.6. Access Registers ...... 75 4.1.4. Cryptographic Facility ...... 76 4.1.5. External Time Reference ...... 76 4.1.6. I/O ...... 76 4.1.7. Channel Subsystem...... 76 4.1.8. Channel Paths...... 77 4.1.9. I/O Devices and Control Units...... 77 4.1.10. Operator Facilities...... 77 4.2. Operating System...... 77 4.3. z/OS...... 78 4.3.1. Hardware resources used by z/OS ...... 78 4.3.2. Multiprogramming and Multiprocessing ...... 79 4.3.3. Control Blocks ...... 79 4.3.4. Physical Storage used by z/OS ...... 80 4.3.5. More about storage ...... 80 4.3.5.1. Storage Addressing...... 81 4.3.5.2. Information Formats ...... 81 4.3.5.3. Integral Boundaries...... 81 4.3.5.4. Address Types ...... 82 4.3.5.4.1. Absolute Address...... 82 4.3.5.4.2. Real Address...... 82 4.3.5.4.3. Prefixing ...... 82 4.3.5.4.4. Virtual Address...... 82 4.3.5.5. Cache Memory...... 83 4.3.5.6. Virtual Memory ...... 83 4.3.5.7. Virtual Memory and z/OS...... 85 4.3.5.7.1. What does it really mean?...... 85 4.3.5.8. Address Space...... 85 4.3.5.9. Virtual Storage Operation - Overview...... 86 4.3.5.9.1. Paging ...... 86 4.3.5.9.2. Virtual Storage Address...... 87 4.3.5.9.3. Dynamic Address Translation ...... 88 4.3.5.9.4. Frames, Pages, and Slots...... 90 4.3.5.9.5. Page Stealing...... 91 4.3.5.9.6. Swapping ...... 91
An Introduction to Mainframes - 7 -
4.3.6. Brief History of 64 bit addressability...... 92
Chapter - 5
5. Leftover...... 96 5.1. Job roles in the mainframe world...... 96 5.1.1. System Programmer...... 96 5.1.2. System Administrator ...... 97 5.1.3. Application Designers and Programmers ...... 97 5.1.4. System Operator...... 98 5.1.5. Production Control Analyst ...... 98 5.2. Program Products for z/OS ...... 98
PART - 2
Chapter - 1
1. COBOL – Tips and Tricks...... 102 1.1. Tips and Tricks! ...... 102 1.2. BLOCK Structure in Files (COBOL) – General Perspective ...... 102 1.3. REDEFINES Clause ...... 104 1.4. RENAMES Clause...... 105 1.5. USAGE Clause ...... 107 1.5.1. USAGE IS DISPLAY...... 107 1.5.2. USAGE IS COMPUTATIONAL / COMP / BINARY ...... 107 1.5.3. USAGE IS COMP-1...... 108 1.5.4. USAGE IS COMP-2...... 108 1.5.5. USAGE IS COMP-3...... 108 1.6. Different forms of EVALUATE Statement...... 109 1.7. Do you know?...... 110 1.7.1. Performance Considerations for Indexes VS Subscripts ...... 110 1.7.2. Rule of the Thumb for SEARCH and SEARCH ALL...... 110 1.7.3. Packed Decimal ...... 111 1.8. Meaning of Device Name in SELECT Clause...... 111 1.9. NEXT SENTENCE and CONTINUE ...... 111 1.10. S0C7 Abend ...... 113 1.11. SEARCH and SEARCH ALL...... 122 1.12. Static and Dynamic Subroutine CALLs...... 122 1.12.1. Static CALLs ...... 122 1.12.1.1. Good things about Static CALLs...... 122 1.12.1.2. Bad things about Static CALLs...... 123 1.12.2. Dynamic CALLs...... 123 1.12.2.1. Good things about Dynamic CALLs ...... 124 1.12.2.2. Bad things about Dynamic CALLs ...... 124
An Introduction to Mainframes - 8 -
1.12.3. Which is Better Static or Dynamic?...... 124 1.13. Why READ FILE and WRITE RECORD? ...... 125 1.14. RETURN CODE of Internal SORT...... 125 1.15. Efficient COBOL Coding Techniques...... 125 1.15.1. Data Types ...... 125 1.15.1.1. BINARY (COMP OR COMP-4)...... 125 1.15.1.2. PACKED DECIMAL (COMP-3)...... 126 1.15.2. Comparing Data Types ...... 127 1.15.3. Data Conversions...... 127 1.15.4. INDEXES Vs SUBSCRIPTS ...... 128 1.16. Compiler options that affect run time performance ...... 128 1.16.1. AWO or NOAWO ...... 128 1.16.2. OPTIMIZE(STD), OPTIMIZE(FULL) OR NOOPTIMIZE ...... 129 1.16.3. SSRANGE or NOSSRANGE...... 129 1.16.4. TRUNC – BIN, STD OR OPT ...... 130 1.16.5. NUMPROC – NOPFD, MIG OR PFD ...... 130 1.16.6. DYNAM Or NODYNAM ...... 131 1.16.7. RENT or NORENT...... 131 1.17. Run Time Options that Affect Run Time Performance ...... 132 1.17.1. ALL 31...... 132 1.17.2. CHECK...... 132 1.18. Dynamic Array...... 133
Chapter - 2
2. DB2 – Tips and Tricks...... 135 2.1. Null Indicator...... 135 2.2. DBRM...... 135 2.3. Plan ...... 135 2.4. Synonym ...... 135 2.5. Alias ...... 136 2.6. Views ...... 136 2.7. How to Run a DB2 Batch Program...... 137 2.8. Why SELECT * is not preferred in embedded SQL programs?...... 137 2.9. How does DB2 store NULL physically? ...... 137 2.10. Concatenate...... 137 2.11. COALESCE Function in DB2 ...... 137 2.12. DCLGEN ...... 138 2.13. EXPLAIN...... 139 2.14. FETCH FIRST n ROWS ONLY...... 139 2.15. OPTIMIZE FOR n ROWS...... 140 2.16. RUNSTATS...... 141 2.17. IMAGECOPY...... 142 2.18. DECIMAL(n,m)...... 142 2.19. Indicator Variable and -305 ABEND...... 142 2.20. CASE Expressions ...... 143
An Introduction to Mainframes - 9 -
2.21. Query Management Facility...... 147
Chapter - 3
3. JCL – Tips and Tricks...... 154 3.1. IEBCOPY ...... 154 3.1.1. Copy an entire PDS to another PDS ...... 154 3.1.2. Convert a PDS to a PDSE...... 155 3.1.3. You will get error if you try the following JCL...... 155 3.1.4. Unloading...... 156 3.1.5. Loading ...... 156 3.1.6. Compressing ...... 157 3.1.7. SELECT...... 157 3.1.8. EXCLUDE...... 158 3.1.9. Rename ...... 158 3.1.10. Merging PDSs...... 159 3.2. IEBGENER...... 159 3.2.1. Create a data set from in stream data...... 160 3.2.2. Backup of a PDS/PDSE member to another PDS/PDSE...... 160 3.2.3. Backup of a sequential data set to another sequential data set...... 161 3.2.4. Backup of a sequential data set to a member of a PDS/PDSE...... 161 3.2.5. Back up copy of a PDS/PDSE member to a sequential data set...... 162 3.2.6. To produce PDSE from a PDS member ...... 162 3.2.7. To change the block size...... 163 3.2.8. You will get error if you try the following JCL...... 163 3.3. PDSE...... 164 3.3.1. Batch Allocation ...... 164 3.3.2. TSO/E Allocation...... 165 3.3.3. ISPF Allocation...... 165 3.3.4. IEBCOPY TO CONVERT A PDS TO PDSE...... 166 3.3.5. When to use a PDSE...... 166 3.4. (NEW, CATLG, CATLG) and a production ABEND...... 167 3.5. Another Production ABEND – JCL ERR...... 168 3.6. ICETOOL ...... 169 3.7. ICETOOL - count the records...... 170 3.8. SORT – modify the output record...... 171
Chapter - 4
4. DFSORT – Tips and Tricks ...... 174 4.1. DFSORT Unleashed ...... 174 4.2. A simple JCL for SORT ...... 175 4.3. INCLUDE Control Statement...... 176 4.4. Bit Logic Tests...... 187
An Introduction to Mainframes - 10 -
Chapter - 5
5. TSO/ISPF – Tips and Tricks...... 192 5.1. COBOL Compiler Version ...... 192 5.2. HRECALL ...... 192 5.3. TSO SEND/TRANSMIT ...... 192 5.4. Information about your DS ...... 192 5.5. Save a sequence of commands...... 192 5.6. Tape Datasets...... 192 5.7. SB37 on Saving a DS...... 193 5.8. No space in directory ...... 193 5.9. CREATE/REPLACE ...... 193 5.9.1. CREATE...... 193 5.9.2. REPLACE...... 194 5.9.3. Saving a DS in view mode...... 194 5.10. CUT/PASTE ...... 194 5.11. ISPF EDITOR COMMANDS ...... 195 5.12. FLIP ...... 196 5.13. Auto complete...... 196 5.14. NRETRIEV...... 197
Chapter - 6
6. VSAM – Tips and Tricks...... 199 6.1. VSAM Basics...... 199 6.1.1. VSAM Overview ...... 199 6.1.2. What is VSAM?...... 199 6.1.3. Catalog Management ...... 200 6.1.4. Record Management ...... 200 6.1.5. Logical Record & Physical Record...... 200 6.1.6. Control Interval...... 200 6.1.7. More about VSAM ...... 201 6.2. VSAM Data Sets...... 202 6.2.1. KSDS ...... 202 6.2.2. ESDS...... 203 6.2.3. RRDS ...... 204 6.2.4. LDS...... 205 6.3. Accessing & Inserting VSAM Data...... 206 6.4. Alternate Index...... 209 6.5. PATH and AIX ...... 211
An Introduction to Mainframes - 11 -
Chapter - 7
7. General – Tips and Tricks...... 214 7.1. 10 Common Abends ...... 214 7.2. Comparing 2 files of different layouts ...... 215 7.3. Counting the number of records ...... 216 7.3.1. Tape Data Set...... 216 7.3.2. DASD Data Set...... 216 7.4. Processing Options in IMS DB...... 217 7.4.1. DEFINING THE IMS DATABASE ...... 217 7.4.2. IMS DL/I DATA BASE TYPES ...... 219 7.4.3. PROCOPT...... 221
Chapter - 8
8. ISPF Editor Commands ...... 225 8.1. < - Data Shift Left...... 225 8.2. > - Data Shift Right...... 225 8.3. ( - Column Shift Left...... 225 8.4. ) - Column Shift Right ...... 225 8.5. AUTOSAVE...... 226 8.6. BOUNDS ...... 226 8.7. BROWSE...... 227 8.8. CHANGE...... 228 8.9. COMPARE ...... 228 8.10. CREATE/REPLACE ...... 232 8.10.1. CREATE...... 232 8.10.2. REPLACE...... 232 8.10.3. Saving a DS in view mode...... 233 8.11. CUT/PASTE ...... 233 8.12. DEFINE ...... 234 8.13. EDIT...... 235 8.14. EDITSET or EDSET...... 235 8.15. F ...... 235 8.16. FLIP ...... 236 8.17. L ...... 236 8.18. LC/LCC...... 236 8.19. LOCATE/L ...... 236 8.20. O...... 236 8.21. PROFILE ...... 239 8.22. RECOVERY ...... 239 8.22. SETUNDO...... 240 8.23. SORT ...... 240 8.24. TS...... 240
An Introduction to Mainframes - 12 -
8.25. UC ...... 240 8.26. UNDO ...... 240
An Introduction to Mainframes - 13 -
PART - 1
An Introduction to Mainframes - 14 - A Brief History of Computing
Chapter 1
A Brief History of Computing
An Introduction to Mainframes - 15 - A Brief History of Computing
1. A Brief History of Computing
It has been an amazing journey… really it is. As you go through this chapter, you can see the computer takes its shape from an abacus to a lap top machine! What a transformation!
The transformation took a slow and steady fashion - Abacus, Napier’s Bones, Pascaline…Vacuum Tubes, Transistors, Integrated Circuits, Micro Processors…
The true brilliance is human: the genius of men and women who have found a way to translate a variety of information from the real world into the zero’s and one’s of binary code – the logical and mathematical language tailor made for a computer’s electronic circuitry - the language of the machines.
Computer is not really a brain, not at least till now. Rather it is simply another tool, another piece of machinery devised to reduce labor or extend our mastery of the world
Still, no other machine in history has so rapidly or so thoroughly changed the world. Computers have made possible such epic achievements as lunar landings, and planetary probes, and they account for a myriad everyday conveniences and benefits in the field of science, medicine, education, banking, communication etc.
In short, computers have woven into the very fabric of modern life. Despite the head- spinning pace of modern advances, the foundations of the computer revolution were built in slow and fitful fashion
1.1. Abacus
A starting point, more than 1500 years ago, and probably in the Mediterranean world – was the development of abacus. An abacus, also called a counting frame, is a calculating tool for performing arithmetical processes, often constructed as a wooden frame with beads sliding on wires. The user, called an abacist, slides counters by hand on rods or in grooves. The abacus was so efficient that it soon spread far and wide
A Chinese Abacus
An Introduction to Mainframes - 16 - A Brief History of Computing
European thinkers of the era were fascinated by the challenge of devising aids to calculations
1.2. Napier’s Bones
John Napier published his discovery of Logarithms in 1614 and in 1617 came up with an aid to multiplication called ‘Napier’s Bones’
Napier's Bones, an abacus, invented by John Napier for calculation of products and quotients of numbers
The abacus consists of a board with a rim; the user places Napier's rods in the rim to conduct multiplication or division. The board's left edge is divided into 9 squares, holding the numbers 1 to 9. The Napier's rods consist of strips of wood, metal or heavy cardboard. Napier's bones are three dimensional, square in cross section, with four different rods engraved on each one. A set of such bones might be enclosed in a convenient carrying case.
John Napier
A rod's surface comprises 9 squares, and each square, except for the top one, comprises two halves divided by a diagonal line. The first square of each rod holds a single-digit, and the other squares hold this number's double, triple, and quadruple and so on until the last square contains nine times the number in the top square. The digits of each product are written one to each side of the diagonal; numbers less than 10 occupy the lower triangle, with a zero in the top half.
A set consists of 9 rods corresponding to digits 1 to 9. The figure additionally shows the rod 0; although for obvious reasons it is not necessary for calculations.
The rods could be arranged so that the answer to a multiplication/division problem could be found. I am not detailing the methods for multiplication/division as it is outside the scope of this book
Although Napier’s theory of logarithms had an enduring impact, the ‘Napier Bones’ were soon eclipsed by the slide rule, developed by William Oughtred, and other type of calculators – most notably a mechanical type –
An Introduction to Mainframes - 17 - A Brief History of Computing pioneered by a brilliant French man named Blaise Pascal. He used the principle of interlocking wheels, which remained central to the operation of most adding machines for next 300 years
1.3. Blaise Pascal and Pascaline
Blaise Pascal called his machine ‘Pascaline’ which was a boxed ‘wheel-and-cog’ machine. Its most serious draw back was its convoluted method of performing any calculations other than simple addition
Blaise Pascal Pascaline
1.4. Gottfried Wilhelm Leibniz and Leibniz’s calculator
The first machine that could do subtraction, multiplication, and division easily was invented by a German genius, whose imagination seemed to spawn no end to original ideas - Gottfried Wilhelm Leibniz (1646-1716). He discovered calculus independently of Newton, and his notation is the one in general use since. He also discovered the binary system, foundation of virtually all modern computer architectures
In 1671, Leibniz invented a calculating machine which was a major advance in mechanical calculating. The Leibniz calculator incorporated a new mechanical feature, the stepped drum — a cylinder bearing nine teeth of different lengths which increase in equal amounts around the drum. Although the Leibniz calculator was not developed for commercial production, the stepped drum principle survived for 300 years and was used in many later calculating systems
An Introduction to Mainframes - 18 - A Brief History of Computing
Leibniz Leibniz’s Calculator
1.5. Joseph Marie Jacquard and Punched Cards
The next great advancement had nothing to do with the numbers. Throughout the 18th century, French weavers had experimented with schemes for guiding their looms by perforated tapes, punch cards or wooden drums
In 1804, Joseph Marie Jacquard built a fully automated loom that could handle enormously complicated designs. The loom was programmed by a mountain of punched cards, each controlling a single throw of the shuttles. The Jacquard loom revolutionized the weaving industry, and in its essential features, is still used today
Jacquard’s effort is considered as the first practical use of the binary system
Joseph Marie Jacquard Jacquard Loom
An Introduction to Mainframes - 19 - A Brief History of Computing
1.6. Charles Babbage
Charles Babbage (26 December 1791 – 18 October 1871) was an English mathematician, philosopher, and mechanical engineer who originated the idea of a programmable computer
In 1822, Charles Babbage wrote a scholarly paper describing a machine that could compute and print lengthy scientific papers.
The same year he built a preliminary model of this ‘Difference engine’, made with toothed wheels on a shaft turned by a crank. For the next 10 years, Babbage wrestled with his brain-child, but the difference engine grew increasingly complex as he modified, enhanced and redesigned it
In 1833 Charles Babbage conceived an ambitious plan for a general purpose calculating machine which in many features of its design is functionally analogous to the modern computer. It was designed to contain a memory or "store," an arithmetic unit or "mill" capable of performing the four operations of arithmetic, an input/output system which used punched cards, and a printer to display the results.
The engine would have been steam-driven and programmed by the punched cards. The engine was designed in great detail on paper but it was never completed, all that exists of it are reams of plans and drawings and a small portion of the mill and printer built by Babbage’s son. The difference engine fared better. It was modified and rebuilt by the Swedish Pehr George Scheutz, winning a gold medal in the exhibition at Paris
Difference Engine Analytical Engine
An Introduction to Mainframes - 20 - A Brief History of Computing
1.7. Herman Hollerith and the Tabulating Machine
Just 19 years after the death of Babbage, one aspect of the Analytical Engine – the punched cards appeared in a functioning machine. The machine was a statistical tabulator built by the American Herman Hollerith to speed up the processing of the returns of the 1890 US census
The cards in Hollerith’s tabulator were the size of dollar bill. So swift was Hollerith’s machine that a simple count of the census was ready in six weeks, and a full statistical analysis in two and a half years, reducing the time required as compared to the previous census by one third. The Hollerith’s tabulating machine was a big success. He formed the Tabulating Machine Company to sell his invention
Herman Hollerith Tabulator
1.8. History of IBM
IBM originated as the Computing Tabulating Recording (CTR) Company, which was incorporated on June 16, 1911 in Endicott, New York, United States of America.
CTR was formed through a merger of three separate companies: Tabulating Machine Company (founded 1896 in Washington D.C.), the International Time Recording Company (founded 1900 in Endicott), and the Computing Scale Company (founded 1901 in Dayton, Ohio, USA). The key person behind the merger was financier Charles R. Flint, who brought together the founders of these companies to propose a merger and remained a member of the board of CTR until his retirement in 1930.
The president of the Tabulating Machine Company at the time of the merger was Herman Hollerith, who had founded the company and was a seminal figure in the industry. His series of patents on tabulating machine technology, first applied for in 1884, drew on his work at
An Introduction to Mainframes - 21 - A Brief History of Computing
the U.S. Census Bureau from 1879-82. Hollerith was initially trying to reduce the time and complexity needed to tabulate the 1890 Census. His transition to the use of punch cards, in 1886, laid a foundation for generations of equipment and a core component of what would become IBM. The companies that merged to form CTR manufactured a wide range of products, including employee time-keeping systems, weighing scales, automatic meat slicers, and most importantly for the development of the computer, punched card equipment. Over time CTR came to focus purely on the punched card business, and ceased its involvement in the other activities.
Thomas J. Watson Sr became General Manager of CTR in 1914 and President in 1915. In 1917, CTR entered the Canadian market under the name of International Business Machines Co., Limited and in February 14, 1924, CTR changed its name to International Business Machines Corporation. At the helm during this period, Watson played a central role in establishing what would become the IBM organization and culture.
Thomas J. Watson, Sr
1.9. Generation of Computers
The term ‘computer generation’ is often used in relation to the hardware of computers. Each phase of computer development is known as a separate generation of computers. Each phase of development is characterized by the type of switching circuits it utilizes
1.9.1. Evolution of the First Generation of Modern Computers
Around 1930, scientists began making significant progress towards devising machines for performing complex computations. Vannevar Bush’s Differential Analyzer ushered in the modern computer age. Alan Turing published his seminal paper ‘On computational Numbers’ in the year 1936
In the same year, in a landmark thesis, Claude Shannon showed the link between symbolic logic and electrical circuits paving the way for use of electricity in computation machines. It has been claimed that this was the most important master's thesis of all time. Shannon has been called ‘the father of information theory’
Claude Shannon
An Introduction to Mainframes - 22 - A Brief History of Computing
1.9.2. The First Generation
The first one of two first generation computers appeared. The Colossus, in 1943, went into service cracking top secret German codes during World War II
Colossus was designed by engineer Tommy Flowers at the Post Office Research Station, Dollis Hill with input from mathematician Max Newman and group at Bletchley Park. The prototype, Colossus Mark I, was shown working in December 1943 and was operational at Bletchley Park by February 1944. An improved Colossus Mark II was first installed in June 1944, with input from Allen Coombs, and ten Colossi had been constructed by the end of the war.
Colossus Mark II Computer
In a landmark memorandum published in 1945, Hungarian born mathematician John von Neumann, laid out in detail the five key components of what is often called the ‘von Neumann architecture’ of the modern computer. He wrote that to be both efficient and general purpose, a modern computing system, must have a central arithmetic unit (ALU), a central control unit to orchestrate operations, a memory, an input unit and an output unit. He also noted that the system should work with binary digits, operate electronically, and perform its operations one at a time
The von Neumann architecture (Stored program concept) is based on three key concepts that are 1) Data and instructions (program) are stored in a single read-write memory 2) The memory contents are addressable by locations 3) Execution takes place in a sequential fashion i.e., from one instruction to the next unless modified explicitly
An Introduction to Mainframes - 23 - A Brief History of Computing
John von Neumann John von Neumann model
The first generation computers used vacuum tubes and machine language was used for giving instructions. The first generation computers used the concept of ‘stored program’. The computers of this generation were very large in size and their programming was a difficult task. The following computers belong to the first generation
1.9.2.1. ENIAC
Based on the above principles, which are a commonplace even today, the first large scale electronic digital computer, the ENIAC (Electronic Numerical Integrator And Calculator) was unveiled by J. Presper Eckert and John Mauchly in the year 1946 at the University of Pennsylvania in USA. This computer used high speed vacuum tube switching devices. It has a very small memory and it was used for calculating the trajectories of missiles. It took 200 microseconds for addition and about 2800 microseconds for multiplication. This giant machine was 30X50 feet long, weighed 30 tons, contained 17,468 vacuum tubes, 7,200 crystal diodes, 1,500 relays 70,000 resistors, 10,000 capacitors, 6000 switches, used 150,000 watts of electricity. When ENIAC was built, it was 5000 times faster than the closest competitor MARK-1
ENIAC
An Introduction to Mainframes - 24 - A Brief History of Computing
1.9.2.2. EDVAC
The binary arithmetic was used in the construction of a computer called Electronic Discrete Variable Automatic Computer (EDVAC), completed in 1950. The von Neumann concept of stored program was also applied in EDVAC. With this, the operation became faster since the computer could rapidly access both the program and data
1.9.2.3. EDSAC
The EDSAC, short for Electronic Delay Storage Automatic Computer was built by M.V Wilkes at Cambridge University in 1949 and used mercury delayed lines for storage. It also used Neumann concept of ‘stored program’. This allowed easy implementation of program loops
1.9.2.4. UNIVAC – I
Commercial production of stored program electronic computers began in the early 50’s. One such computer was UNIVAC – I, built by Univac division of Remington Rand and delivered in 1951. This computer also used vacuum tubes
Initial applications of computers those days were in science and engineering but with the advent of UNIVAC – I, the prospect of commercial application were perceived
The first generation computers suffered from some ‘big’ limitations like slow operating speed, restricted computing capacity, high power consumption, short mean time between failures, very large space requirement and limited programming capabilities. Further researches in this line aimed at removal of these limitations
UNIVAC
An Introduction to Mainframes - 25 - A Brief History of Computing
1.9.3. The Second Generation
John Bardeen, William Shockley and Walter Brattain invented the transistor in 1947 at Bell Labs. It replaced the vacuum tubes, reducing the size and increasing the speed of the computer. In 1951, the first business computer – the LEO, was introduced
Vacuum tube and the Transistor LEO
In 1952, broadcast newsman, Walter Cronkite used a UNIVAC computer to predict a presidential election
The increased reliability and availability of large memories paved the way for the development of high level languages such as FORTRAN, COBOL, Algol and Snobol etc. With speedy CPUs and the advent of magnetic tape and disk storage, operating systems came into being. Batch operating systems ruled the second generation computers
1.9.4. The Third Generation
The Third Generation was ushered by the invention of the integrated circuit. A single integrated circuit has many transistors, resistors and capacitors along with the associated circuitry encapsulated in a small package with many leads
Jack Kilby is probably most famous for his invention of the integrated circuit, for which he received the Nobel Prize in Physics in the year 2000. After his success with the integrated circuit Kilby stayed with Texas Instruments and, among other things, he led the team that invented the hand-held calculator
An Introduction to Mainframes - 26 - A Brief History of Computing
Integrated Circuit
Robert Noyce came up with his own idea for the integrated circuit. He did it half a year later than Jack Kilby. Noyce's circuit solved several practical problems that Kilby's circuit had, mainly the problem of interconnecting all the components on the chip. This was done by adding the metal as a final layer and then removing some of it so that the wires needed to connect the components were formed. This made the integrated circuit more suitable for mass production. Besides being one of the early pioneers of the integrated circuit, Robert Noyce also was one of the co-founders of Intel. Intel is one of the largest manufacturers of integrated circuits in the world.
Jack Kilby Robert Noyce
From small scale integrated (SSI) circuits which had about 10 transistors per chip, technology developed to medium scale integrated (MSI) circuits with 100 transistors per chip. The size of main memories reached about 4 megabytes. Magnetic disk technology also improved and it became feasible to have drive having capacity up to 100MBs. The CPUs became much more powerful with the capacity of carrying out 1 million instructions per second (MIPS)
The third generation computers using integrated circuits proved to be highly reliable, relatively inexpensive and faster. Less human labor was required at assembly stage. Examples of some mainframe computers developed during this generation are IBM 360
An Introduction to Mainframes - 27 - A Brief History of Computing series, ICL -1900 series, IBM 370/168, ICL -2900, Honeywell Model 316, Honeywell -6000 series. Some mini computers developed during this phase are ICL -2903 manufactured by International Computers Limited, CDC -1700 manufactured by Control Data Corporation and PDP -11/45 (Personal Data Processor -11/45) from Digital Equipment
1.9.5. The Fourth Generation
The advent of the microprocessor chip marked the beginning of the fourth generation computers. Medium Scale Integrated (MSI) circuits yielded to Large and Very Large Scale integrated (VLSI) circuits packing about 50000 transistors in a chip. Semiconductor memories replaced magnetic core memories. The emergence of the microprocessor (CPU on a single chip) led to the emergence of extremely powerful personal computers. Computer costs came down so rapidly that these found places in most offices and homes. The faster accessing and processing speeds and increased memory capacity helped in development of much powerful operating systems
1971: Ted Hoffman designed the Intel 4004 microprocessor – a single chip with all the basic parts of a central processor – triggering a series of new developments
1974: Ed Roberts of MITS built a microcomputer called Altair
1975: Students, Bill Gates and Paul Allen created the first personal computer software – a form of BASIC for the Altair
1977: Three mass-market personal computers emerged in one year: the Apple II, Radio Shack TRS-80 and the Commodore
1981: IBM, long dominated in big computers, entered the personal computer market with the IBM PC
Original IBM PC
An Introduction to Mainframes - 28 - A Brief History of Computing
The second decade of the fourth generation observed a great increase in the speed of microprocessors and the size of main memory. The speed of microprocessors and the size of main memory and hard disk went up by a factor of 4 every 3 years. Many of the mainframe CPU features became part of the microprocessor architecture in 90s. Also RISC (Reduced Instruction Set Computers) microprocessors are preferred in powerful servers for numeric computing and file services
The computer networks came of age and are one of the most popular ways of interacting with computer chains of millions of users. The computers are being applied in various areas like simulation, visualization, parallel computing, virtual reality, multimedia etc.
At the time of writing, a Lenovo M series has the following configuration
Lenovo M series
Processor: Up to dual-core processor Memory: Up to 8GB Hard Drive: Up to 500GB
And a Lenovo Y series Home/Home office widescreen has the following configuration
Lenovo Y series
Processor: Up to Intel® Core™2 Duo Processor T5450 (1.66GHz) Memory: Up to 4GB DDR2 Hard Drive: 160GB
An Introduction to Mainframes - 29 - A Brief History of Computing
1.9.6. The Fifth Generation
The fifth generation computers are on the way! The researchers are aiming at developing a machine that can be spoken to in simple plain language and is able to converse the way we human beings do. For this the concept of Artificial Intelligence (AI) is being used (Don’t worry about the Matrix movie). The robots of science fiction will be science facts by the end of this century if these researches meet their goal. The fifth generation, it is widely believed at the time, would turn to massive numbers of CPUs for added performance.
An Introduction to Mainframes - 30 - Computer Classifications
Chapter 2
Computer Classifications
An Introduction to Mainframes - 31 - Computer Classifications
2. Computer Classifications
The computers have been classified into three categories; you can see mainframes come under the classification of ‘Size and Performance Wise’
1) Digital Computers 2) Analog Computers 3) Hybrid Computers
COMPUTERS
DIGITAL ANALOG HYBRID
Purpose Wise Size and Performance Wise
Special Purpose General Purpose Micro Mini Mainframe Super
2.1. Digital Computer
Encyclopedia Britannica defines a digital computer as any of a class of devices capable of solving problems by processing information in discrete form. It operates on data, including magnitudes, letters, and symbols, that are expressed in binary form—i.e., using only the two digits 0 and 1. By counting, comparing, and manipulating these digits or their combinations according to a set of instructions held in its memory.
Computers used for business and scientific applications are digital computers. Digital computers can be further classified in two ways
1) Purpose wise 2) Size and Performance Wise
An Introduction to Mainframes - 32 - Computer Classifications
Purpose wise digital computers are classified into two types
2.1.1. Special Purpose Computer
Special Purpose Computer is the one that is designed to perform a specific task. The instructions (programs) to carry out the task are permanently stored in the machine. For the specific tasks, this type of computer works efficiently but such computers are not versatile
2.1.2. General Purpose Computer
General Purpose Computer is the one that can work on different types of programs input to it and thus being used in countless applications. The programs are not permanently stored but are input at the time of execution. These computers are very versatile
Size and performance wise digital computers can be classified into four types
2.1.3. Microcomputer
Although there is no single definition, a microcomputer is most often taken to mean a computer with a microprocessor as its CPU. Another general characteristic of these computers is that they occupy physically small amounts of space. Although the terms are not synonymous, many microcomputers are also personal computers (in the generic sense).
This category is termed micro because the CPU was created on a single chip. These are normally single micro processor, single user systems, designed for performing basic operations like educational, training, small business applications, playing games etc. These are mainly used in offices, homes, schools, shops, stores etc.
Work stations, desktops, laptops, notebooks are examples of Micro computers
A Lenovo M series Desktop A Lenovo Y series Laptop
2.1.4. Minicomputer
Minicomputers are more powerful computers than micro computers in terms of processing power and capabilities. Minicomputers are mainly multi user systems where many users simultaneously work on the systems. Mini computers possess greater storage capacity and
An Introduction to Mainframes - 33 - Computer Classifications
larger memories as compared to micro computers. These computers are capable of handling more input - output devices
Mini computer lies in the middle range of the computing spectrum, in between the largest multi-user systems (mainframe computers) and the smallest single-user systems (microcomputers or personal computers).
Formerly this class formed a distinct group with its own hardware and operating systems. While the distinction between mainframe computers and smaller computers remains fairly clear, contemporary middle-range computers are not well differentiated from personal computers, being typically just a more powerful but still compatible version of a personal computer. More modern terms for minicomputer-type machines include midrange systems (IBM parlance), workstations (Sun Microsystems and general UNIX/Linux parlance), and servers.
The minicomputer is used when large groups need access to data simultaneously. The minicomputer can do this because the hardware is designed for plugging in more devices and the CPU and the support chips are designed for this kind of work
For example, large super markets around the world need to have their cash register send sales information to the same computer (so that the data is collected at one place)
Mini computers are used by medium sized business. They are also used in factories to control automated assembly lines, manufacturing, process control, etc,
Popular makers of minicomputer include DEC (Digital Equipment Corporation) – that built the popular VAX minicomputer. IBM also creates a very popular mini computer range with a branding of the AS/400. HP has a popular mini computer range branded HP9000
Unlike Micro computers, most mini computers provide more than one terminal so that several people can use the system at one time. A system like this is called a multi user system
We can see few examples of midrange (mini) computers
IBM System i™ 515 Express
An Introduction to Mainframes - 34 - Computer Classifications
At the time of writing, an IBM System i™ 515 Express has the following features
Software : i5/OS®, Windows Server™, Linux, AIX 5L™ Memory (Range) : Up to 16 GB Disk (Range) : Up to 560 GB Processor : POWER5+ 1.9 GHz
IBM System i™ 595
At the time of writing, an IBM System i™ 595 has the following features
Software : i5/OS, Linux®, Windows Server®, AIX 5L™ Memory (Range) : Up to 2 TB Disk (Range) : Up to 381 TB Processor performance : 31500 to 216000 CPW
Designed for large enterprises, the System i™ 595 offers multiplatform management and maximum flexibility for customers requiring up to 64–way symmetrical multiprocessing capability
CPW stands for Commercial Processing Workload - is a measure used in IBM's AS/400 and i Series line of computers to compare computer system models in terms of how efficiently each system processes a typical workload of commercial applications involving frequent database access. The CPW also represents a test of database commitment control, concurrent data access by many users, and a range of updating complexity.
2.1.5. Mainframe Computer
Today, computer manufacturers don’t always use the term mainframe to refer to mainframes. Instead, most have taken to calling any commercial-use computer—large or small—a server, with the mainframe simply being the largest type of server in use today. IBM, for example, now refers to its mainframes as zSeries servers.
A mainframe is the central data repository or hub in a corporation’s data processing center, linked to users through less powerful devices such as workstations or terminals. The presence
An Introduction to Mainframes - 35 - Computer Classifications of a mainframe often implies a centralized form of computing, rather than a distributed form of computing. Having data centralized in a single mainframe repository saves customers from having to manage updates to more than one copy of their business data. This increases the likelihood that the data is current.
This distinction, however, is rapidly blurring as smaller machines continue to gain in processing power, and mainframes become ever more flexible and multi-purpose, so a working definition can be “a mainframe is what businesses use to host the commercial databases, transaction servers, and applications that require a greater degree of security and availability than is commonly found on smaller-scale machines.”
Early mainframe systems were housed in enormous, room-filling metal boxes or frames, and this is probably how the term mainframe originated. The mainframe required large amounts of electrical power and air-conditioning, and the room was occupied mostly by I/O devices. Also, a typical installation had several mainframes installed with most of the I/O devices connected to all of the mainframes. During their largest period in terms of physical size, a typical mainframe occupied 2000-10,000 square feet, with some installations being much larger than this.
Starting around 1990, mainframe processors and most of the I/O devices became physically smaller, while their functionality and capacity continued to grow. Mainframe systems today are much smaller than earlier systems--about the size of a large refrigerator.
Clearly, the term “mainframe” has expanded beyond merely describing the physical characteristics of a system. Instead, the word typically applies to some combination of the following attributes:
• Compatibility with mainframe operating systems, applications, and data. • Centralized control of resources. • Hardware and operating systems that can share access to disk drives with other systems, with automatic locking and protection against destructive simultaneous use of disk data. • A style of operation, often involving dedicated operations staff who use detailed operations procedure books and highly organized procedures for backups, recovery, training, and disaster recovery at an alternate site. • Hardware and operating systems that routinely work with hundreds or thousands of simultaneous I/O operations.
An Introduction to Mainframes - 36 - Computer Classifications
• Clustering technologies that allow the customer to operate multiple copies of the operating system as a single system. This configuration, known as Parallel Sysplex, is analogous in concept to a UNIX cluster, but allows for systems to be added or subtracted as needed while applications continue to run. This flexibility allows mainframe customers to introduce new applications, or discontinue using existing applications, in response to changes in business activity. • Additional data and resource sharing capabilities. In a Parallel Sysplex, for example, it is possible for users across multiple systems to access the same databases concurrently, with database access controlled at the record level.
We can see few examples of mainframe computers
IBM eServer zSeries 890
The IBM eServer zSeries 890 (z890) includes zSeries functionality at a lower entry capacity level than previously available on IBM z/Architecture™ hardware, as well as new granular growth options.
It has one to 4 processors and the processor memory ranges from 8GB to 32 GB
IBM System z9 Enterprise Class
It has one to 54 n-way processors and a processor memory range of 16 GB to 512 GB
2.1.6. Super Computer
Super computers are the most powerful computers among digital computers. These consist of several processors running together thereby making them immensely faster and powerful.
An Introduction to Mainframes - 37 - Computer Classifications
The term "Super Computing" was first used by New York World newspaper in 1929 to refer to large custom-built tabulators IBM made for Columbia University.
Supercomputers introduced in the 1960s were designed primarily by Seymour Cray at Control Data Corporation (CDC), and led the market into the 1970s until Cray left to form his own company, Cray Research. He then took over the supercomputer market with his new designs, holding the top spot in supercomputing for five years (1985–1990)
The Cray-2 was the world's fastest computer from 1985 to 1989
Columbia Supercomputer / NASA Advanced Supercomputing Facility
An Introduction to Mainframes - 38 - Computer Classifications
Supercomputers are mainly used in applications like weather forecasting, nuclear science research, aerodynamic modeling, seismology etc.
Examples of super computers are CRAY X-MP/14, CDC -205, ETAGF – 10, FUJITSU VP – 400, NEC SX – 2, PARAM, ANURAG
As of November 2006, the top ten supercomputers on the Top 500 list have the same top- level architecture. Each of them is a cluster of MIMD (Multiple Instruction stream Multiple Data stream) multiprocessors, each processor of which is SIMD (Single Instruction stream Multiple Data stream). The supercomputers vary radically with respect to the number of multiprocessors per cluster, the number of processors per multiprocessor, and the number of simultaneous instructions per SIMD processor.
Within this hierarchy we have:
A computer cluster is a collection of computers that are highly interconnected via a high- speed network or switching fabric. Each computer runs under a separate instance of an Operating System (OS).
A multiprocessing computer is a computer, operating under a single OS and using more than one CPU, where the application-level software is indifferent to the number of processors. The processors share tasks using Symmetric multiprocessing (SMP) and Non- Uniform Memory Access (NUMA).
An SIMD processor executes the same instruction on more than one set of data at the same time. The processor could be a general purpose commodity processor or special-purpose vector processor. It could also be high performance processor or a low power processor.
Recently, a cluster platform at Pune’s (India) Computational Research Laboratories, a TATA subsidiary, has been ranked fourth in the widely anticipated top 500 list released at an international conference on high performance computing in Reno, Nevada and the Indian Super computer has been adjudged the fastest in Asia
Computer Site/Country Speed Maker (Teraflops) BlueGene/L Lawrence Livermore 478.2 IBM National Laboratory / US BlueGene/P Jülich Research Centre / 167.3 IBM Germany ICE 8200 New Mexico Computing 126.9 SGI Applications Center / US HP 3000 BL460c Computational Research 117.9 HP Laboratories / India HP 3000 BL460c Swedish National Defense 102.8 HP Radio Establishment / Sweden
An Introduction to Mainframes - 39 - Computer Classifications
The TATA supercomputer, named EKA after the Sanskrit term for one, is a Hewlett Packard Cluster Platform 3000 BL460c system. Computational Research Laboratories has integrated this system with its own innovative routing technology and achieved a speed of 117.9 teraflop. A teraflop is a trillion floating point operations per second
The number one position has been claimed by the BlueGene/L System, a joint development of IBM and the US department of energy’s National Nuclear Security Administration and installed at DOE’s Lawrence Livermore National Laboratory, California
IBM BlueGene/L Super Computer
2.2. Analog Computer
In analog computers, continuous quantities are used. Computations are carried out with physical quantities such as voltage, length, current, temperature etc. The devices that measure such quantities are analog devices e.g. voltmeter ammeter. Analog computers operate by measuring rather than counting. The main advantage of analog computers is that all calculations take place in parallel and hence these are faster. But their accuracy is poor as compared to digital counterparts. Analog computers are used mostly in engineering and scientific applications. An electronic weighting scale is an example of an analog computer
2.3. Hybrid Computer
Hybrid computers utilize the best qualities of both the digital and analog computers. In these computers some calculations take place in analog manner and rest of them take place in digital manner. Hybrid computers are best used in hospital where analog part is responsible for measurement of patient’s heart beat, blood pressure, temperature and other vital signs and then the operation is carried out in digital fashion to monitor patient’s vital signs. Hybrid computers are also used in weather forecasting
An Introduction to Mainframes - 40 - More about Mainframes
Chapter 3
More about Mainframes
An Introduction to Mainframes - 41 - More about Mainframes
3. More about Mainframes
We have seen a brief introduction about mainframes in the previous chapter, we will see more about it now
The mainframe owes much of its popularity and longevity to its inherent reliability and stability, a result of careful and steady technological advances since the introduction of System/360 in 1964. No other computer architecture in existence can claim as much continuous, evolutionary improvement, while maintaining compatibility with previous releases.
Because of these design strengths, the mainframe is often used by IT organizations to host the most important, mission-critical applications. These applications typically include customer order processing, financial transactions, production and inventory control, payroll, as well as many other types of work.
A common impression of a mainframe user interface is the 80x24 character “green screen” terminal, named for the old CRT-based computer terminals from years ago that glowed green. However, current mainframe interfaces can look much the same as those for personal computers or UNIX systems. When a business application is accessed through a Web browser, there is often a mainframe computer providing crucial function “behind the scenes.”
Many of today’s busiest Web sites store their production databases on a mainframe host. New mainframe hardware and software are ideal for Web transactions because they are designed to allow huge numbers of users and applications to rapidly and simultaneously access the same data without interfering with each other. This security, scalability, and reliability are critical to the efficient and secure operation of contemporary information processing.
IBM eServer zSeries 990 (1 to 32 Processors, Processor memory ranges from 16GB to 256GB)
Businesses today rely on the mainframe to:
• Perform large-scale transaction processing (thousands of transactions per second) • Support thousands of users and application programs concurrently accessing many resources • Manage terabytes of information in databases • Handle large-bandwidth communications
An Introduction to Mainframes - 42 - More about Mainframes
3.1. Factors Contributing to Mainframe use
The reasons for mainframe use are many, but most generally fall into one or more of the following categories
3.1.1. Reliability, Availability, and Serviceability
Reliability: Involves the use of high quality components. In addition, hardware components have extensive self checking and self recovery. Software reliability involves extensive testing and quick updates for detected problems
Availability: The ability to recover from a failed component without impacting the rest of the running system. This applies to hardware recovery (by automatically replacing failed elements with spares) and software recovery (through layers of error recovery provided by the operating system)
Serviceability: Allows for the replacement of elements (hardware and software) while impacting as little of the operational system as possible. It also implies well defined units of replacement, either hardware or software
Beyond Reliability, Availability, and Serviceability (known as RAS), a state of the art mainframe system might be said to provide high availability and fault tolerance. Redundant hardware components in critical paths, enhanced storage protection, a controlled maintenance process, and system software designed for unlimited availability all help to ensure a consistent, highly available environment for business applications in the event that a system component fails
3.1.2. Security
In an IT environment, data security is defined as protection against unauthorized access, transfer, modification, or destruction, whether accidental or intentional. To protect data and to maintain the resources necessary to meet the security objectives, customers typically add a sophisticated security manager product to their mainframe operating system. The customer’s security administrator often bears the overall responsibility for using the available technology to transform the company’s security policy into a usable plan
A secure computer system prevents users from accessing or changing any objects on the system, including user data, except through system provided interfaces that enforce authority rules. Mainframe computers can provide a very secure system for processing large numbers of heterogeneous applications that accesses critical data
3.1.3. Scalability
By scalability we mean the ability of the hardware, software, or a distributed system to continue to function well as it is changed in size or volume; for example, the ability to retain
An Introduction to Mainframes - 43 - More about Mainframes
performance levels when adding processors, memory, and storage. A scalable system can efficiently adapt to work, with larger or smaller networks performing tasks of varying complexity.
IBM’s latest zSeries mainframes exhibit scalability characteristics in both hardware and software, with the ability to run multiple copies of the operating system software as a single entity called a system complex of Sysplex
3.1.4. Continuing Compatibility
Some of the mainframe applications have been developed and refined over decades. Some applications were written many years ago, while others may have been written “yesterday.”
The need to support applications of varying ages imposes a strict compatibility demand on mainframe hardware and software, which have been upgraded many times since the first System/360 mainframe computer was shipped in 1964. Applications must continue to work properly. Thus, much of the design work for new hardware and system software revolves around this compatibility requirement.
Given a brief about the mainframes, let us look into the different aspects in detail
While large mainframe computers have essentially the same hardware components as all other computers, including personal computers (PCs), the terminology is totally different. The formidable-sounding “Direct Access Storage Device” (or DASD) on a mainframe becomes the more unassuming “hard disk” on a PC. Likewise, the impressive term “data set” on a mainframe turns out to be just a “file” on a PC
The computer is essentially a device that reads some data, does some computing or processing and produces information. The main computer hardware that concerns you consists of
• The CPU, or Central Processing Unit • Central Storage – also called real storage or computer memory • Input and output devices, such as disks, tapes, and printers
CPU: The central processing unit executes instructions to perform computations, initiates input/output, and directs the operation of the computer. It is the part of the computer that does the processing
Central Storage: The computer memory holds both the instructions and data during computations and is termed central storage or real storage
I/O Devices: The input/output contains external data
An Introduction to Mainframes - 44 - More about Mainframes
Input/Output Operations Interface
CPU I/O Devices
Central Storage
3.2. Typical Mainframe Workloads
Most mainframe workloads fall into either of two categories: batch processing and online transactional processing, including Web based applications
3.2.1. Batch Processing
One key advantage of a mainframe is its ability to process terabytes of data from high speed storage devices and produce valuable output. For example, mainframe systems make it possible for banks and other financial institutions to produce end-of-quarter processing when such reporting is necessary to customers
The applications that produce these statements are batch applications; they are processed on the mainframe without user interaction. A batch job is submitted on the computer, reads and process data in bulk, and produces output, such as customer billing statements
While batch processing is possible on distributed systems, it is not as commonplace as on mainframes because distributed systems often lack:
• Sufficient data storage • Available processor capacity or cycles • Sysplex-wide management of system resources and job scheduling
Mainframe operating systems are usually equipped with sophisticated job scheduling software that allows data center staff to submit, manage, and track the execution and output of batch jobs.
An Introduction to Mainframes - 45 - More about Mainframes
Batch processes have the following characteristics:
• Large amounts of input data are processed, stored records accessed, and a large volume of output is produced. • Interactive response time is usually not the primary requirement. However, batch jobs often must complete within a “batch window,” a period of less intensive online activity prescribed by a service level agreement. • Information is generated about large numbers of users. • A scheduled batch process can consist of the execution of hundreds or thousands of jobs in a pre-established sequence.
During batch processing, many types of work can be generated.
Consolidated information such as profitability of investment funds, scheduled database back- ups, processing of daily orders and updating of inventories are typical examples of batch processing
Batch Job
Input Data Application Program Output
Process data to perform a specific task
3.2.2. Online Transactional Processing
Mainframes serve a vast number of online transaction processing (OLTP) systems. These are mission critical applications that businesses depend on for their core functions. Some industry uses of online systems
Bank – ATMs, teller systems for customer service Insurance - Agent systems for policy management and claims processing Travel and Support – Airline/railway reservation systems Manufacturing – Inventory control, production scheduling Government – Tax processing, license issuance and management
An Introduction to Mainframes - 46 - More about Mainframes
In an online interactive system, a user working at a display station interacts with the computer. On a transaction by transaction basis, the user enters data and receives output back from the system
Online (real time) transaction
Application Program
Access shared data on behalf of on-line user
3.3. A peep into the history
I don’t wish to write a long history log, we will see the important milestones
3.3.1. System/360
IBM introduced System/360 on April 4 -1964. It combined micro electronic technology, which made possible operating speeds measured in billionths of a second, with significant advances in the concepts of computer organization
System/360 Model 195 Launched in 1969, the Model 195 was at the time, the most powerful computer in IBM's product line.
An Introduction to Mainframes - 47 - More about Mainframes
System/360 is a single system spanning the performance range of virtually all the then IBM computers - from the widely used 1401 to nearly twice that of the most powerful computer previously built by the company. It was developed to perform information handling jobs encompassing all types of applications.
System/360 includes in its central processors 19 combinations of graduated speed and memory capacity. Incorporated with these are more than 40 types of peripheral equipment which store information and enter it into and retrieve it from the computer. Built-in communications capability makes System/360 available to remote terminals, regardless of distance.
The equipment is supported by programs which enable System/360 to schedule its own activities for non-stop computing that makes most efficient use of system capabilities.
Internal processing power of the largest System/360 configuration is approximately 50 times greater than that of the smallest. The system's machine cycle time - basic pulse beat of a computer - ranges from one millionth-of-a-second to only 200 billionths-of-a-second.
System/360 core storage memory capacity ranges from 8,000 characters of information to more than 8,000,000. Information storage devices linked to the system can store additional billions of characters of data and make them available for processing at varying speeds, depending on need.
It is the balancing of these factors - all available within a single system using one set of programming instructions - that will make it possible for a user to select a configuration suited to his own requirements for both commercial and scientific computing. With the same type of input/output devices, a user can expand his System/360 to any point in its performance range, without reprogramming.
Some of the most significant advances represented by the new IBM System/360 include:
Solid Logic Technology - Microelectronic circuits - product of IBM's Solid Logic Technology - make up the system's basic componentry. System/360 is the first commercially available data processing system whose design is based on the use of microminiaturized computer circuits.
Called logic circuits because they carry and control the electrical impulses which represent information within a computer, these tiny devices operate at speeds ranging from 300 down to six billionths-of-a-second. Transistors and diodes mounted on the circuits are only 28 thousandths-of-an-inch square and are protected by a film of glass 60 millionths-of-an-inch thick.
Memory power - A hierarchy of memories within System/360 makes information in core storage available at varying speeds. Small local store memories operate in as little as 200 billionths-of-a-second. Control memories operate in as little as 250 billionths-of-a-second. Powerful main memories - containing up to 524,000 characters of information - range from 2.5 millionths-of-a-second down to one millionth-of-a-second.
An Introduction to Mainframes - 48 - More about Mainframes
A key development provides 8,000,000 characters in bulk core storage - each character available in eight millionths-of-a-second and each at the direct command of a computer programmer. This is over sixty times more directly addressable characters than were previously available in IBM computers. The computer's historic limitations on memory size are overcome by this development.
Application versatility - The traditional distinction between computers for commercial and scientific use is eliminated in System/360. Users will be able to process both business and scientific problems, or a combination of the two, with equal effectiveness. This versatility is reinforced by the variety of peripheral equipment which is part of the system.
Communications capability - Built into System/360 is the ability to respond to inquiries and messages from remote locations at any time. Hundreds of terminal devices can communicate simultaneously with a system while the computer continues to process the basic job on which it is working.
More than 100,000 businessmen in 165 American cities attended meetings at which System/360 was announced!
At a press conference at the company's Poughkeepsie facilities, Mr. Watson, the then IBM Board Chairman, said:
"System/360 represents a sharp departure from concepts of the past in designing and building computers. It is the product of an international effort in IBM's laboratories and plants and is the first time IBM has redesigned the basic internal architecture of its computers in a decade. The result will be more computer productivity at lower cost than ever before. This is the beginning of a new generation - not only of computers - but of their application in business, science and government."
3.3.2. System/370
In 1970, a new computer system, the IBM System/370 was announced. System/370 Models 155 and 165 could provide computer users with dramatically higher performance and information storage capacity.
Please see the figure in the next page
An Introduction to Mainframes - 49 - More about Mainframes
System/370 Model 165
The Model 165 of 1970 was designed to handle large data bases, remote computing and high throughput multiprogramming. This "white room" design model includes (from left) eight IBM 3420 Magnetic Tape Units and a single 3803 Tape Control, three 2821 Control Units (background), four 1403 N-1 Printers (foreground left center), two 2540 Card Read Punch Units (foreground right center), 3066 System Console (center background), 2821 Control Unit (right background), 2314 Direct Access Storage Facility (right middle) and IBM 2305 Fixed Head Storage (right foreground).
To help customers exploit the full throughput potential of System/370, IBM had built in many advances keyed to reliable performance, including:
• Monolithic integrated circuits, microscopic in size, that perform logical and arithmetic operations at speeds measured in nanoseconds. • Main core memories having capacities up to 2-million bytes for the Model 155 and 3- million for the Model 165. • Monolithic buffer storage that holds data and instructions ready before they are actually needed, streaming them into the central processing unit on demand at nanosecond speeds. The buffer effectively matches the data from the larger but slower main memory to the very high internal speed of the processor. • Expanded channels to carry more data faster between memory and other system units. These new channels are analogous to pipelines whose width and flow pressure have been increased. • The ability to handle up to 15 different program tasks simultaneously, including programs written for the IBM 1400 and 7000 series, as well as System/360.
An Introduction to Mainframes - 50 - More about Mainframes
This image of the Model 165 provides a close-up view of the operator's console (foreground) and the IBM 2314 Direct Access Storage facility (background)
Let’s take a deviation from the history and see few of the jargons in detail so that the reading will be smooth.
The central components of mainframe computer system are the processors.
CPU
MAIN STORAGE
Channel 0 Channel 1 Channel 5 Channel 6
An Introduction to Mainframes - 51 - More about Mainframes
The figure shows the basic arrangement of the subcomponents that make up a typical System/370 type processor. As you can see, the processor consists of 3 main parts: CPU, Main Storage and Channels.
The CPU contains the circuitry needed to execute program instructions that manipulate data stored in main storage. Although the figure doesn’t show it, most System/370 processors use a special purpose high speed memory buffer called a cache that operates between the CPU and Main Memory. This relatively small amount of storage operates at speeds even faster than the storage in main memory, so the overall speed of the processor is increased
Special circuitry constantly monitors access to main memory and keeps the most frequently accessed sections in the cache.
3.3.2.1. Multiprocessing
To understand what a multiprocessor does, let us focus on the term single processor. A single processor or uniprocessor contains its own main storage and is controlled by a single OS. A Multiprocessor, on the other hand, can share system resources and work. For example, while one of the processors initiates an I/O operation, another processor can handle an interrupt and so on.
There are two types of multiprocessing systems
• Loosely coupled multiprocessing : where processors operate under separate operating systems, yet share access to data • Tightly coupled multiprocessing : where processors operate under the same OS
3.3.2.2. Channels
The purpose of a channel is to provide a path between the processor and an I/O device. In the above figure, there are 7 channels. As a result, there are 7 different paths along which data can pass between the processor and I/O device. Each channel can connect up to 8 devices called control units that connect to I/O devices. As a result, the processor in the above figure can connect up to 56 control units. Depending on the processor and the device, a control unit may be housed within the processor’s cabinet, the I/O device’s cabinet, or in its own cabinet.
The basic channel design of the System/370 requires that I/O devices to be connected to channels using heavy copper cables that can no longer than 400 feet in length. These channels use a parallel architecture which means that the cable transmits all of the bits that make up a byte simultaneously. To do that, the cable must have a separate wire for each bit – Sixteen in all (the channel sends two bytes simultaneously) - Plus additional wires for control signals. The result is that parallel channel cable is both heavy and expensive.
In 1990, IBM announced a new channel architecture, called ESCON (Enterprise System Connection), which is based on fiber optic rather than copper table. Fiber optic cable is not only 80 times lighter than copper table, but also 50 times less bulky. ESCON will allow many
An Introduction to Mainframes - 52 - More about Mainframes data centers to replace literally tons of unmanageable copper cable with neatly organized fiber optic cable. Besides its reduced size and weight, ESCON provides two other advantages. First it extends the 400-feet cable limit of standard channels to 26 miles. This lets installations locate disk devices on another floor or even in another building. Second, ESCON channels are nearly 4 times as fast as standard channels, transmitting data at 17 MB per second rather than 4.5 MB per second
In the new S/390 systems, a new channel architecture – S/390 Fiber Connectivity (FICON) – provides a new high performance I/O channel, optimized for efficiency at high speed.
3.3.2.3. PR/SM
At one time, multiprocessor configurations were considered exotic, and the facilities for managing them were often inadequate. So many installations resorted to VM, an OS designed to emulate multiple computer systems. VM could be configured to take advantage of multiple processors, but it didn’t provide all of the controls needed to take full advantage of modern multiprocessor configurations.
To address this problem, current IBM multiprocessors include a feature called Processor Resource/Systems Manager, or PR/SM. PR/SM allows an installation to divide a multi-CPU processor into several partitions, or LPARs, each of which can function as an independent system. PR/SM can be configured so that a partition is reserved as a backup for a primary partition. If the primary partition fails, the backup partition can automatically take over the work that was being processed at the time of the failure. PR/SM also allows the I/O channels assigned to the various partitions to be reconfigured without disrupting the work
3.3.2.4. LPAR
A subset of the processor hardware that is defined to support an operating system - An LPAR (Logical Partition) contains resources (processors, memory, and input/output devices) and operates as an independent system. If hardware requirements are met, multiple logical partitions can exist within a system
3.3.2.5. I/O Devices
I/O devices are the devices that connect to a processor to provide it with input, receive output or provide secondary storage.
The common types of I/O devices found on IBM mainframes are
3.3.2.5.1. Unit Record Devices
Card Devices and Printers - The name Unit record device implies that each record processed by the device is a physical unit. URDs usually have built in control units that attach directly to channels, so separate control units are not required
An Introduction to Mainframes - 53 - More about Mainframes
o Card Devices • Card Readers • Card Punches • Reader/Punches
o Printers • Impact : produce out put by striking an image of characters to be printed against a ribbon, which in turn transfers ink to paper • Non Impact Printers: use laser technology. IBM’s 3800 printing subsystem can print at rates of up to remarkable 20,000 lines per minute
3.3.2.5.2. Magnetic Tape Devices
How much data a reel or cartridge of tape can contain depends on the length of the tape and the density used to record the data. Density is a measurement of how many bytes are recorded in one inch of tape. Tape densities for standard reel tapes are usually 1600 or 6250 bpi. Data records are normally written to tape in groups called blocks. Empty spaces called gaps are required to separate blocks from one another. The larger the block, the lesser the amount of wasted space on a tape. However there is an extra cost involved when blocking is used: a buffer is required in main storage to contain the entire block. As a result, the larger the block, the more main storage that is required to contain it
3.3.2.5.3. Direct Access Device
The official IBM term for a disk drive is DASD, because it allows direct and rapid access to large quantities of data. Data is recorded on the usable surfaces of a disk pack in concentric circles called tracks. The number of tracks per surface varies with each device type. The component that reads and writes data on the tracks of a disk pack is called the actuator. The actuator has one read/write head for each recording surface. When the actuator moves, all of its heads move together so they are all positioned at the same track of each recording surface. As a result the disk drive can access data on all of those tracks without moving the actuator. The tracks that are positioned under the heads of the actuator at one time make up a cylinder. As a result, there are as many tracks in a cylinder as there are usable surfaces on the pack, and there are as many cylinders in a pack as there are tracks on a surface. So a pack that has 19 surfaces, each with 808 tracks has 808 cylinders, each with 19 tracks.
IBM manufactures two basic types of disk drives Count-Key-Data (CKD) devices and Fixed- Block-Architecture (FBA) devices. CKD devices store data in variable-length blocks. FBA devices store data in fixed-length blocks
Each type of DASD devices requires two kinds of control units to attach it to a processor channel. The first is called a string controller, attaches a group of DASDs of the same type: the resulting group is called a string. The second kind of control unit, called a storage control, connects up to eight strings of DASD units to a channel
An Introduction to Mainframes - 54 - More about Mainframes
Special circuitry keeps track of what disk data is accessed most frequently and tries to keep this data in the cache storage. Then, when that data is referenced, it can be read directly from cache, the DASD unit doesn’t have to be accessed at all
STORAGE CONTROL
String Controller String Controller
3.3.2.6. Data Communications Equipment
An installation creates a data communications network (telecommunications network) that lets users at local terminal (terminals at the computer site) and remote terminals (terminals that are not at the computer site) access a computer system
At the center of the network is the host system, a System/370 processor. The control unit that attaches to the host system’s channels is called a communications controller; it manages the communications functions necessary to connect remote terminal system via modems and telecommunications lines.
Whether attached locally or remotely, the most commonly used terminal system on IBM mainframe is the 3270 Information Display system
See the figure in the next page
An Introduction to Mainframes - 55 - More about Mainframes
Channel Connections
Communication Controller
Modem Modem
Telecommunication Lines
Modem Modem
T 1 T 1
T 2 Terminal Terminal T 2 Controller Controller
T 3 T 3
Printer Printer Terminals Terminals
3.3.2.7. Characteristic Features of Mainframe OS
We will see in detail about the mainframe OS; I give a brief here to make the understanding easier
3.3.2.7.1. Virtual Storage
In most computer systems, the processor’s main storage is among the most valuable of the system’s resources. As a result, modern mainframe computer operating systems provide sophisticated services to make the best use of the available main storage. Among the most important of these services include virtual storage
Virtual storage is a technique that lets a processor simulate an amount of main storage that is larger than the actual amount of real storage. To do this, the computer uses disk storage as an extension of real storage
An Introduction to Mainframes - 56 - More about Mainframes
The key to understanding virtual storage is to realize that at any given moment, only the current program instruction and the data it refers need to be in real storage. Other data and instructions can be placed temporarily on disk storage, and recalled into main storage when needed. In other words, virtual storage Operating Systems transfer data and instructions between real storage and disk storage as and when they are needed.
3.3.2.7.2. Multiprogramming
Multiprogramming means that the computer lets more than one program execute at the same time. Actually, that is misleading; at any given moment, only one program can have control of the CPU. A multiprogramming system appears to execute more than one program at the same time
The key to understanding multiprogramming is to realize that some processing operations – like reading data from an input device – take much longer than others. As a result, most programs that run on mainframe computers are idle for a large percentage of the time, waiting for I/O operations to complete. If programs were run one at a time on a mainframe computer, the CPU would spend most of its time waiting. Multiprogramming simply reclaims the CPU during these idle periods and lets another program execute
3.3.2.7.3. Spooling
A significant problem that must be overcome by multiprogramming systems is sharing access to input and output devices for the programs that execute together. One way to avoid this problem is to give one of the programs complete control of the printer. Unfortunately, that defeats the purpose of multiprogramming because the other program has to wait until the printer is available
To provide shared access to printer devices, spooling (simultaneous peripheral operation online) is used. Spooling manages printer output for applications by intercepting printer output and directing it to a disk device instead. Then, when the program finishes, the operating system collects its spooled print output and directs it to the printer. In a multiprogramming environment, the OS stores the spooled output separately on disk so it can print each program’s output separately
Another benefit of spooling is that programs can execute faster. That is because; disk devices are much faster than printers. The OS component that actually prints the spooled output is multi programmed along with the application programs, so the printer is kept as busy as possible. But the application programs themselves are not slowed down by the relatively slow operation of the printer
3.3.2.7.4. Batch Processing
When you use batch processing, your work is processed in units called jobs. A job may cause one or more programs to execute in sequence. For example, one job may invoke the
An Introduction to Mainframes - 57 - More about Mainframes programs necessary to update a file of employee records, print a report listing employee information, and produce payroll checks.
One of the problems that arise when batch processing is used is managing how work flows through the system. In a typical mainframe computer system, many users compete to use the system’s resources. To manage this, the Job Entry Subsystem, or JES processes each user’s job in an orderly fashion
3.3.2.7.5. Time Sharing
In a time sharing system, each user has access to the system through a terminal device. Instead of submitting jobs that are scheduled for later execution, the user enters commands that are processed immediately. As a result, time sharing is sometimes called interactive processing, because it lets users interact directly with the computer. Sometimes, timesharing processing is also called foreground processing, while batch job processing is called background processing
An Introduction to Mainframes - 58 - More about Mainframes
3.3.2.8. A small mainframe configuration
Impact Printers (2) 3490 Tape Drives (4)
4381 Processor
3880 Storage Controller
Operator Consoles (4)
3390 –1 Disk Drives (24)
Communications Controller
Remote 3270 System
Local 3270 System
An Introduction to Mainframes - 59 - More about Mainframes
For Direct access storage, the configuration above uses three strings of 3390 model - 1 DASDs, each containing 8 drives. Since each 3390 model 1 has a capacity of 946 MB, the total DASD capacity of this system is about 22 billion bytes. 3390 are fixed-media DASDs; their disk packs can’t be removed. To provide a way to create backup copies of data on the 3390s, a string of four tape drives is used
The 4 operator consoles let system operators control the operation of the system. Some of the consoles might be dedicated to specific tasks, such as managing the tape drives or controlling the 2 high speed impact printers.
A local 3270 system, directly attached to the 4381 processor, provide 12 terminals and one printer. These terminals are used by the programming staffs, who are based in the same building that houses the computer.
The 3725 communications controller allows remote 3270 systems to access the system via telephone lines.
3.3.2.9. MVS Concepts
MVS stands for multiple virtual storage. Under MVS, the concepts of virtual storage and multiprogramming are closely related.
Virtual Storage is a facility that simulates a large amount of main storage by treating DASD storage as an extension or real storage. In other words when virtual storage is used, the processor appears to have more storage than it actually does.
Multiprogramming is a facility that lets two or more programs use the processor at the same time. The key to understanding multiprogramming is realizing that most programs spend most of their time waiting for I/O operations to complete. So while one program waits for an I/O operation, the CPU can execute instructions for another program.
3.3.2.9.1. Address Space
Main storage consists of millions of individual storage locations, each of which can store one character, or byte, of information. To refer to a particular location, you use an address that indicates the storage location’s offset from the beginning of the memory.
An Address space is simply the complete range of addresses – and as a result, the number of storage locations – that can be accessed by the computer. The maximum size of a computer’s address space is limited by the number of digits that can be used to represent an address. To illustrate, suppose a computer records its addresses using six decimal digits, such a computer could access storage with addresses from 0 to 999,999
The original System/370 processors used 24 bit binary numbers to represent addresses. Since the largest number that can be represented in 24 bits is abut 16 million (16 M), an address
An Introduction to Mainframes - 60 - More about Mainframes
space on a System/370 can’t contain more than 16M bytes of storage. Because this 16 MB address space limitation severely restricted the capabilities of the System/370, IBM replaced it in the early 1980s with a new architecture known as 370-XA. 370-XA processors can operate in 370 mode using standard 24 bit addresses or in XA, or Extended Architecture, mode using 31-bit addresses, in XA mode, the largest address that can be represented – and therefore the largest address space that can be used – is about 2G.
In the late 1980s and early 1990s, IBM extended this architecture even further with the introduction first of ESA/370, then ESA/390. These designs utilize the same 31 – bit addresses that 370-XA uses.
MVS/370 was designed to operate on System/370 processors that utilize 24-bit addresses, and MVS/XA was designed to operate on 370-XA processors that use 31 – bit addresses. MVS/ESA also uses 31-bit addresses, but runs only on ESA/370 and ESA/390 processors.
To maintain compatibility with MVS/370, MVS/XA recognizes 24-bit processing. Whether it interprets an address as 24 or 31 bit depends upon the setting of the addressing mode bit in the current PSW at the time an instruction executes. Programs running in 24-bit addressing mode can access the first 16 MB of the virtual storage. MVS allows program to switch from one mode to another during execution in order to access data or call modules running in the other mode. Thus new programs can take advantage of 31 bit addressing and still be compatible with ones written for 24 bit addresses.
All MVS programs have an addressing mode (AMODE) attribute that indicates which addressing mode is to take effect when a module is given control. The AMODE attribute is assigned to MVS program module by the programmer as input to the assembler or linkage- editor. The default is 24 bit addressing mode.
MVS modules have a residence mode (RMODE) attribute that indicates whether they must be loaded below the 16 MB address line or can be loaded anywhere in the virtual storage. If RMODE = 24, modules require residency below 16 MB. If RMODE = ANY, it allows the OS to load a module anywhere in virtual storage
A program that must be directly addressable by 24 bit callers must reside below the 16 MB line. A program that doesn’t have 24 bit callers, or whose 24 bit callers call it indirectly, can reside anywhere. The RMODE attribute is assigned as input to the assembler or the linkage- editor, or by default. The default is 24 bit residence mode.
3.3.2.9.2. Paging
To allow the parts of a program in virtual storage to move between real and auxiliary storage, MVS breaks real storage, virtual storage and auxiliary storage into blocks. The terminology the system uses is as follows
• A block of real storage is a Frame • A block of virtual storage is a Page • A block of auxiliary storage is a Slot
An Introduction to Mainframes - 61 - More about Mainframes
A page, a frame and a slot are all of the same size; each consists of 4KB. An active virtual storage page resides in a real storage frame; a virtual storage page that becomes inactive resides in an auxiliary storage slot.
MVS divides virtual storage into 4K sections called pages. Data is transferred between real and DASD storage one page at a time. As a result, real storage is divided into 4K sections called page frames, each of which can hold one page of virtual storage. Similarly, the DASD area used for virtual storage, called a page data set, is divided into 4K page slots, each of which holds one page of virtual storage.
When a program refers to a storage location that is not in real storage, a page fault occurs. When that happens, MVS locates the page that contains the needed data on DASD and transfers it into real storage. That operation is called a page-in. In some cases, the new page can overlay data in a real storage page frame. In other cases, data in a page frame has to be moved to a page data set to make room for the new page. That is called a page-out. Either way, the process of bringing a new page into real storage is called paging.
3.3.2.9.3. Expanded Storage
Most new System/370 processors include a special type of memory known as expanded storage. Expanded storage improves the efficiency of virtual storage operations by acting as a large buffer between real storage and the page data sets. Simply put, when a virtual storage page must be paged out, the processor moves the page’s contents to expanded storage. This transfer occurs at CPU speeds rather than at DASD speeds, so the operation is almost instantaneous. Pages are written to the actual page data set only when expanded storage becomes full. The amount of expanded storage on a processor varies depending on the processor model.
3.3.2.9.4. Swapping
Swapping is the process of transferring all of the most recently valid pages of an address space between real storage and auxiliary storage. This has the effect of moving an entire address space into or out of real storage. It is one of several methods MVS employs to balance the system workload as well as to ensure that an adequate supply of available real storage frames is maintained. Address spaces that are swapped in are active having pages in real storage frames and pages in auxiliary storage slots. Address spaces that are swapped out are inactive; the address space resides on auxiliary storage and can’t execute until it is swapped in. Swapping is performed in response to the recommendations from the System Resource Manager (SRM).
See the figure in the next page
An Introduction to Mainframes - 62 - More about Mainframes
Page Data Sets
Real Storage Swap Data Sets
Add: Add: Add: Add: Add: Add: S pace 1 Space 2 Space 3 (Swapp (Swapp (Swapp Space 4 Space 5 Space 6 (Swapp (Swapp (Swapp e d in) ed in) ed in) ed out) ed out) ed out)
CPU
You can think of swapping as the same thing as paging, only at a higher level. Rather than move small 4K pieces of virtual storage in an out of real storage, swapping effectively moves entire address spaces in and out of virtual storage. Since paging occurs only for address spaces that are currently in virtual storage, paging doesn’t occur for address spaces that are swapped out
3.3.2.10. The MVS system
3.3.2.10.1. System Generation
When an installation purchases the MVS operating system, IBM sends the basic components that make up the MVS on a series of tapes, called distribution libraries. System generation, only a part of the overall process of installing MVS from the distribution libraries, selects and assembles the various components an installation needs to create a working MVS system. To control system generation, often called sysgen, a systems programmer codes special macro instructions that specify how the MVS components from the distribution libraries should be put together.
Interestingly, an installation must already have a working MVS system before it can generate a new one. This is because an existing MVS system is required to execute the sysgen macro instructions. Fortunately, most installations perform sysgen to upgrade to a newer version of MVS or to make changes to their current version. So they can use their current version of MVS to execute the sysgen
An Introduction to Mainframes - 63 - More about Mainframes
For installations that do not already have an MVS system, the system installation process includes setting up a small, limited function MVS system that can execute the sysgen for the complete, full function MVS system
The macro instructions a systems programmer codes for a sysgen fall generally into two categories. The first category of macro instructions defines the system’s hardware configuration... They are needed because MVS must know about every I/O device that is attached to the system. As a result, whenever a new I/O device is installed, the system must be generated again. MVS lets you do a smaller, less time consuming type of sysgen called an iogen to change the I/O device configuration.
The second category of macro instructions in a sysgen indicates which options of the OS should be included. Like which Job Entry Subsystem, what optional access methods and so on
The output from sysgen is a series of system libraries that contain, among other things, the executable code that makes up the OS
3.3.2.10.2. System Initialization
Once an MVS OS has been generated, it can be used to control the operation of the computer system. To begin a system initialization, the system operator uses the system console to start an Initial Program Load or IPL. That causes the computer system to clear its real storage and begin the process of loading MVS into storage from the system libraries.
Sounds cool now?
If so, you might not have read the following lines or you might have already knew it
“370-XA processors can operate in 370 mode using standard 24 bit addresses or in XA, or Extended Architecture, mode using 31-bit addresses, in XA mode, the largest address that can be represented – and therefore the largest address space that can be used – is about 2G”
Still confused? Didn’t you read 31 bit?! Didn’t you think why 31 and not 32?
We have an answer for that
3.3.2.11. XA and 31 bit addressing
The IT landscape of the early 1980s was dominated by the mainframe computer, and the mainframe marketplace was dominated by IBM, though less so than it is today. In those days there were various other manufacturers selling proprietary and mostly long forgotten systems such as Burroughs and ICL. IBM's flagship was the 370 architecture line, itself a development of IBM's earlier 360 line. Some of the largest physical boxes that IBM ever produced, big 370 systems like the 3033 and 3081 mostly ran IBM's proprietary operating
An Introduction to Mainframes - 64 - More about Mainframes
system MVS/SP V1.3. The most serious limitation of this operating system, and the 370 architecture on which it ran, was that it used a 24 bit addressing scheme. Although every unit of work, known as an address space in MVS, had access to it's own virtual storage area of 16 MB (well 16 MB in theory, but after the operating system reserved areas for it's own use, in practice you were lucky to get 9 MB for your own use), this had become a severe limitation for large sites, much as the 640 KB limit in the PC operating system DOS became a limitation.
The 370 architecture always used 4 byte, or 32 bit, words to store virtual memory addresses, but only the last 3 bytes or 24 bits actually represented an address, the other 8 bits were essentially available to the programmer to do as they pleased. Many programs used these bits for passing flags, which caused problems later. The 370/XA (XA stands for eXtended Architecture, why it was never just called EA is one of those nomenclature mysteries with which IBM is riddled) altered this 24 bit scheme to use the entire word for addressing, and so 31 bit addressing was born, bringing access to a 2 GB address space. But why 31 bit and not 32 bit?
Well this is because of those flags often stored in the first 8 bits, in order to save their customers from the problems of rewriting huge volumes of 24 bit code, IBM ensured that XA could run it without modification. This was achieved by setting the top bit as the 24 or 31 bit mode bit. If the bit was set, the address took up the following 31 bits, if it was zero then the next 7 bits were ignored and only the last 24 bits represented the address.
You should feel comfortable now!
Let’s go ahead with our discussion on mainframe history
3.3.3. System/390
IBM announced System/390 on September 5, 1990.
In addition to a new, enriched family of Enterprise Systems Architecture/390 operating systems, a new connection architecture and many functional enhancements, System/390 introduced the IBM Enterprise System/9000 family of 18 new processors - including the most powerful the company has ever offered. The new ESA/390 architecture and new MVS/ESA, VM/ESA and VSE/ESA operating systems, along with new technologies, facilitate the function and computing power of System/390.
An Introduction to Mainframes - 65 - More about Mainframes
The System/390 line of servers was the IBM flagship mainframe family in the 1990s.
Among the functional highlights are:
• Enterprise System Connection (ESCON) architecture that implements high speed fiber optic channels, allows customers to locate traditional "computer room" equipment anywhere within a 9-kilometer (5.6 miles) radius, and facilitates any-to- any connectivity • System management and system availability enhancements that reduce planned and unplanned outages, allow reconfiguration of channels and input/output equipment without impacting the system, and provide functions that help customers move closer to the goal of 24 hours/7 days a week operation; • Enhanced enterprise-wide security functions, with integrated cryptography at central processor speeds, that are especially suited to high-speed, high-volume transmission of sensitive information such as financial transactions; • Very high performance supercomputing vector options for the most powerful ES/9000 models, as well as new cost-effective vector facilities on intermediate processors, making advanced scientific and technical applications affordable to many customers for the first time; • Software enhancements that speed application development, better manage distributed data, and help move applications from one system or network to another; • New client/server hardware and software products designed to simplify the management and coordination of an enterprise's local area network environment; • On-line transaction processing capabilities that can improve applications linking thousands of remote terminals and huge databases, such as those in airline reservation and banking systems, and • A unique external time reference system that connects and synchronizes separate IBM processors in a multi-system complex (sysplex) and allows customers to operate them as one system.
An Introduction to Mainframes - 66 - More about Mainframes
System/390 Parallel Enterprise Server
The S/390 Parallel Enterprise Servers were microprocessor-based mainframes designed for any business application. From traditional accounts payable to advanced video serving applications, the air-cooled CMOS processors introduced in 1994 extended the scalability of earlier S/390 parallel processors to meet the needs of a wide range of customers.
3.3.4. eServer zSeries 900
IBM unveiled the IBM eServer zSeries 900 on Oct 3, 2000, the first mainframe built from scratch with e-business as its primary function. It is built to handle the unpredictable demands of e-business, allowing thousands of servers to operate within one box. Along with the new design, IBM also introduced its new 64-bit operating system, z/OS
The z900 and z/OS were the result of a $1 billion, two-year effort to specifically address the needs of businesses in the age of e-commerce. The first in a new class of e-business servers, the system, which works hand-in-hand with z/OS - the z900's flagship operating system - is designed for high speed connectivity to the network and to storage systems, scalability in the face of unpredictable spikes in workload or traffic, and near zero downtime when clustered. The z900 will allow customers to push performance and connectivity to the outer limits without any concessions to reliability and security.
This was the comment made by Dan Colby, general manager, Enterprise Servers, IBM, while the server was introduced
"The z900 knows what you need before you do”!
An Introduction to Mainframes - 67 - More about Mainframes
eServer zSeries 900
The only server capable of dynamically shifting workloads in the server and the network according to priorities set by the customer, the z900 addressed one of the greatest e-business challenges facing companies - efficiently and robustly managing unpredictable resource requirements. Functioning like thousands of servers within the server, resources shift automatically to the applications that need them. On most servers these adjustments must be made manually or are limited to a single logical or even physical partition. In addition, the z900 has self-healing capabilities. It continuously monitors itself and can automatically detect and correct errors, allowing applications to run without interruption.
The zSeries 900 was the first IBM mainframe built from scratch with e-business as its primary function
The ability to run thousands of virtual servers within one physical box made the z900 the ideal platform for e-business-intensive operations like application service providers, Internet service providers and technology hosting companies.
The heart of the z900 is the IBM multichip module (MCM) - the densest, most advanced semiconductor and packaging technology in the world. The 5" x 5" x 1/4" module contains 35 chips mounted on 101 layers of ceramic glass connected to 4,226 I/0 pins by 1 kilometer of wire. The module uses IBM's leading-edge copper technology and contains 2.5 billion transistors. Designed and manufactured by IBM's world-class chip developers, this leading- edge technology provided significant advantages in performance, power consumption and reliability.
The z900 reached unprecedented levels in capacity and security, including:
• Greater than 2,500 MIPs (Million Instructions Per second) on 16 processors. Clustered, the z900 can handle up to 9 billion transactions/day (300 million transactions/day stand alone). • 24GB/second of 110 bandwidth. The bandwidth has been tripled to accommodate applications that require huge I/O bandwidth to process the large number of transactions and inquiries driven by the Internet.
An Introduction to Mainframes - 68 - More about Mainframes
• FICON enhancements - offers native FICON attachment to Magstar tape storage that enhances performance, distance and sharing capabilities for networked storage. It also features FICON directors for Magstar tape and the IBM Enterprise Storage Server. • Enhanced Capacity on Demand capabilities - scales effortlessly from 1-way to 16- way processor capability on the fly and without disruption. • 2,000 Secure Sockets Layer (SSL) transactions/second - the best Sun claims is 125 SSL/second. SSL transactions - those that cause the "locked" padlock icon to appear at the bottom of browsers - are crucial to e-business transactions, enabling companies to securely process orders on-line. The ability to process greater numbers of SSL transactions means businesses can serve more customers and make more sales in less time. • New HiperSocket technology - provides high speed TCP/IP connectivity between virtual servers within a single z900, creating a network in a box.
3.3.5. eServer zSeries 990
On May 13, 2003, IBM introduced eServer zSeries 990, the new flagship of the eServer family, built on the breakthrough technology of the eServer z900, which rewrote the rules for enterprise-class computing with fortress-like security, rock-solid reliability, and extreme performance in Linux virtualization and automation
The new z990 was the result of a four-year, more than $1 billion investment in the zSeries platform involving 1,200 IBM developers
The z990 sets a new standard for enterprise-class computing and will feature industry leadership in:
• Virtualization - the z990 architecture can support hundreds or even thousands of virtual Linux servers in a single box. That roughly equates to an entire data center on one server the size of a refrigerator. • Automation - the z990 features IBM's exclusive Intelligent Resource Director (IRD) technology, which dynamically moves system resources to the workloads that need them, according to priorities and objectives set by the customer. • Scalability - a single z990 offers massive capacity and the ability to scale up and out. It can scale up to process 450 million e-business transactions/day or scale out to manage hundreds of virtual Linux servers. A clustered z990 can handle up to 13 billion transactions/day, exceeding the average weekly volume on the New York Stock Exchange. The z990 also offers the ability to turn capacity on and off, allowing customers to temporarily add server engines during peak periods. • Security - designed from the ground up to help thwart intrusion into the system, the IBM mainframe is one of the most secure servers on the market. A 16-way z990 can securely process up to 11,000 transactions/second. • Reliability -- mainframe reliability is measured in decades, not weeks or days, and the hardware availability rate for a clustered zSeries is up to 99.999%, or less than five minutes of downtime per year.
An Introduction to Mainframes - 69 - More about Mainframes
The z990 is the most powerful and scalable IBM mainframe in the 40-year history of the product, with twice the virtualization capabilities and the ability to do nearly three times the work of the z900, a new "building block" design that allows customers to plug in new capacity without taking the system down, and a dramatically simplified product structure that reduces the number of mainframe models from 42 to 4.
eServer zSeries 990
The z990 will provide new levels of scalability, security and connectivity:
• For the first time, with On/Off Capacity on Demand, mainframe customers can power up available additional engines on demand, when they need them, and turn them off when they don't, offering the ultimate flexibility to help respond to daily or seasonal surges in demand. • The z990 features up to 9,000 MIPS (million instructions per second) on 32 processors - twice the number of processors and almost three times the system capacity of the z900 - and allows customers the ability to scale up from 1- to 32-way, without taking the system down. • Up to 30 logical partitions (LPARs) are supported on the z990, providing twice the LPAR capability of the z900. Running the latest version of z/VM, release 4.4, customers can quickly create and effectively manage hundreds of virtual Linux servers within one physical box. IBM's advanced virtualization technologies make the z990 an ideal consolidation platform for customers seeking to reduce the cost and management expense of server farms. • Topping its own security record, the new 16-way z990 can handle up to 11,000 Secure Sockets Layer (SSL) transactions/second (a 57% improvement over a 16-way z900). SSL handshakes -- those that cause the "locked" padlock icon to appear at the bottom of browsers -- are crucial to e-business transactions, enabling companies to more securely process orders on-line. The ability to process greater numbers of SSL transactions helps businesses serve more customers and make more sales in less time. • For customers seeking additional connectivity for new e-business workloads on the mainframe, the new z990 provides up to 512 I/O channels, double the number of its
An Introduction to Mainframes - 70 - More about Mainframes
predecessor. In addition, there are now up to 16 HiperSockets, which provide high speed TCP/IP connectivity between virtual servers within a single z990, quadruple the number in the z900. IBM has also introduced a new technology called logical channel subsystems, which can make it easier for customers to consolidate multiple mainframes into a larger z990. • The z990 has available up to four times the memory of the z900, 256GB versus 64GB.
An Introduction to Mainframes - 71 - z/Architecture and z/OS
Chapter 4
z/Architecture and z/OS
An Introduction to Mainframes - 72 - z/Architecture and z/OS
4. z/Architecture and z/OS
4.1. Logical Structure of a z/Architecture system with 2 CPUs
ETR
CPU
Expanded
Storage Main
Storage
CPU
Crypto
Channel Subsystem
Logically, a system consists of main storage, one or more central processing units (CPUs), operator facilities, a channel subsystem, and I/O devices. I/O devices are attached to the channel subsystem through control units. The connection between the channel subsystem and a control unit is called a channel path
4.1.1. Main Storage
Main storage, which is directly addressable, provides for high speed processing of data by the CPUs and the channel subsystem. Both the data and programs must be loaded into main storage from input devices before they can be processed. The amount of main storage available in the system depends on the model, and, depending on the model, the amount in the configuration may be under control of model-dependent configuration controls. The storage is available in multiples of 4K byte blocks. At any instant, the channel subsystem and
An Introduction to Mainframes - 73 - z/Architecture and z/OS
all the CPUs in the configuration have access to the same blocks of storage and refer to a particular block of main storage locations by using the same absolute address
Main storage may include a faster access buffer storage, sometimes called a cache. Each CPU may have an associated cache.
4.1.2. Expanded Storage
Expanded storage may be available on some models. Expanded storage, when available, can be accessed by all CPUs in the configuration by means of instructions that transfer 4K byte blocks of data from expanded storage to main storage or from main storage to expanded storage. These instruction are called PAGE IN and PAGE OUT instructions
I don’t detail about these instructions… that is beyond the scope of this book
Each 4K byte block of expanded storage is addressed by means of a 32 bit unsigned binary integer called an expanded-storage block number
4.1.3. CPU
The Central Processing Unit (CPU) is the controlling center of the system. It contains the sequencing and processing facilities for instruction execution, interruption action, timing functions, initial program loading, and other machine related functions
The CPU, in executing instructions, can process binary integers and floating point numbers (binary and hexadecimal) of fixed length, decimal integers of variable length, and logical information of either fixed or variable length. Processing may be in parallel or in series
Instructions which the CPU executes fall into seven classes: general, decimal, floating-point- support (FPS), binary-floating-point (BFP), hexadecimal-floating-point (HFP), control, and I/O instructions. The general instructions are used in performing binary-integer-arithmetic operations and logical, branching, and other non-arithmetic operations. The decimal instructions operate on data in the decimal format. The BFP and HFP instructions operate on data in the BFP and HFP formats, respectively, while the FPS instructions operate on floating-point data independent of the format or convert it from one format to the other. The privileged control instructions and the I/O instructions can be executed only when the CPU is in the supervisor state; the semi privileged control instructions can be executed in the problem state, subject to the appropriate authorization mechanisms.
The CPU provides registers which are available to programs but do not have addressable representations in main storage. They include
4.1.3.1. PSW
The program-status word (PSW) includes the instruction address, condition code, and other information used to control instruction sequencing and to determine the state of the CPU. The
An Introduction to Mainframes - 74 - z/Architecture and z/OS
active or controlling PSW is called the current PSW. It governs the program currently being executed. The CPU has an interruption capability, which permits the CPU to switch rapidly to another program in response to exceptional conditions and external stimuli. When an interruption occurs, the CPU places the current PSW in an assigned storage location, called the old-PSW location, for the particular class of interruption. The CPU fetches a new PSW from a second assigned storage location. This new PSW determines the next program to be executed. When it has finished processing the interruption, the program handling the interruption may reload the old PSW, making it again the current PSW, so that the interrupted program can continue
4.1.3.2. General Registers
Instructions may designate information in one or more of 16 general registers. The general registers may be used as base-address registers and index registers in address arithmetic and as accumulators in general arithmetic and logical operations. Each register contains 64 bit positions
For some operations, either bits 32-63 or bits 0-63 of two adjacent general registers are coupled, providing a 64-bit or 128-bit format, respectively. In these operations, the program must designate an even-numbered register, which contains the leftmost (high-order) 32 or 64 bits. The next higher-numbered register contains the rightmost (low-order) 32 or 64 bits.
4.1.3.3. Floating Point Registers
All floating-point instructions (FPS, BFP, and HFP) use the same floating-point registers. The CPU has 16 floating-point registers. Each floating-point register is 64 bits long and can contain either a short (32-bit) or a long (64-bit) floating-point operand; pairs of floating-point registers can be used for extended (128-bit) operands. Each of the eight pairs is referred to by the number of the lower-numbered register of the pair.
4.1.3.4. Floating Point Control Register
Floating Point Control (FPC) register is a 32 bit register that contains mask bits, flag bits, a data exception code, and rounding-mode bits
4.1.3.5. Control Registers
The CPU has 16 control registers, each having 64 bit positions. The bit positions in the registers are assigned to particular facilities in the system, such as program-event recording, and are used either to specify that an operation can take place or to furnish special information required by the facility
4.1.3.6. Access Registers
The CPU has 16 access registers numbered 0-15. An access register consists of 32 bit positions containing an indirect specification of an address-space-control element. An
An Introduction to Mainframes - 75 - z/Architecture and z/OS address-space-control element is a parameter used by the dynamic address translation (DAT, we will see this later) mechanism to translate references to a corresponding address space.
4.1.4. Cryptographic Facility
Depending on the model, an integrated cryptographic facility may be provided as an extension of the CPU. When the cryptographic facility is provided on a CPU, it functions as an integral part of that CPU.
The integrated cryptographic facility provides a number of instructions to protect data privacy, to support message authentication and personal identification, and to facilitate key management. The high-performance cipher capability of the facility is designed for financial transaction and bulk-encryption environments, and it complies with the Data Encryption Standard (DES).
4.1.5. External Time Reference
Depending on the model an External Time Reference (ETR) may be connected to the configuration. The ETR facility provides a means to initiate and maintain the synchronization of TOD (Time of Day) clocks to an external time reference
4.1.6. I/O
Input/output (I/O) operations involve the transfer of information between main storage and an I/O device. I/O devices and their control units attach to the channel subsystem, which controls this data transfer.
4.1.7. Channel Subsystem
The channel subsystem directs the flow of information between I/O devices and main storage. It relieves CPUs of the task of communicating directly with I/O devices and permits data processing to proceed concurrently with I/O processing.
A channel path employs either a parallel-transmission protocol or a serial-transmission protocol and, accordingly, is called either a parallel or a serial channel path. A serial channel path may connect to a control unit through a dynamic switch that is capable of providing different internal connections between the ports of the switch.
The channel subsystem uses one or more channel paths as the communication link in managing the flow of information to or from I/O devices. As part of I/O processing, the channel subsystem also performs the path-management function of testing for channel-path availability, selecting an available channel path, and initiating execution of the operation with the I/O device
An Introduction to Mainframes - 76 - z/Architecture and z/OS
One subchannel is provided for and dedicated to each I/O device accessible to the channel subsystem. Each subchannel contains storage for information concerning the associated I/O device and its attachment to the channel subsystem. The subchannel also provides storage for information concerning I/O operations and other functions involving the associated I/O device. Information contained in the subchannel can be accessed by CPUs using I/O instructions as well as by the channel subsystem and serves as the means of communication between any CPU and the channel subsystem concerning the associated I/O device. The actual number of subchannels provided depends on the model and the configuration.
4.1.8. Channel Paths
I/O devices are attached through control units to the channel subsystem via channel paths. Control units may be attached to the channel subsystem via more than one channel path, and an I/O device may be attached to more than one control unit. In all, an individual I/O device may be accessible to a channel subsystem by as many as eight different channel paths, depending on the model and the configuration.
4.1.9. I/O Devices and Control Units
I/O devices include such equipment as printers, magnetic-tape units, direct-access-storage devices, displays, keyboards, communications controllers, teleprocessing devices, and sensor based equipment. Many I/O devices function with an external medium, such as paper or magnetic tape. Other I/O devices handle only electrical signals, such as those found in displays and communications networks. In all cases, I/O-device operation is regulated by a control unit that provides the logical and buffering capabilities necessary to operate the associated I/O device. From the programming point of view, most control-unit functions merge with I/O-device functions. The control-unit function may be housed with the I/O device or in the CPU, or a separate control unit may be used.
4.1.10. Operator Facilities
The operator facilities provide the functions necessary for operator control of the machine. Associated with the operator facilities may be an operator-console device, which may also be used as an I/O device for communicating with the program.
The main functions provided by the operator facilities include resetting, clearing, initial program loading, start, stop, alter, and display.
4.2. Operating System
In simplest terms, an operating system is a collection of programs that manage the internal workings of a computer system. Operating systems are designed to make the best use of the computer’s various resources, and ensure that the maximum amount of work is processed as efficiently as possible. Although an operating system cannot increase the speed of a
An Introduction to Mainframes - 77 - z/Architecture and z/OS computer, it can maximize its use, thereby making the computer seem faster by allowing it to do more work in a given period of time.
4.3. z/OS
In most early operating systems, requests for work entered the system one at a time. The operating system processed each request or job as a unit, and did not start the next job until the one ahead of it had completed. This arrangement worked well when a job could execute continuously from start to completion. But often a job had to wait for information to be read in from, or written out to a device such as a tape drive or a printer. Input and output (I/O) take a long time compared to the electronic speed of the processor. When a job waited for I/O, the processor was idle.
Finding a way to keep the processor working while a job waited would increase the total amount of work the processor could do without requiring additional hardware. z/OS gets work done by dividing it into pieces and giving portions of the job to various system components and subsystems that function interdependently. At any point in time, one component or another gets control of the processor, and makes its contribution, and then passes control along to a user program or another component
4.3.1. Hardware resources used by z/OS
The z/OS operating system executes in a processor and resides in processor storage during execution. z/OS is commonly referred to as the system software.
Mainframe hardware consists of processors and a multitude of peripheral devices such as disk drives (called direct access storage devices or DASD), magnetic tape drives, and various types of user consoles. Tape and DASD are used for system functions and by user programs executed by z/OS.
The figure shows a simplified view of mainframe concepts
An Introduction to Mainframes - 78 - z/Architecture and z/OS
• Software - The z/OS operating system consists of load modules or executable code. During the install process, the system programmer copies these load modules to load libraries residing on DASD volumes. • Hardware - The system hardware consists of all the devices, controllers, and processors that constitute a mainframe environment • Peripheral devices - These include tape drives, DASD devices, and consoles etc. • Processor Storage - Often called real or central storage (or memory), this is where the z/OS operating system executes. Also, all user programs share the use of processor storage with the operating system. z/OS is made up of programming instructions that control the operation of the computer system. These instructions ensure that the computer hardware is being used efficiently and allow application programs to run. z/OS includes sets of instructions that, for example, accept work, convert work to a form that the computer can recognize, keep track of work, allocate resources for work, execute work, monitor work, and handle output.
4.3.2. Multiprogramming and Multiprocessing z/OS is capable of multiprogramming, or executing many programs concurrently, on behalf of many users at once. In multiprogramming, when a job cannot use the processor, the system can suspend, or interrupt, the job, freeing the processor to work on another job z/OS makes multiprogramming possible by capturing and saving all the relevant information about the interrupted program before allowing another program to execute. When the interrupted program is ready to begin executing again, it can resume execution just where it left off. Multiprogramming allows z/OS to run hundreds of programs simultaneously for users who might be working on different projects at different physical locations around the world. z/OS can also perform multiprocessing, which is the simultaneous operation of two or more processors that share the various hardware resources, such as memory and external disk storage devices.
Many users running many separate programs means that, along with large amounts of complex hardware, z/OS users need large amounts of memory to ensure suitable system performance
4.3.3. Control Blocks
As instructions execute the work of a computer system, they keep track of this work in storage areas known as control blocks. Generally speaking, there are three types of z/OS control blocks: • System-related control blocks • Resource-related control blocks • Task-related control blocks
An Introduction to Mainframes - 79 - z/Architecture and z/OS
Each system-related control block represents one z/OS system and contains system-wide information, such as how many processors are in use. Each resource-related control block represents one resource, such as a processor or storage device. Each task-related control block represents one unit of work.
4.3.4. Physical Storage used by z/OS
Conceptually, mainframes and all other computers have two types of physical storage.
• The physical storage located with the mainframe processor itself. This is called processor storage or real storage; think of it as memory for the mainframe.
• The physical storage external to the mainframe, including storage on direct access devices, such as disk drives and tape drives. This storage is called auxiliary storage.
The primary difference between the two kinds of storage relates to the way in which it is accessed, as follows:
• Real storage is accessed synchronously with the processor. That is, the processor must wait while data is retrieved from real storage.
• Auxiliary storage is accessed asynchronously. The processor accesses auxiliary storage through an input/output (I/O) request, which is scheduled to run amid other work requests in the system. During an I/O request, the processor is free to execute other, unrelated work.
As with memory for a personal computer, mainframe real storage is tightly integrated with the processor itself. In contrast, mainframe auxiliary storage is located on (comparatively) slower external disk and tape drives. Because real storage is more closely integrated with the processor, it takes the processor much less time to access data from real storage than from auxiliary storage. However, the processor is free to do other work while waiting for an I/O request to be satisfied. Auxiliary storage is less expensive than real storage, so it provides the capability for many jobs to be running while keeping real storage costs down.
4.3.5. More about storage
Main storage provides the system with directly addressable fast-access storage of data. Both data and programs must be loaded into main storage (from input devices) before they can be processed. Main storage may include one or more smaller faster-access buffer storages, sometimes called caches. A cache is usually physically associated with a CPU or an I/O processor. The effects, except on performance, of the physical construction and use of distinct storage media are not observable by the program.
Main storage may be volatile or nonvolatile. If it is volatile, the contents of main storage are not preserved when power is turned off. If it is nonvolatile, turning power off and then back
An Introduction to Mainframes - 80 - z/Architecture and z/OS on does not affect the contents of main storage, provided all CPUs are in the stopped state and no references are made to main storage when power is being turned off.
4.3.5.1. Storage Addressing
Storage is viewed as a long horizontal string of bits. For most operations, accesses to storage proceed in a left-to-right sequence. The string of bits is subdivided into units of eight bits. An eight-bit unit is called a byte, which is the basic building block of all information formats. Each byte location in storage is identified by a unique nonnegative integer, which is the address of that byte location or, simply, the byte address. Adjacent byte locations have consecutive addresses, starting with 0 on the left and proceeding in a left-to-right sequence. Addresses are unsigned binary integers and are 24, 31, or 64 bits
4.3.5.2. Information Formats
Information is transmitted between storage and a CPU or the channel subsystem one byte, or a group of bytes, at a time. Unless otherwise specified, a group of bytes in storage is addressed by the leftmost byte of the group. The number of bytes in the group is either implied or explicitly specified by the operation to be performed. When used in a CPU operation, a group of bytes is called a field.
Within each group of bytes, bits are numbered in a left-to-right sequence. The leftmost bits are sometimes referred to as the “high-order” bits and the rightmost bits as the “low-order” bits. Bit numbers are not storage addresses, however, only bytes can be addressed. To operate on individual bits of a byte in storage, it is necessary to access the entire byte. The bits in a byte are numbered 0 through 7, from left to right.
4.3.5.3. Integral Boundaries
Certain units of information must be on an integral boundary in storage. A boundary is called integral for a unit of information when its storage address is a multiple of the length of the unit in bytes. Special names are given to fields of 2, 4, 8, and 16 bytes on an integral boundary. A halfword is a group of two consecutive bytes on a two-byte boundary and is the basic building block of instructions. A word is a group of four consecutive bytes on a four- byte boundary. A doubleword is a group of eight consecutive bytes on an eight-byte boundary. A quadword is a group of 16 consecutive bytes on a 16-byte boundary
Integral boundary says, an 8-byte field must have an address exactly divisible by 8, a 4-byte field's address must be divisible by 4, and so on
Instructions must be on two-byte integral boundaries, and CCWs (Channel Command Words), IDAWs (Indirect Address Words), and the storage operands of certain instructions must be on other integral boundaries. The storage operands of most instructions do not have boundary-alignment requirements.
An Introduction to Mainframes - 81 - z/Architecture and z/OS
4.3.5.4. Address Types
For purposes of addressing main storage, three basic types of addresses are recognized: absolute, real, and virtual.
4.3.5.4.1. Absolute Address
An absolute address is the address assigned to a main-storage location. An absolute address is used for a storage access without any transformations performed on it.
The channel subsystem and all CPUs in the configuration refer to a shared main-storage location by using the same absolute address. Available main storage is usually assigned contiguous absolute addresses starting at 0, and the addresses are always assigned in complete 4K-byte blocks on integral boundaries.
4.3.5.4.2. Real Address
A real address identifies a location in real storage. When a real address is used for an access to main storage, it is converted, by means of prefixing, to an absolute address. At any instant there is one real-address to absolute-address mapping for each CPU in the configuration. When a real address is used by a CPU to access main storage, it is converted to an absolute address by prefixing. The particular transformation is defined by the value in the prefix register for the CPU.
4.3.5.4.3. Prefixing
Prefixing provides the ability to assign the range of real addresses 0-8191 (8KB) to a different block in absolute storage for each CPU, thus permitting more than one CPU sharing main storage to operate concurrently with a minimum of interference, especially in the processing of interruptions.
Prefixing causes real addresses in the range 0-8191 to correspond one-for-one to the block of 8K-byte absolute addresses (the prefix area) identified by the value in bit positions 0-50 of the prefix register for the CPU, and the block of real addresses identified by that value in the prefix register to correspond one-for-one to absolute addresses 0-8191. The remaining real addresses are the same as the corresponding absolute addresses. This transformation allows each CPU to access all of main storage, including the first 8K bytes and the locations designated by the prefix registers of other CPUs.
4.3.5.4.4. Virtual Address
A virtual address identifies a location in virtual storage. When a virtual address is used for an access to main storage, it is translated by means of dynamic address translation to a real address, which is then further converted by prefixing to an absolute address.
An Introduction to Mainframes - 82 - z/Architecture and z/OS
We have few more different jargons here, Cache Memory, Virtual Memory, Prefixing…, let’s see what they really mean
4.3.5.5. Cache Memory
This is a small fast memory placed between the CPU and the main memory.
CPU Cache Main Memory
A memory cache, sometimes called a cache store or RAM cache, is a portion of memory made of high-speed static RAM (SRAM) instead of the slower and cheaper dynamic RAM (DRAM) used for main memory. Memory caching is effective because most programs access the same data or instructions over and over. By keeping as much of this information as possible in SRAM, the computer avoids accessing the slower DRAM. Thus making the execution of the programs faster
4.3.5.6. Virtual Memory
Imagine your PC has only 64MB of main memory. If you load the operating system, an e- mail program, a Web browser and word processor into RAM simultaneously, 64 megabytes is not enough to hold it all. If there were no such thing as virtual memory, then once you filled up the available RAM, your computer would have to say, "Sorry, you can not load any more applications. Please close another application to load a new one."
With virtual memory, what the computer can do is look at RAM for areas that have not been used recently and copy them onto the hard disk. This frees up space in RAM to load the new application.
Virtual Memory breaks a program into a number of fixed length portions called pages, or into variable length portions called segments. Each of these is very small. Only the relevant portion is loaded into the main memory, whereas the remaining other program pages are stored on a peripheral disk
CPU Cache Main Virtual Disk Storage Memory Memory
An Introduction to Mainframes - 83 - z/Architecture and z/OS
This permits the loading of portions of two or more programs at the same time on the RAM. This is the reason why computers can run two or more programs at the same time. The computer could be playing music for the user while the user is busy using an accounting software on the same computer
On your PC (Windows XP Machine), you can setup virtual memory size by selecting Control Panel/System Properties/Performance Options
An Introduction to Mainframes - 84 - z/Architecture and z/OS
4.3.5.7. Virtual Memory and z/OS
In z/OS, each user has access to virtual storage, rather than physical storage. This use of virtual storage is central to the unique ability of z/OS to interact with large numbers of users concurrently, while processing the largest workloads. To make virtual storage possible, z/OS requires sufficient amounts of real storage and many billions of bytes of auxiliary storage. z/OS uses a system of tables and special settings (bit settings) to relate the location of data on disk storage and real storage, and keep track of the identity and authority of each user or program. z/OS uses a variety of storage manager components to manage virtual storage.
4.3.5.7.1. What does it really mean?
Virtual storage means that each running program can assume it has access to all of the storage defined by the architecture’s addressing scheme. The only limit is the number of bits in a storage address. This ability to use a large number of storage locations is important because a program may be long and complex, and both the program’s code and the data it requires must be in real storage for the processor to access them. z/OS supports 64-bit long addresses, which allows a program to address up to 16 Exa (1 Exa is 260) of storage locations.
In reality, mainframe might have much less real storage installed. How much less depends on the model of computer and the system configuration.
To allow each user to act as though this much storage really exists in the computer system, z/OS keeps only the active portions of each program in real storage. z/OS keeps the rest of the code and data in files called paging data sets on auxiliary storage, which usually consists of a number of high-speed direct access storage devices (DASDs).
Virtual storage, then, is this combination of real and auxiliary storage
4.3.5.8. Address Space
The range of virtual addresses that the operating system assigns to a user (or separately running program) is called an address space. This is the area of contiguous virtual addresses available for executing instructions and storing data. The range of virtual addresses in an address space starts at zero and can extend to the highest address permitted by the operating system architecture.
z/OS provides each user with a unique address space and maintains the distinction between the programs and data belonging to each address space. Within each address space the user can start multiple tasks, using task control blocks or TCBs that allow user multiprogramming.
When a virtual address is used by a CPU to access main storage, it is first converted, by means of dynamic address translation (DAT), to a real address, and then, by means of prefixing, to an absolute address.
An Introduction to Mainframes - 85 - z/Architecture and z/OS
Address spaces provide isolation of private areas in different address spaces (and this provides much of the operating system’s security), yet each address space also contains a common area that is accessible to every other address space.
Because it maps all of the available addresses, an address space includes system code and data as well as user code and data. Thus, not all of the mapped addresses are available for user code and data.
The ability of many users to share the same resources implies the need to protect users from one another and to protect the operating system itself. Along with such methods as “keys” for protecting real storage and code words for protecting data files and programs, separate address spaces ensure that users’ programs and data do not overlap.
An active z/OS system uses many address spaces. There is at least one address space for each job in progress and one address space for each logged-on user. There are many address spaces for operating system functions, such as operator communication, automation, networking, security, and so on.
4.3.5.9. Virtual Storage Operation - Overview
Recall that for the processor to execute a program instruction, both the instruction and the data it references must be in real storage. The convention of early operating systems was to have the entire program reside in real storage when its instructions were executing. However, the entire program does not really need to be in real storage when an instruction executes. Instead, by bringing pieces of the program into real storage only when the processor is ready to execute them—moving them out to auxiliary storage when it doesn’t need them, an operating system can execute more and larger programs concurrently.
Let’s see how the system makes it happen
Physical storage is divided into areas, each the same size and accessible by a unique address. In real storage, these areas are called frames; in auxiliary storage, they are called slots
Similarly, the operating system can divide a program into pieces the size of frames or slots and assign each piece a unique address. This arrangement allows the operating system to keep track of these pieces. In z/OS, the program pieces are called pages
The addresses of pages are called virtual addresses. From the time a program enters the system until it completes, the virtual address of the page remains the same, regardless of whether the page is in real storage or auxiliary storage. Each page consists of individual locations called bytes, each of which has a unique virtual address
4.3.5.9.1. Paging
z/OS maintains tables to determine whether a page is in real or auxiliary storage. To find a page of a program, z/OS checks the table for the virtual address of the page, rather than searching through all of physical storage for it. z/OS then transfers the page into real storage
An Introduction to Mainframes - 86 - z/Architecture and z/OS
or out to auxiliary storage as needed. This movement of pages between auxiliary storage slots and real storage frames is called paging. Paging is key to understanding the use of virtual storage in z/OS.
z/OS paging is transparent to the user. During job execution, only those pieces of the application that are required are brought in, or paged in, to real storage. The pages remain in real storage until no longer needed, or another page is required by the same application or a higher priority application, and no empty real storage is available.
To select pages for paging out to auxiliary storage, z/OS follows a “Least Frequently Used” algorithm. That is, z/OS assumes that a page that has not been used for some time will not be used in the near future.
4.3.5.9.2. Virtual Storage Address
Each user or program gets an address space, and each address space contains the same range of storage addresses. Only those portions of the address space that are needed at any one point in time are actually loaded into real storage. z/OS keeps the inactive pieces of address spaces in auxiliary storage
z/OS manages address spaces in units of various sizes, as follows:
Page: Address spaces are divided into 4-kilobyte units of virtual storage called pages
Segment: Address spaces are divided into 1-megabyte units called segments. A segment is a block of sequential virtual addresses spanning megabytes, beginning at a 1-megabyte boundary. A 2-gigabyte address space, for example, consists of 2048 segments.
Region: Address spaces are divided into 2-8 gigabyte units called regions. A region is a block of sequential virtual addresses spanning 2-8 gigabytes, beginning at a 2-gigabytes boundary. A 2-terabyte address space, for example, consists of 2048 regions.
A virtual address, accordingly, is divided into four principal fields. Bits 0-32 are called the region index (RX), bits 33-43 are called the segment index (SX), bits 44-51 are called the page index (PX), and bits 52-63 are called the byte index (BX).
A virtual address has the following format:
RX SX PX BX
0 33 44 52 63
An Introduction to Mainframes - 87 - z/Architecture and z/OS
As determined by its address-space-control element, a virtual address space can be a 2G-byte space consisting of one region, or it may be up to a 16-exabyte space consisting of up to 8G regions. The RX part of a virtual address applying to a 2G-byte address space must be all zeros; otherwise, an exception is recognized.
The RX part of a virtual address is itself divided into three fields. Bits 0-10 are called the region first index (RFX), bits 11-21 are called the region second index (RSX), and bits 22-32 are called the region third index (RTX).
Bits 0-32 of the virtual address have the following format:
RFX RSX RTX
0 11 22 33
A virtual address in which the RTX is the left most significant part (a 42-bit address) is capable of addressing 4T bytes (2K regions), one in which the RSX is the left most significant part (a 53-bit address) is capable of addressing 8P bytes (4M regions), and one in which the RFX is the lifetimes significant part (a 64-bit address) is capable of addressing 16E bytes (8G regions).
4.3.5.9.3. Dynamic Address Translation
Dynamic address translation, or DAT, is the process of translating a virtual address during a storage reference into the corresponding real address.
If the virtual address is already in central storage, the DAT process may be accelerated through the use of a translation look-aside buffer. If the virtual address is not in central storage, a page fault interrupt occurs, and z/OS is notified and brings the page in from auxiliary storage.
Looking at this process more closely reveals that the machine can present any one of a number of different types of faults. A type, region, segment, or page fault will be presented depending on at which point in the DAT structure invalid entries are found. The faults repeat down the DAT structure until ultimately a page fault is presented and the virtual page is brought into central storage either for the first time (there is no copy on auxiliary storage) or by bringing the page in from auxiliary storage.
DAT is implemented by both hardware and software through the use of page tables, segment tables, region tables and translation look-aside buffers. DAT allows different address spaces to share the same program or other data that is for read only. This is because virtual addresses in different address spaces can be made to translate to the same frame of central storage.
An Introduction to Mainframes - 88 - z/Architecture and z/OS
Otherwise, there would have to be many copies of the program or data, one for each address space.
Generally, in most processors, a direct mapping scheme is supported by the system hardware, in which a page map is maintained in physical memory. This means that each physical memory reference requires both an access to the page table and an operand fetch. In effect, all memory references are indirect
Virtual page Number Offset
Page Map
Physical Page Number Offset Absolute Address
Base Address of Page In Physical Memory
Virtual address translation hardware without translation look-aside buffer
This requirement would be a considerable performance penalty, so most systems which support virtual addressing have a small associative memory (called a translation look-aside buffer, or TLB) which contains the last few virtual addresses and their corresponding physical addresses, so in most cases the virtual to physical mapping does not require an additional memory access
An Introduction to Mainframes - 89 - z/Architecture and z/OS
Virtual page Number Offset
Page hit In TLB
TLB
Page miss in TLB
Page Map
Physical Page Number Offset Absolute Address
Base Address of Page In Physical Memory
Virtual address translation hardware with translation look-aside buffer
4.3.5.9.4. Frames, Pages, and Slots
When a program is selected for execution, the system brings it into virtual storage, divides it into pages of 4 kilobytes (4K), transfers the pages into real storage for execution, and transfers pages that are not needed out to auxiliary storage.
To the programmer, the entire program appears to occupy contiguous space in real storage at all times. Actually, not all pages of a program are necessarily in real storage, and the pages that are in real storage do not necessarily occupy contiguous space.
The pieces of a program executing in virtual storage must be moved between real and auxiliary storage. To allow this, z/OS manages storage in units, or blocks, of 4 kilobytes.
The following blocks are defined:
An Introduction to Mainframes - 90 - z/Architecture and z/OS
• A block of real storage is a frame. • A block of virtual storage is a page. • A block of auxiliary storage is a slot.
A page, a frame, and a slot are all the same size: 4096 bytes (4 kilobytes). An active virtual storage page resides in a real storage frame. A virtual storage page that becomes inactive resides in an auxiliary storage slot (in a paging data set).
Frames, Pages and Slots
4.3.5.9.5. Page Stealing z/OS tries to keep an adequate supply of available real storage frames on hand. When a program refers to a page that is not in real storage, z/OS uses a real storage page frame from a supply of available frames.
When this supply becomes low, z/OS uses page stealing to replenish it, that is, it takes a frame assigned to an active user and makes it available for other work. The decision to steal a particular page is based on the activity history of each page currently residing in a real storage frame. Pages that have not been accessed for a relatively long time are good candidates for page stealing
4.3.5.9.6. Swapping
Swapping is the process of transferring all of the most recently valid pages of an address space between real storage and auxiliary storage. This has the effect of moving an entire
An Introduction to Mainframes - 91 - z/Architecture and z/OS address space into, or out of, real storage. It is one of several methods that z/OS uses to balance the system workload and ensure that an adequate supply of available real storage frames is maintained.
A swapped-in address space is active; having pages in real storage frames and pages in auxiliary storage slots. A swapped-out address space is inactive; the address space resides on auxiliary storage and cannot execute until it is swapped in. Swapping is performed in response to recommendations from the z/OS Workload Manager (WLM) component.
4.3.6. Brief History of 64 bit addressability
In 1970, IBM introduced System/370, the first of its architectures to use virtual storage and address spaces. Since that time, the operating system has changed in many ways. One key area of growth and change is addressability.
System/370 defined storage addresses as 24 bits in length, which meant that the highest accessible address was 16,777,216 bytes (or 224 bytes). The use of 24-bit addressability allowed MVS/370, the operating system at that time, to allot to each user an address space of 16 MB.
Over the years, as MVS/370 gained more functions and was asked to handle more complex applications, even access to 16 MB of virtual storage fell short of user needs. With the release of the System/370-XA architecture in 1983, IBM extended the addressability of the architecture to 31 bits. With 31-bit addressing, the operating system (now called MVS Extended Architecture or MVS/XA™) increased the addressability of virtual storage from 16 MB to 2 gigabytes (2 GB). In other words, MVS/XA provided an address space for users that was 128 times larger than the address space provided by MVS/370. The 16 MB address became the dividing point between the two architectures and is commonly called the line
2GB
The ‘Bar’
31 bit Addressing (MVS/XA)
16MB
24 bit The ‘Line’ Addressing (MVS)
An Introduction to Mainframes - 92 - z/Architecture and z/OS
The new architecture did not require customers to change existing application programs. To maintain compatibility for existing programs, MVS/XA remained compatible for programs originally designed to run with 24-bit addressing on MVS/370, while allowing application developers to write new programs to exploit the 31-bit technology. To preserve compatibility between the different addressing schemes, MVS/XA did not use the high-order bit of the address (Bit 32) for addressing. Instead, MVS/XA reserved this bit to indicate how many bits would be used to resolve an address: 31-bit addressing (Bit 32 on) or 24-bit addressing (Bit 32 off).
With the release of zSeries mainframes in 2000, IBM further extended the addressability of the architecture to 64 bits. With 64-bit addressing, the potential size of a z/OS address space expands to a size so vast that we need new terms to describe it. Each address space, called a 64-bit address space, is 16 exabytes (EB – 16 260) in size
16 EB
64 bit Addressing (z/OS)
2GB
The ‘Bar’
31 bit Addressing (MVS/XA)
16MB
24 bit The ‘Line’ Addressing (MVS)
An Introduction to Mainframes - 93 - z/Architecture and z/OS
We say that the potential size is 16 exabytes because z/OS, by default, continues to create address spaces with a size of 2 GB. The address space exceeds this limit only if a program running in it allocates virtual storage above the 2 GB address. If so, the z/OS operating system increases the storage available to the user from 2 GB to 16 EB.
Programs running on z/OS and zSeries mainframes can run with 24-, 31-, or 64-bit addressing (and can switch among these if needed). Programs can use a mixture of instructions with 64-bit operands or 32-bit operands or other operands.
An Introduction to Mainframes - 94 - Leftover
Chapter 5
Leftover
An Introduction to Mainframes - 95 - Leftover
5. Leftover
5.1. Job roles in the mainframe world
It would be better to present the job roles in the mainframe world as it is entirely different from the normal scenarios
Mainframe systems are designed to be used by large numbers of people. Most of those who interact with mainframes are end users – the people who use the applications hosted on the system. However, because of the large number of end users, applications running on the system, and the sophistication and complexity of the system software that supports the users and applications, a variety of roles are needed to support and operate the system.
5.1.1. System Programmer
In a mainframe IT organization, the system programmer (or systems programmer) plays a central role. The system programmer installs, customizes, and maintains the operating system, and also installs or upgrades products that run on the system. The system programmer might be presented with the latest version of the operating system to upgrade the existing systems. Or, the installation might be as simple as upgrading a single program, such as a sort.
In any case, the system programmer must perform tasks like the following:
• Planning software and hardware system upgrades and changes in configuration • Training system operators and application programmers • Automating operations • Capacity planning • Running installation jobs and scripts • Performing installation-specific customization tasks • Integration-testing the new products with existing applications and user procedures • System-wide performance tuning to meet required levels of service
The system programmer must be skilled at debugging problems with system software. These problems are often manifested by software system images, sometimes known as dumps that have been produced by the software products or in user jobs or transactions
System programmers are needed to install and maintain the middleware on the mainframe, such as database management systems, online transaction processing systems, Web servers, and so forth. Middleware is a software “layer” between the operating system and the end user or end-user application. It supplies major functions not provided by the operating system. Major Middleware products such as DB2, CICS, and IMS™ can be as complex, if not more so, than the operating system itself.
An Introduction to Mainframes - 96 - Leftover
There are a wide variety of system configuration options to be maintained, in addition to the daily monitoring and debugging of the system. And, on the database side, the database administrator (DBA) is also present to ensure the integrity and smooth operation of the data that is stored in the database management systems. These roles are not necessarily unique to the mainframe environment, but they are key to its smooth operation nonetheless.
5.1.2. System Administrator
The distinction between “system programmer” and “system administrator” varies widely among mainframe sites. In many smaller IT organizations, where one person might be called upon to perform several roles, the terms may be used interchangeably.
In larger IT organizations with multiple departments, the job responsibilities tend to be more clearly separated. System administrators perform more of the day-to-day tasks related to maintaining the critical business data that resides on the mainframe, while the system programmer focuses on maintaining the system itself. One reason for the separation of duties is to comply with auditing procedures, which often require that no one person in the IT organization be allowed to have unlimited access to sensitive data or resources. Examples of system administrators include database administrators and security administrators.
While system programmer expertise lies mainly in the mainframe hardware and software areas, system administrators are more likely to have experience with the applications. They often interface directly with the application programmers and end users to ensure that the administration aspects of the applications are met.
In larger IT organizations, the system administrator maintains the system software environment for business purposes, including the day-to-day maintenance of systems to keep them running smoothly.
Other examples of common system administrator tasks can include:
• Installing software • Adding and deleting users and maintaining user profiles • Maintaining security resource access lists • Managing storage devices and printers • Managing networks and connectivity • Monitoring system performance
In matters of problem determination, the system administrator generally relies on the software vendor support center personnel to diagnose problems, read dumps, and identify corrections for cases in which these tasks aren’t performed by the system programmer
5.1.3. Application Designers and Programmers
The application designer and application programmer (or developer) design, build, test, and deliver mainframe applications for the company’s end users and customers. Based on requirements gathered from business analysts and end users, the designer creates a design
An Introduction to Mainframes - 97 - Leftover
specification from which the programmer constructs an application. The process includes many iterations of code changes and compiles, application builds, and unit testing
During the application development process, the designer and programmer must interact with other roles in the enterprise. For example, the programmer often works on a team of other programmers who are building code for related application program modules. When completed, each module is passed through a testing process that can include function, integration, and system-wide tests. Following the tests, the application programs must be acceptance tested by the user community to determine whether the code actually satisfies the original user requirement.
Besides creating new application code, the programmer is responsible for maintaining and enhancing the company’s existing mainframe applications. In fact, this is frequently the primary job for many application programmers on the mainframe today. While many mainframe installations still create new programs with COBOL or PL/I, languages such as Java™ have become popular for building new applications on the mainframe, just as on distributed platforms.
5.1.4. System Operator
The system operator monitors and controls the operation of the mainframe hardware and software. The operator starts and stops system tasks, monitors the system consoles for unusual conditions, and works with the system programming and production control staff to ensure the health and normal operation of the systems.
The operator is also responsible for starting and stopping the major subsystems, such as transaction processing systems, database systems, and the operating system itself.
In case of a failure or an unusual situation, the operator communicates with system programmers, who assist the operator in determining the proper course of action, and with the production control analyst, who works with the operator to ensure that production workloads are completing properly.
5.1.5. Production Control Analyst
The production control analyst is responsible for ensuring that batch workloads run to completion--without error or delay. Many mainframe installations run interactive workloads for online users, followed by batch updates that run after the prime shift when the online systems are not running.
5.2. Program Products for z/OS
A z/OS system usually contains additional program products (priced products) that are needed to create a practical working system, such as a security manager product and a database manager product.
An Introduction to Mainframes - 98 - Leftover
Some common choices include:
A security system
z/OS provides a framework for customers to add security through the addition of a security management product (IBM’s program product is Resource Access Control Facility or RACF®). Non-IBM security system program products are also available.
Compilers
z/OS includes an assembler and a C compiler. Other compilers, such as the COBOL compiler, are offered as separate products.
A relational database, such as DB2
Other types of database products, such as hierarchical databases, are also available.
Transaction processing facilities
IBM offers several, including:
– Customer Information Control System (CICS) – Information Management System (IMS) – WebSphere Application Server (WAS)
A sort program
Fast, efficient sorting of large amounts of data is highly desirable in batch processing. IBM and other vendors offer sophisticated sorting products.
A large variety of utility programs
For example, the System Display and Search Facility (SDSF)
A large number of other products are available from various independent software vendors (commonly called ISVs in the industry).
An Introduction to Mainframes - 99 -
PART - 2
An Introduction to Mainframes - 100 - COBL – Tips and Tricks
Chapter 1
COBOL – Tips and Tricks
An Introduction to Mainframes - 101 - COBL – Tips and Tricks
1. COBOL – Tips and Tricks
1.1. Tips and Tricks!
I still remember the day the Tips and Tricks took its birth. I could say I started sending Tips and Tricks few months after I started my IT career.
The beginning was like this. We had a confusion regarding the internal representation of numbers inside mainframe. We did a bit of research and came up with a write – up and shared it with the team. The response was quite surprising. It fuelled my wish to send it continuously. I think so far I had sent more than 75 such documents. A consolidation of all the Tips and Tricks were published already. This is the updated version of that. I hope it would help you in your daily work.
Let there be Light!
1.2. BLOCK Structure in Files (COBOL) – General Perspective
While handling a tape or disk file, normally a single record is not read or written. Instead, the usual practice is to group a number of consecutive records to form what is known as a block or physical record.
For example, block can consist of 10 records. This means that the first 10 consecutive records will form the first block of the file, the next 10 records will form the next block of the file, and so on. The number of records in a block is often called the ‘blocking factor’
The actual handling of the blocks is transparent to the programmer. The Input Output Control System (IOCS) takes care of blocking. The programmer should only specify the number of records that should be contained in a block. When a file is blocked, a physical read or write operation on the file is only applicable to the entire block and not to the individual records in the block. However, the programmer would like to read or write only one record at a time. This requirement of the programmer is fulfilled by the IOCS in the following manner. The IOCS reserves a memory space equal to the size of a block of the file. This memory space s is known as the buffer.
When the programmer wants to read the first record from the file, the IOCS reads the first block into the buffer but releases only the first record to the program. The next time the programmer wants to read a record, IOCS releases the second record from the buffer. In this way only when all the records in the block has been released to the program and the programmer wants to read the next record, the IOCS reads another block. In this respect the function of the IOCS in the case of writing on a file is just the reverse of reading.
However, it is important to note that every read or write statement doesn’t require the physical reading or writing of the file. Thus the read/write statements in the program are
An Introduction to Mainframes - 102 - COBL – Tips and Tricks
logical operations; the physical reading or writing is done by the IOCS at the block level. The records as defined in the program are sometimes called logical records and the blocks which are records as stored on the file medium are called physical records.
The advantage of blocking is two fold.
• Firstly, blocking results in saving in terms of input – output time required to handle a file. • The other advantage of blocking is that a substantial amount of storage space on the tap of disk can be saved.
We know that in the case of tape files, an inter-record gap is generated between any two consecutive records. The total space occupied by these inter record gaps is quite substantial. Blocking helps to get the number of such gaps reduced thereby decreasing the wastage of storage spaces o n account of these gaps
We specify blocking in
FD file name
BLOCK CONTAINS
Magnetic tape of disk files can contain variable length records. In this case the file can have records with different fixed lengths or one or more records can contain variable number of table elements. In the latter case, the table elements are defined with the occurs … depending on clause
Each record in a file with variable length records carries a data item that contains the length of the record. The COBOL features for variable length records are only limited to the file description and record description entries in the file section.
BLOCK CONTAINS INTEGER-1 TO INTEGER-2 RECORDS/CHARACTERS RECORD CONTAINS INTEGER-3 TO INTEGER-4 CHARACTERS
The above forms for the BLOCK CONTAINS and RECORD CONTAINS clauses are quite sufficient to indicate that the said file is a file with variable length records. However, these clauses being optional in some computers, a non standard clause is also required. The clause is as follows
RECORDING MODE IS F/V
Where, V indicates variable length records while F indicates fixed length records.
JCL:
Declaration for a fixed block data set, having LRECL = 80
An Introduction to Mainframes - 103 - COBL – Tips and Tricks
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
For a variable block file, you have to take 4 more bytes into consideration while specifying LRECL in JCL (this 4 bytes is used for marking the length of the record)
// DCB=(RECFM=VB,LRECL=84,BLKSIZE=840,DSORG=PS)
1.3. REDEFINES Clause
Sometimes, it may be found that two or more storage areas defined in the DATA DIVISION are not in use simultaneously. In such cases only one storage area can serve the purpose of two or more areas if the area is redefined. The REDEFINES clause allows the same area to be referred to by more than one data name with different sizes and pictures.
For example,
01 SALES-RECORD. 05 SALES-TYPE PIC X(01). 05 SALES-BY-UNIT. 10 QTY PIC 9(04). 10 UNIT-PRICE PIC 9(08)V99. 05 TOTAL-SALES REDEFINES SALES-BY-UNIT. 10 AMOUNT PIC 9(10)V99. 10 FILLER PIC X(02).
This example describes a sales record which may either contain the total amount of sales (TOTAL-SALES) or the QTY & UNIT-PRICE
The purpose of such description may be to have two types of records and their types may be determined from the data item named SALES-TYPE
Depending on some predetermined values of SALES-TYPE the record will be interpreted in one of the two forms.
Note that SALES-BY-UNIT & TOTAL-SALES refer to the same storage space. They really represent two different mappings of this same storage area
Advantage:
Conservation of Storage space
Syntax:
Level-number data-name-1 REDEFINES data-name-2
An Introduction to Mainframes - 104 - COBL – Tips and Tricks
Rules
1) The level-number of data-name-1 and data-name-2 must be identical.
2) Except when the REDEFINES clause is used to 01 level, data-name-1 and data- name-2 must be of same size
3) When the 01 level is used, the size of data-name-1 must not exceed that of data- name-2
4) Multiple redefinitions are allowed. The entries giving the new descriptions must immediately follow the REDEFINES entry.
5) In the case of multiple redefinitions, the data-name-2 must be the data name of the entry that originally defined the area.
6) The REDEFINES clause must immediately follow the data-name-1
7) Entries giving new descriptions can't have the value clauses (except in the case of condition-names(88))
8) The REDEFINES clause must not be used for records (01 level) described in the FILE SECTION. The appearance of multiple 01 entry in the record description is implicitly assumed to be the redefinition of the first 01 level record.
9) This clause must not be used for level-number 66 or 88
(COBOL 77 Standard)
According to COBOL - 85, a redefined data item can be equal or smaller in size than that of the data item it redefines.
Note that in COBOL - 74, the two must be equal.
For example
05 DATA-A PIC X(12) 05 DATA-B REDEFINES DATA-A. 10 FIELD-A PIC 9(03)V99. 10 FIELD-B PIC 9(02).
1.4. RENAMES Clause
Sometimes a re-grouping of elementary data items in a record may be necessary so that they can belong to the original as well as to the new group.
An Introduction to Mainframes - 105 - COBL – Tips and Tricks
01 PAY-REC. 05 FIXED-PAY. 10 BASIC-PAY PIC 9(6)V99. 10 DEARNESS-ALLOWANCE PIC 9(6)V99. 05 ADDITIONAL-PAY. 10 HOUSE-RENT PIC 9(4)V99. 10 MNTHLY-INCENTIVE PIC 9(3)V99. 05 DEDUCTIONS. 10 PF-DEDUCT PIC 9(3)V99. 10 IT-DEDUCT PIC 9(4)V99. 10 OTHER-DEDUCT PIC 9(3)V99. 66 PAY-OTHER-THAN-BASIC RENAMES DEARNESS-ALLOWANCE THRU MNTHLY-INCENTIVE 66 IT-AND-PF-DEDUCTIONS RENAMES PF-DEDUCT THRU IT-DEDUCT.
In the above example, PAY-OTHER-THAN-BASIC will become a new group consisting of DEARNESS-ALLOWANCE, HOUSE-RENT and MNTHLY-INCENTIVE. Note that the new group overlaps on two original groups, namely, part of FIXED-PAY and the entire ADDITIONAL-PAY. Such overlapping is allowed provided the elementary items are all contiguous. In a similar way IT-AND-PF-DEDUCTIONS has two elementary items PF- DEDUCT and IT-DEDUCT. This new group is formed out of the original group DEDUCTIONS. Alternatively, the same thing can also be done in the original group description by placing like this
. . .
05 DEDUCTIONS. 10 IT-AND-PF-DEDUCTIONS. 15 PF-DEDUCT PIC 9(3)V99. 15 IT-DEDUCT PIC 9(4)V99. 10 OTHER-DEDUCT PIC 9(3)V99.
Syntax
66 data-name-1 RENAMES data-name-2 THRU data-name-3
Rules
1) All RENAMES entries must be written only after the last record description entry 2) The RENAMES clause must be used only with the special level number 66 3) Data-name-2 and data-name-3 can be the names of elementary items or group items. They however can’t be items of levels 01,66,77 or 88 4) Neither data-name-2 nor data-name-3 can have an OCCURS clause in its description entry, nor can they be subordinate to an item that has an occurs clause in its data description entry
An Introduction to Mainframes - 106 - COBL – Tips and Tricks
5) Data-name-3, if mentioned, must follow data-name-2, in the record and must not be one of its sub fields.
1.5. USAGE Clause
Normally, a computer can store data in more than one internal form. In COBOL, a programmer is allowed to specify the internal form of the data item so as to facilitate the use of the data item more efficiently. Broadly, there are only two general forms of internal representation – computational and display. Only numeric data items can be displayed as computational, and as the name suggests, an item specified as computational can take part in arithmetic operations more efficiently. On the other hand, any data item can be specified as display. This form is suitable for input/output and character manipulations. Whether a data item is computational or display, it can be specified with a usage clause in addition to the PIC clause
1.5.1. USAGE IS DISPLAY
This is the most common form of internal data. Each character of the data is represented in one byte and a data item is stored in a couple of contiguous bytes. The number of bytes required is equal to the size of the data item. One can specify the usage as DISPLAY. However, it is also the default.
1.5.2. USAGE IS COMPUTATIONAL / COMP / BINARY
This usage stores data in the form in which the computer actually does its computation. Usually this form is binary. Thus defining WORKING-STORAGE SECTION entries in binary format is desirable when many repetitive arithmetic computations must be performed. The item must be an integer (no assumed decimal point is allowed).
COBOL 85 permits the USAGE IS BINARY clause as well to specifically represent data in binary form
A few notes to remember: while allocating the space, for COMP fields, the compiler will allocate space in multiples of word, that is, it can be half word (2 bytes), full word or word (4 bytes), double word (8 bytes) like that
So if the PIC specified is 9(1) COMP, 9(2) COMP, 9(3) COMP OR 9(4) COMP, the space allocated by the compiler will be half word (2 bytes). This allocation depends on the length of the maximum number that you can represent with this specification.
That is if you specify 9(4), the max number that you can represent is 9999. This number can be easily represented by 2 bytes. With 2 bytes you can represent up to 65535
An Introduction to Mainframes - 107 - COBL – Tips and Tricks
If you specify 9(5) COMP, 9(6) COMP, 9(7) COMP OR 9(8) COMP, the space allocated by the compiler will be one word (4 bytes). That is with 9(8), you can represent a maximum of 99999999, this is possible with a word, and a word can represent up to 4294967295
If you specify a PIC more than 9(8), it will allocate a double word (8 bytes).
Points to keep in mind while you declare an item as COMP
1) Don’t use COMP if the data item is
a) Properly DISPLAY b) Nonnumeric or edited c) A field associated with a unit record device or terminal (this means, you can’t accept from user, an item that is declared as COMP)
2) Use COMP if the data item is a
a) A numeric field in a record input from a tape or disk file whether it was already COMP b) Numeric, is used in calculations, and is a field in a record to be output to a tape or disk file from which it will later be input and used in further computation c) In WORKING-STORAGE, and is numeric and not edited and used in calculations
1.5.3. USAGE IS COMP-1
If the usage of a numeric data item is specified as COMP-1, it will be represented in one word (4 bytes) in the floating point form (single precision floating point form). Such representation is suitable for arithmetic operations. The number is actually represented in hexadecimal. The PIC clause can’t be specified for COMP-1 items
1.5.4. USAGE IS COMP-2
This usage is the same as COMP-1 except that the data is represented internally in two words (8 bytes). The advantage is that this increases the precision of the data (double precision) which means that more significant digits can be available for the item. The PIC clause can’t be specified for COMP-2 items
1.5.5. USAGE IS COMP-3
COMP-3 enables the computer to store two digits in each storage position, except for the rightmost position, which holds the sign. The sign is stored separately as the rightmost half-a- byte regardless of whether S is specified in the PIC or not.
An Introduction to Mainframes - 108 - COBL – Tips and Tricks
The hexadecimal number C or F denotes a positive sign and the hexadecimal number D denotes a negative sign.
Suppose if you move 1234567 into a field defined 9(7). In DISPLAY mode, which is default, this field will use 7 storage positions. If you define the field with PIC 9(7) COMP-3, it will however use only four positions
12 34 56 7+
We can save a significant amount of storage by using the USAGE-COMP-3
1.6. Different forms of EVALUATE Statement
Evaluate is like a case statement and can be used to replace nested Ifs. The difference between EVALUATE and case is that no ‘break’ is required for EVALUATE i.e. control comes out of the EVALUATE as soon as one match is made.
Different forms of EVALUATE statements are
a)
EVALUATE WHEN A=B AND C=D Imperative stmt WHEN (D+X)/Y = Imperative stmt WHEN OTHER Imperative stmt END-EVALUATE
b)
EVALUATE SQLCODE ALSO FILE-STATUS WHEN 100 ALSO ‘00’ Imperative stmt WHEN -305 ALSO ‘32’ Imperative stmt WHEN OTHER Imperative stmt END-EVALUATE
c)
EVALUATE SQLCODE ALSO A=B WHEN 100 ALSO TRUE Imperative stmt WHEN -305 ALSO FALSE Imperative stmt END-EVALUATE
An Introduction to Mainframes - 109 - COBL – Tips and Tricks
d)
EVALUATE SQLCODE ALSO TRUE WHEN 100 ALSO A=B Imperative stmt WHEN -305 ALSO (A/C=4) Imperative stmt END-EVALUATE
During the execution of an EVALUATE statement, the values denoted by the list of subjects (items in the EVALUATE statement) are compared with the values denoted by the list of objects in a WHEN phrase to establish a “match” between the two.
• The value of a subject is compared with the value/range of values of the object in the corresponding ordinal position • In the case of a single valued (numeric/non numeric) object, the subject – object comparison is done in the usual way • When a range of values is specified for the object, the subject – object comparison results in TRUE, if the value of the subject falls within the range • In the case of conditional values, the subject – object comparison results in TRUE, if both evaluate to the same value (that is if both are TRUE or both are FALSE). • If ANY is specified for an object, the subject-object comparison always results in TRUE • The list of subjects is said to “match” with the list of object, if all the corresponding subject – object comparisons result in true • Note that the values of the subjects need not be of the same class. For example one can be numeric and the other can be alpha numeric
After the execution of one of the when clauses, the control is automatically passed on to the next sentence after the EVALUATE statement. There is no need of any extra code.
1.7. Do you know?
1.7.1. Performance Considerations for Indexes VS Subscripts
• Using COMP to address a table is 30% slower than using indexes! • Using COMP-3 to address a table is 300% slower than using indexes!! • Using DISPLAY data item to address a table is 450% slower than using indexes!!!
1.7.2. Rule of the Thumb for SEARCH and SEARCH ALL
• For a table with less than 50 entries, go for SEARCH (Sequential Search) • For a table with more than 50 entries go for SEARCH ALL (Binary Search)
An Introduction to Mainframes - 110 - COBL – Tips and Tricks
1.7.3. Packed Decimal
Using an odd number of digits for PACKED DECIMAL (COMP-3) is 5% to 20% faster than using an even number of digits!
1.8. Meaning of Device Name in SELECT Clause
SELECT INFILE ASSIGN TO UT-S-INFILE
OR
SELECT INFILE ASSIGN TO DA-S-INFILE
What they mean actually is
First Part in DDNAME: Device Class
UT stands for utility (Tape or sequential disk) DA stands for direct access (Disk)
Second Part in DDNAMAE: Method of Organization
S – Sequential (Printer, Terminal, Disk or Tape) I, R, D – Disk files to be accessed randomly
1.9. NEXT SENTENCE and CONTINUE
There is a big difference between NEXT SENTENCE & CONTINUE. Please refer the test program given below
WORKING-STORAGE SECTION. 01 SAMPLE PIC X(2) VALUE 'AB'. 01 SAMPLE2 PIC X(2) VALUE 'CD'. PROCEDURE DIVISION. PARA1. PERFORM PARA2. STOP RUN. PARA2. IF SAMPLE = 'AB' NEXT SENTENCE ELSE DISPLAY 'SAMPLE IS NOT AB' END-IF IF SAMPLE2 = 'CD' DISPLAY 'SAMPLE 2 IS CD' ELSE NEXT SENTENCE END-IF .
An Introduction to Mainframes - 111 - COBL – Tips and Tricks
In this case, we may assume that ‘SAMPLE 2 IS CD’ will get displayed but since SAMPLE is ‘AB’, NEXT SENTENCE will get executed and this will transfer control to the statement following the period so the program will move to STOP RUN. END-IF won’t act here as a statement terminator. SYSOUT will be empty in this case. It doesn’t matter whether NEXT SENTENCE is nested inside an IF statement. SYSOUT will be empty in the following program also.
WORKING-STORAGE SECTION. 01 SAMPLE PIC X(2) VALUE 'AB'. 01 SAMPLE2 PIC X(2) VALUE 'CD'. 01 SAMPLE3 PIC X(2) VALUE 'EF'. PROCEDURE DIVISION. PARA1. PERFORM PARA2. STOP RUN. PARA2. IF SAMPLE = 'AB' IF SAMPLE3 = 'EF' NEXT SENTENCE END-IF ELSE DISPLAY 'SAMPLE IS NOT AB' END-IF IF SAMPLE2 = 'CD' DISPLAY 'SAMPLE 2 IS CD' ELSE NEXT SENTENCE END-IF .
CONTINUE will transfer control to the end of the statement that contains ‘CONTINUE’ (remember, end of the statement may not be a period). So, for the following program 'SAMPLE 2 IS CD' will be printed in SYSOUT
WORKING-STORAGE SECTION. 01 SAMPLE PIC X(2) VALUE 'AB'. 01 SAMPLE2 PIC X(2) VALUE 'CD'. PROCEDURE DIVISION. PARA1. PERFORM PARA2. STOP RUN. PARA2. IF SAMPLE = 'AB' CONTINUE ELSE DISPLAY 'SAMPLE IS NOT AB' END-IF IF SAMPLE2 = 'CD' DISPLAY 'SAMPLE 2 IS CD' ELSE CONTINUE END-IF .
An Introduction to Mainframes - 112 - COBL – Tips and Tricks
1.10. S0C7 Abend
S0C7 abend occurs when an invalid character is present in COMP/COMP-3 /numeric field and you tried to manipulate that field by some arithmetic expressions.
Let us look into the internal details.
The representation scheme that we use is EBCDIC. This is an 8 byte extension to the ASCII representation. The following is the EBCDIC representation.
Dec Hex ASCII EBCDIC 0 00 NUL Null NUL Null 1 01 SOH Start of Heading (CC) SOH Start of Heading 2 02 STX Start of Text (CC) STX Start of Text 3 03 ETX End of Text (CC) ETX End of Text 4 04 EOT End of Transmission (CC) PF Punch Off 5 05 ENQ Enquiry (CC) HT Horizontal Tab 6 06 ACK Acknowledge (CC) LC Lower Case 7 07 BEL Bell DEL Delete 8 08 BS Backspace (FE) 9 09 HT Horizontal Tabulation (FE) 10 0A LF Line Feed (FE) SMM Start of Manual Message 11 0B VT Vertical Tabulation (FE) VT Vertical Tab 12 0C FF Form Feed (FE) FF Form Feed 13 0D CR Carriage Return (FE) CR Carriage Return 14 0E SO Shift Out SO Shift Out 15 0F SI Shift In SI Shift In 16 10 DLE Data Link Escape (CC) DLE Data Link Escape 17 11 DC1 Device Control 1 DC1 Device Control 1 18 12 DC2 Device Control 2 DC2 Device Control 2 19 13 DC3 Device Control 3 TM Tape Mark 20 14 DC4 Device Control 4 RES Restore 21 15 NAK Negative Acknowledge (CC) NL New Line 22 16 SYN Synchronous Idle (CC) BS Backspace 23 17 ETB End of Transmission Block (CC) IL Idle
An Introduction to Mainframes - 113 - COBL – Tips and Tricks
24 18 CAN Cancel CAN Cancel 25 19 EM End of Medium EM End of Medium 26 1A SUB Substitute CC Cursor Control 27 1B ESC Escape CU1 Customer Use 1 28 1C FS File Separator (IS) IFS Interchange File Separator 29 1D GS Group Separator (IS) IGS Interchange Group Separator Interchange Record 30 1E RS Record Separator (IS) IRS Separator 31 1F US Unit Separator (IS) IUS Interchange Unit Separator 32 20 SP Space DS Digit Select 33 21 ! Exclamation Point SOS Start of Significance 34 22 " Quotation Mark FS Field Separator 35 23 # Number Sign, Octothorpe, "pound" 36 24 $ Dollar Sign BYP Bypass 37 25 % Percent LF Line Feed 38 26 & Ampersand ETB End of Transmission Block 39 27 ' Apostrophe, Prime ESC Escape 40 28 ( Left Parenthesis 41 29 ) Right Parenthesis 42 2A * Asterisk, "star" SM Set Mode 43 2B + Plus Sign CU2 Customer Use 2 44 2C , Comma 45 2D - Hyphen, Minus Sign ENQ Enquiry 46 2E . Period, Decimal Point, "dot" ACK Acknowledge 47 2F / Slash, Virgule BEL Bell 48 30 0 0 49 31 1 1 50 32 2 2 SYN Synchronous Idle 51 33 3 3 52 34 4 4 PN Punch On 53 35 5 5 RS Reader Stop 54 36 6 6 UC Upper Case 55 37 7 7 EOT End of Transmission 56 38 8 8
An Introduction to Mainframes - 114 - COBL – Tips and Tricks
57 39 9 9 58 3A : Colon 59 3B ; Semicolon CU3 Customer Use 3 60 3C < Less-than Sign DC4 Device Control 4 61 3D = Equal Sign NAK Negative Acknowledge 62 3E > Greater-than Sign 63 3F ? Question Mark SUB Substitute 64 40 @ At Sign SP Space 65 41 A A 66 42 B B 67 43 C C 68 44 D D 69 45 E E 70 46 F F 71 47 G G 72 48 H H 73 49 I I 74 4A J J ¢ Cent Sign 75 4B K K . Period, Decimal Point, "dot" 76 4C L L < Less-than Sign 77 4D M M ( Left Parenthesis 78 4E N N + Plus Sign 79 4F O O | Logical OR 80 50 P P & Ampersand 81 51 Q Q 82 52 R R 83 53 S S 84 54 T T 85 55 U U 86 56 V V 87 57 W W 88 58 X X 89 59 Y Y 90 5A Z Z ! Exclamation Point
An Introduction to Mainframes - 115 - COBL – Tips and Tricks
91 5B [ Opening Bracket $ Dollar Sign 92 5C \ Reverse Slant * Asterisk, "star" 93 5D ] Closing Bracket ) Right Parenthesis 94 5E ^ Circumflex, Caret ; Semicolon 95 5F _ Underline, Underscore ¬ Logical NOT 96 60 ` Grave Accent - Hyphen, Minus Sign 97 61 a a / Slash, Virgule 98 62 b b 99 63 c c 100 64 d d 101 65 e e 102 66 f f 103 67 g g 104 68 h h 105 69 i i 106 6A j j 107 6B k k , Comma 108 6C l l % Percent 109 6D m m _ Underline, Underscore 110 6E n n > Greater-than Sign 111 6F o o ? Question Mark 112 70 p p 113 71 q q 114 72 r r 115 73 s s 116 74 t t 117 75 u u 118 76 v v 119 77 w w 120 78 x x 121 79 y y 122 7A z z : Colon Number Sign, Octothorp, 123 7B { Opening Brace # "pound"
An Introduction to Mainframes - 116 - COBL – Tips and Tricks
124 7C | Vertical Line @ At Sign 125 7D } Closing Brace ' Apostrophe, Prime 126 7E ~ Tilde = Equal Sign 127 7F DEL Delete " Quotation Mark 128 80 Reserved 129 81 Reserved a a 130 82 Reserved b b 131 83 Reserved c c 132 84 IND Index (FE) d d 133 85 NEL Next Line (FE) e e 134 86 SSA Start of Selected Area f f 135 87 ESA End of Selected Area g g 136 88 HTS Horizontal Tabulation Set (FE) h h Horizontal Tabulation with 137 89 HTJ i i Justification (FE) 138 8A VTS Vertical Tabulation Set (FE) 139 8B PLD Partial Line Down (FE) 140 8C PLU Partial Line Up (FE) 141 8D RI Reverse Index (FE) 142 8E SS2 Single Shift Two (1) 143 8F SS3 Single Shift Three (1) 144 90 DCS Device Control String (2) 145 91 PU1 Private Use One j j 146 92 PU2 Private Use Two k k 147 93 STS Set Transmit State l l 148 94 CCH Cancel Character m m 149 95 MW Message Waiting n n 150 96 SPA Start of Protected Area o o 151 97 EPA End of Protected Area p p 152 98 Reserved q q 153 99 Reserved r r 154 9A Reserved 155 9B CSI Control Sequence Introducer (1) 156 9C ST String Terminator (2)
An Introduction to Mainframes - 117 - COBL – Tips and Tricks
157 9D OSC Operating System Command (2) 158 9E PM Privacy Message (2) 159 9F APC Application Program Command (2) 160 A0 161 A1 162 A2 s s 163 A3 t t 164 A4 u u 165 A5 v v 166 A6 w w 167 A7 x x 168 A8 y y 169 A9 z z 170 AA 171 AB 172 AC 173 AD 174 AE 175 AF 176 B0 177 B1 178 B2 179 B3 180 B4 181 B5 182 B6 183 B7 184 B8 185 B9 ` Grave Accent 186 BA 187 BB 188 BC 189 BD 190 BE
An Introduction to Mainframes - 118 - COBL – Tips and Tricks
191 BF 192 C0 193 C1 A A 194 C2 B B 195 C3 C C 196 C4 D D 197 C5 E E 198 C6 F F 199 C7 G G 200 C8 H H 201 C9 I I 202 CA 203 CB 204 CC 205 CD 206 CE 207 CF 208 D0 209 D1 J J 210 D2 K K 211 D3 L L 212 D4 M M 213 D5 N N 214 D6 O O 215 D7 P P 216 D8 Q Q 217 D9 R R 218 DA 219 DB 220 DC 221 DD 222 DE 223 DF 224 E0
An Introduction to Mainframes - 119 - COBL – Tips and Tricks
225 E1 226 E2 S S 227 E3 T T 228 E4 U U 229 E5 V V 230 E6 W W 231 E7 X X 232 E8 Y Y 233 E9 Z Z 234 EA 235 EB 236 EC 237 ED 238 EE 239 EF 240 F0 0 0 241 F1 1 1 242 F2 2 2 243 F3 3 3 244 F4 4 4 245 F5 5 5 246 F6 6 6 247 F7 7 7 248 F8 8 8 249 F9 9 9 250 FA 251 FB 252 FC 253 FD 254 FE 255 FF
Look into the HEX column, where numeric 1 is represented as F1 where F is actually the sequence used to represent the series. For calculation, the system will take only the lower order nibbles. In this case, it is 1. So, S0C7 will occur only when an invalid value is present
An Introduction to Mainframes - 120 - COBL – Tips and Tricks in the lower order nibble. Where invalid value means not simply alphabetic characters stored in numeric field. This is because, if you try to move 1A to a numeric field, the COBOL compiler will do an automatic data conversion. 1A will be represented internally as 1A FC 11 Here the lower order nibbles contain numeric 11 so if you move 1A to a numeric filed and try to manipulate that filed, it won’t cause a S0C7 , because it contains 11. Suppose you are moving 9* to a numeric field. That will be represented internally as 9* F5 9C Now, the lower order nibbles contain an invalid character C, if you try to manipulate this field, it would cause a S0C7 abend.
Look at the following program and its output
DATA DIVISION. WORKING-STORAGE SECTION.
01 SAMPLE PIC X(2) VALUE '9*'. 01 SAMPLE1 PIC 9(2) COMP-3. 01 SAMPLE2 PIC 9(2). PROCEDURE DIVISION. MOVE SAMPLE TO SAMPLE1 DISPLAY SAMPLE1 ' IS SAMPLE 1:COMP-3:BEFORE COMPUTATION' MOVE SAMPLE1 TO SAMPLE2 DISPLAY SAMPLE2 ' IS SAMPLE 2:9(2):MOVED FROM COMP-3' *********THIS LINE WILL CAUSE A S0C7 ABEND************ ADD 1 TO SAMPLE1 ****************************************************** DISPLAY SAMPLE1 ' IS SAMPLE 1:COMP-3:AFTER COMPUTATION' DISPLAY SAMPLE ' IS SAMPLE: PIC X' STOP RUN
This program will cause a S0C7 abend. Its output is
9Ü IS SAMPLE 1:COMP-3:BEFORE COMPUTATION 9Ü IS SAMPLE 2:9(2):MOVED FROM COMP-3
Note that
DISPLAY SAMPLE1 ' IS SAMPLE 1:COMP-3:AFTER COMPUTATION' and DISPLAY SAMPLE ' IS SAMPLE: PIC X'
Are not executed because just before that the program abended.
This is a possible cause of S0C7 error. For more information on the causes of this error, see the description of S0C7 in QW.
An Introduction to Mainframes - 121 - COBL – Tips and Tricks
1.11. SEARCH and SEARCH ALL
SEARCH is a serial search
SEARCH ALL is a binary search and the table must be sorted before using SEARCH ALL. (ASCENDING/DESCEDING KEY clause is to be used and the data must be loaded in this order)
Binary Search is search on a sorted array. Compare the item to be searched with the item at the center. If it matches, it stops the search else repeat the process with the left half or the right half depending on where the item lies.
Searching order in the SEARCH ALL can be either ASCENDING or DESCENDING. ASCENDING is default. If you want the search to be done on an array sorted in descending order, then while defining the array, you should give DESCENDING KEY clause. (You must load the table in the specified order).
1.12. Static and Dynamic Subroutine CALLs
Keep in mind as you read this that some compilers let you set options that will override the calling mechanisms shown below. Therefore, even if your program is coded to call a program statically, the compiler can convert it to the dynamic form of CALL if you set (or don't set) the correct compiler options. Such compiler options are discussed at the end of this document.
1.12.1. Static CALLs
In COBOL, you normally call a subroutine like this:
CALL 'A' USING arguments
The static form of the CALL statement specifies the name of the subroutine as a literal; e.g., it is in quotes.
This is the static form of a subroutine call. The compiler generates object code for this which will cause the linker to copy the object module a.obj into your executable when it is linked.
So, if you modify "A" and recompile it, you must also relink all of the executables that call "A", because the each of the executables contains its own copy of "A".
1.12.1.1. Good things about Static CALLs
• Fewer files are needed to distribute your application because your application can be built into a single EXE file, or perhaps an EXE for your main, and a couple of DLLs
An Introduction to Mainframes - 122 - COBL – Tips and Tricks
for subordinate modules. This generally makes it simpler to distribute and/or upgrade your end users.
Note: A dynamic-link library (DLL) is a module that contains functions and data that can be used by another module (application or DLL).
• No risk of mixing/matching different versions of your called subroutines, because they are bundled into your main program.
1.12.1.2. Bad things about Static CALLs
• You must relink all of the EXE and DLL files in your application that use a statically linked subroutine in order to use the newer version of the subroutine.
• If your application contains DLLs that call a subroutine statically, each DLL will have its own copy of the subroutine, including the storage defined in the subroutine. As a result, your application uses more storage than necessary.
• If your application has multiple DLLs that use the same statically named subroutine, each DLL has its own copy of that subroutine and its storage. Therefore, if you set a value in the subroutine in one of the DLLs, it's local to that DLL. The copy linked to the other DLLs will not know about this. This can be either a Good Thing or a Bad Thing, of course, but it's definitely a trap for the unwary.
1.12.2. Dynamic CALLs
In COBOL, the dynamic form of a subroutine call is coded like this:
SUBROUTINE-A PIC X(8) VALUE 'A'. . . . CALL SUBROUTINE-A USING arguments
The dynamic form of the CALL statement specifies the name of the subroutine using a variable; the variable contains the name of the subroutine to be invoked.
The difference is that the name of the subroutine is found in the variable SUBROUTINE-A. The compiled code will cause the operating system to load the subroutine when it is required instead of incorporating it into the executable.
An Introduction to Mainframes - 123 - COBL – Tips and Tricks
Note that you can also load a module dynamically by including it in a DLL and then linking it using the import library for that DLL!
1.12.2.1. Good things about Dynamic CALLs
• You don't need to relink your application if you change something in your subroutine; only the subroutine DLL needs to be relinked.
• All executables that call this subroutine will share the same DLL; both the code and data. Since your application only loads one copy of a dynamically called subroutine, it uses less memory.
• Changes in values contained within the dynamically called subroutine are available to all the DLLs that use it, because they all share the same copy of the subroutine.
1.12.2.2. Bad things about Dynamic CALLs
• Every dynamically called subroutine must be linked as a DLL (unless you use an import library to expose other entry points in a DLL). Therefore, if you application consists of hundreds of subroutines and they're all called dynamically, you will need to distribute hundreds of DLLs.
• It's possible to mix versions of your DLLs. This can be a problem both with distributing your application and with end-users installing updates improperly.
• If one of your DLLs is missing, you may not know about it until the user exercises some facility that tries to call that DLL. At that point, your application will terminate abnormally unless you handle this situation.
• If you CALL a DLL, CANCEL it, then CALL it again, you incur more I/O because the routine needs to be reloaded if you CANCEL it. This can slow down an application because it requires more disk activity
• If you mix and match static and dynamic calls to the same subroutine, your software might have several different versions in memory at once. Guess how much fun it will be trying to debug THAT mess?
1.12.3. Which is Better Static or Dynamic?
The answer is, it depends.
Static subroutines are nice, because your application can be built into a single EXE file, or perhaps an EXE for your main, and a couple of DLLs for subordinate modules.
An Introduction to Mainframes - 124 - COBL – Tips and Tricks
Dynamic subroutines are nice because you can manage memory differently and you can update a portion of your application by shipping a newer DLL instead of the entire application.
You choose static/dynamic linking by choosing either the DYNAM or NODYNAM link edit option. (Even if you choose NODYNAM, a CALL identifier (as opposed to a CALL literal), will translate to a DYNAMIC call). A statically called subroutine will not be in its initial state the next time it is called unless you explicitly use INITIAL or you do a CANCEL. A dynamically called routine will always be in its initial state.
1.13. Why READ FILE and WRITE RECORD?
You READ FILE because you don’t know in advance
• Whether there actually a record to read or not • For variable or undefined length files, how long the next record will be if there is one.
You WRITE RECORD because you know in advance the answer to both of the above questions.
1.14. RETURN CODE of Internal SORT
(Internal – In a COBOL Program)
The return code or completion code is stored in a SORT-RETURN special register.
IF SORT-RETURN = 0 (Successful completion of SORT/MERGE)
IF SORT-RETURN = 16 (Unsuccessful completion of SORT/MERGE)
1.15. Efficient COBOL Coding Techniques
1.15.1. Data Types
Using the proper data types is an important factor in determining the performance characteristic of an application. Some of these are discussed below
1.15.1.1. BINARY (COMP OR COMP-4)
When using binary (COMP) data items, the use of the SYNCHRONIZED clause specifies that the binary data items will be properly aligned on half word, full word or double word boundaries. This may enhance the performance of certain operations on some machines.
An Introduction to Mainframes - 125 - COBL – Tips and Tricks
Additionally, using signed data items with eight or fewer digits produces the best code for binary items. The following shows the performance considerations (from most efficient to least efficient) for the number of digits of precision for signed binary data items (using PICTURE S9(n) COMP)
n is from 1 to 8
For n from 1 to 4, arithmetic is done half word instructions where possible For n from 5 to 8, arithmetic is done in full word instructions where possible
n is from 10 to 17
Arithmetic is done in double word format
n is 9
Full word values are converted to double word format and then double word arithmetic is used (this is slower than any of the above)
n is 18
Double word values are converted to a higher precision format and then arithmetic is done using this higher precision (this is the slowest of all four binary data items)
Note: using 9 digits is slower than using 10 digits.
Performance considerations for BINARY
Using 1 to 8 digits is the fastest Using 10 to 17 digits is 20% to 30% slower than using 1 to 8 digits Using 9 digits is 50% slower than using 1 to 8 digits Using 18 digits is 1150% slower than using 1 to 8 digits
1.15.1.2. PACKED DECIMAL (COMP-3)
When using PACKED DECIMAL (COMP-3) data items in computations use 15 or fewer digits in the picture specification to avoid the use of library routines for multiplication and division. A call to the library routine is expensive compared to the calculation in-line. Additionally, using a signed data item with an odd number of digits produces more efficient code since this uses an integral multiple of bytes in storage for the data item (Please refer the Tips and Tricks doc on COMP-3).
Performance Considerations for PACKED DECIMAL
Using an odd number of digits is 6% faster than using the next lower even number of digits.
An Introduction to Mainframes - 126 - COBL – Tips and Tricks
Using the fewest odd number of digits as possible may result in an additional 5% to 15% savings compared to using the next larger number of odd digits.
When selecting your data types, it is important to understand the performance characteristics of them before you use them. Shown below are some performance considerations of doing several ADDs and SUBTRACTs on the various data types of the specified precision.
1.15.2. Comparing Data Types
Performance Considerations for comparing Data Types
Packed decimal (COMP-3) compared to Binary (COMP or COMP-4)
• Using 1 to 5 digits: packed decimal is 150% to 210% slower than binary • Using 6 to 8 digits: packed decimal is 220% to 260% slower than binary • Using 9 to 17 digits: packed decimal is 100% to 240% slower than binary • Using 18 digits: packed decimal is 65% faster than binary
DISPLAY compared to Packed Decimal
• Using 1 to 9 digits: DISPLAY is 60% to 95% slower than packed decimal • Using 10 to 18 digits: DISPLAY is 100% to 180% slower than packed decimal
DISPLAY compared to Binary
• Using 1 to 5 digits: DISPLAY is 350% to 480% slower than binary • Using 6 to 8 digits: DISPLAY is 500% to 570% slower than binary • Using 9 to 17 digits: DISPLAY is 300% to 725% slower than binary • Using 18 digits: DISPLAY is 10% faster than binary
1.15.3. Data Conversions
Conversion to a common format is necessary for certain types of numeric operations when mixed data types are involved in the computation. This results in additional processing time and storage for these conversions. In order to minimize this overhead, it is recommended that the following guidelines should be followed.
DISPLAY
Avoid using USAGE DISPLAY data items for computations (especially in areas that are heavily used for computation). When a USAGE DISPLAY data item is used, additional overhead is required to convert the data item to the proper type both before and after the computation. In some cases, the conversion is done by a call to a library routine, which can be expensive compared to using the proper data type that does not require any conversion
An Introduction to Mainframes - 127 - COBL – Tips and Tricks
Performance considerations for DISPLAY
Using 1 to 5 digits is the fastest Using 6 to 9 digits is 15% slower than using 1 to 5 digits Using 10 to 13 digits is 50% slower than using 1 to 5 digits Using 14 to 16 digits is 65% slower than using 1 to 5 digits Using 17 to 18 digits is 120% slower than using 1 to 5 digits.
1.15.4. INDEXES Vs SUBSCRIPTS
Using indexes to address a table is more efficient than using subscripts since the index already contains the displacement from the start of the table and does not have to be calculated at run time. Subscripts on the other hand contain an occurrence number that must be converted to a displacement value at run time before it can be used. When using subscripts to address a table, use a binary signed data item with eight or fewer digits (for example, using PICTURE S9(8) COMP) for the data item). This will allow full word arithmetic to be used during the calculations. Additionally in some cases, using four or fewer digits for the data item may also offer some added reduction in CPU time since half word arithmetic can be used
Performance Considerations for Indexes Vs Subscripts (PIC S9(8))
Using binary data items (COMP) to address a table is 56% slower than using indexes
Using decimal data items (COMP-3) to address a table is 426% slower than using indexes
Using DISPLAY data items to address a table is 680% slower than using indexes
1.16. Compiler options that affect run time performance
1.16.1. AWO or NOAWO
The AWO compiler option causes the APPLY WRITE ONLY clause to be in effect for all physical sequential, variable length, blocked files, even if the APPLY WRITE ONLY clause is not specified in the program. With APPLY WRITE ONLY in effect, the file buffer is written to the output device when there is not enough space in the buffer for the next record. Without APPLY WRITE ONLY, the file buffer is written to the output device when there is not enough space in the buffer for the maximum size record. If the application has a large variation in the size of records to be written, using APPLY WRITE ONLY can result in a performance savings since this will generally result in fewer calls to Data Management Services to handle the I/Os.
Performance Consideration using AWO
One program using variable length files and AWO was 10% faster than NOAWO
An Introduction to Mainframes - 128 - COBL – Tips and Tricks
1.16.2. OPTIMIZE(STD), OPTIMIZE(FULL) OR NOOPTIMIZE
To assist in the optimization of the code, you should use the OPTIMIZE compiler option. With the OPTIMIZE(STD) or OPTIMIZE(FULL) options in effect, you may receive optimizations that include
• Eliminating unnecessary branches • Simplifying inefficient branches • Simplifying the code for the out-of-line PERFORM statement , moving the performed paragraphs in-line, where possible • Simplifying the code for a CALL to a contained (nested) program, moving the called statements in-line, where possible • Eliminating duplicate computations • Eliminating constant computations • Aggregating moves of contiguous, equal sized items into a single move • Deleting unreachable code
Additionally with the OPTIMIZE(FULL) option in effect, you may also receive these optimizations
• Deleting unreferenced data items and the associated code to initialize their VALUE clauses
NOOPTIMIZE is generally used while a program is being developed when frequent compiles are necessary. NOOPTIMIZE also makes it easier to debug a program since code is not moved. NOOPTIMIZE is required when using the TEST compiler option with a value other than TEST(NONE). OPTIMIZE requires more CPU times for compiles than NOOPTIMIZE, but generally produces more efficient run time code. For production runs, OPTIMIZE is recommended.
Performance Considerations using OPTIMIZE
• On the average, OPTIMIZE(STD) was 4% faster than NOOPTIMIZE, with a range of 17% faster to equivalent. • On the average, OPTIMIZE(FULL) was equivalent to OPTIMIZE(STD)
1.16.3. SSRANGE or NOSSRANGE
Using SSRANGE generates additional code, to verify that all subscripts, indexes and reference modification expressions are within the proper bounds. This inline code occurs at every reference to a subscripted or variable length data item, as well as every reference modification expression, and it can result in some degradation at run time. In general if you need to verify the subscripts only a few times in the application instead of at every reference, coding your own checks may be faster than using the SSRANGE option. For performance sensitive applications, NOSSRANGE is recommended.
An Introduction to Mainframes - 129 - COBL – Tips and Tricks
Performance Considerations using SSRANGE with CHECK(ON)
On the average, SSRANGE was 4% slower than NOSSRANGE
1.16.4. TRUNC – BIN, STD OR OPT
When using the TRUNC(BIN) compiler option, all binary (COMP) sending fields are treated as half word, full word or double word values, depending on the PICTURE clause, and code is generated to truncate all binary receiving fields to the corresponding half word, full word or double word boundary (base 2 truncation). This can add significant amount of degradation since typically some data conversion must be done, which may require the use of some library routines. BIN is usually the slowest of the three sub options for TRUNC.
When using the TRUNC(STD) compiler option, the final or intermediate result of an arithmetic expression, or the sending field in the MOVE statement, is truncated to the number of digits in the PICTURE clause of the binary (COMP) receiving field (base 10 truncation). This too can add significant amount of degradation since typically the number is divided by some power of 10 (depending on the number of digits in the PICTURE clause) and the remainder is used. A divide instruction is one of the most expensive instructions.
With TRUNC(OPT), the compiler assumes that the data conforms to the PICTURE and USAGE specifications and manipulates the result based on the size of the field in storage (half word, full word or double word)
Performance Considerations for TRUNC
• On the average, TRUNC(OPT) was 27% faster than TRUNC(BIN) • On the average, TRUNC(STD) was 26% faster than TRUNC(BIN) • On the average, TRUNC(OPT) was 5% faster than TRUNC(STD)
1.16.5. NUMPROC – NOPFD, MIG OR PFD
Using the NUMPROC(PFD) compiler option generates significantly more efficient code for numeric comparisons. It also avoids the generation of extra code that NUMPROC(NOPFD) or NUMPROC(MIG) generates for most references to COMP-3 and DISPLAY numeric data items to ensure a correct sign is being used. With NUMPROC(NOPFD), sign fix-up processing is done for all references to these numeric data items. With NUMPROC(MIG), sign fix-up processing is done only for receiving fields (and not for sending fields) of arithmetic and move statements
With NUMPROC(PFD), the compiler assumes that the data has the correct sign and bypasses the sign fix-up processing
An Introduction to Mainframes - 130 - COBL – Tips and Tricks
Using NUMPROC(NOPFD) or NUMPROC(MIG) may also inhibit some other types of optimization. However not all external data files contain the proper sign for COMP-3 or DISPLAY signed numeric data, and hence using NUMPROC(PFD) may not be applicable for all application programs. For performance sensitive applications, NUMPROC(PFD) is recommended when possible.
Performance Considerations using NUMPROC
On the average, NUMPROC(PFD) was 1% faster than NUMPROC(NOPFD)
On the average, NUMPROC(PFD) was 1% faster than NUMPROC(MIG)
On the average, NUMPROC(MIG) was equivalent to NUMPROC(NOPFD)
1.16.6. DYNAM Or NODYNAM
The DYNAM compiler option specifies that all subprograms invoked through the CALL literal statement will be loaded dynamically at run time. This allows you to share common subprograms among several different applications, allowing for easier maintenance of these subprograms since the application will not have to be re-link-edited if the subprogram is changed. DYNAM also allows you to control the use of virtual storage by giving you the ability to use a CANCEL statement to free the virtual storage used by a subprogram when the subprogram is no longer needed. However when using the DYNAM option, you pay a performance penalty since the call must go through a library routine, whereas with the NODYNAM option, the call goes directly to the subprogram. Hence the path length is longer with DYNAM than with NODYNAM.
Performance Considerations Using DYNAM with CALL (Measuring CALL overhead only)
On the average, for a CALL intensive application, the overhead associated with the CALL using DYNAM ranged from 80% slower to 350% slower than NODYNAM
1.16.7. RENT or NORENT
Using the RENT compiler option causes the compiler to generate some additional code to ensure that the program is reentrant. Reentrant programs can be placed in shared storage like Link Pack Area (LPA) or the Extended Link Pack Area (ELPA) on MVS. Also the RENT option will allow the program to run above the 16 MB line on MVS. Producing the reentrant code may increase the execution time path length slightly.
Performance considerations using RENT
On the average RENT was equivalent to NORENT with a range of equivalent to 1% slower.
An Introduction to Mainframes - 131 - COBL – Tips and Tricks
1.17. Run Time Options that Affect Run Time Performance
Selecting the proper run time options is another factor that affects the performance of a COBOL application.
1.17.1. ALL 31
The ALL31 option allows LE to take advantage of knowing that there are no AMODE(24) routines in the application. It specifies that the entire application will run in AMODE(31). This can help to improve the performance for an all AMODE(31) application because Linkage Editor can minimize the amount of mode switching across calls to common run time library routines.
Performance Considerations using ALL31 (Measuring CALL overhead only)
On the average, ALL31(ON) was 1% faster than ALL31(OFF)
1.17.2. CHECK
The CHECK option activates the additional code generated by the SSRANGE compiler option, which requires more CPU time resources for the verification of the subscripts, indexes and reference modification expressions. Using the CHECK(OFF) run time option deactivates this code but still requires some additional CPU time resources at every use of a subscript, index or reference modification expression to determine that this check is not desired during the particular run of the program. This options has an effect only on a program that has been compiled with the SSRANGE compiler option
Performance Considerations using CHECK
On the average, CHECK(ON) with SSRANGE was 2% slower than CHECK(OFF) with SSRANGE
An Introduction to Mainframes - 132 - COBL – Tips and Tricks
1.18. Dynamic Array
When a table of variable size is required, the OCCURS DEPENDING ON clause may be used
Example
01 WS4-T-TABLE-FIELDS. 03 WS4-T-TABLE OCCURS 1 TO 5000 TIMES DEPENING ON Q-MAX-ENTRY INDEXED BY WS4-Y-INDX.
05 I-RATE-SHT PIC S9(03). 05 C-CALC-DEM-USGE PIC X (02).
Here, depending on the value of the data name Q-MAX-ENTRY, the size of WS4-T-TABLE will be decided. It can be anything between 1 and 5000
This saves space, instead of reserving 5000 entries, it reserves only the required storage space as specified by Q-MAX-ENTRY at the run time
An Introduction to Mainframes - 133 - DB2 – Tips and Tricks
Chapter 2
DB2 – Tips and Tricks
An Introduction to Mainframes - 134 - DB2 – Tips and Tricks
2. DB2 – Tips and Tricks
2.1. Null Indicator
To retrieve data from a nullable column, use null indicators.
Syntax:
INTO :HOSTVAR:NULLIND
The picture clause that should be used for the null indicator is S9(4) COMP
Meaning:
-1 : the field is null 0 : the field is not null -2 : the field value is truncated
Inserting a record with a nullable column
To insert a NULL, move -1 to the null indicator To insert a valid value, move 0 to the null indicator
2.2. DBRM
Data Base Request Module, has the SQL statements extracted from the host language program by the SQL pre-compiler.
2.3. Plan
A result of the BIND process - It has the executable code for the SQL statements in the DBRM. Plan is marked as invalid if the index used by it is dropped. The next time the plan is invoked, it is recreated.
2.4. Synonym
Synonym is an alternate, private name for a table or view. A synonym is accessible only by the creator. Synonym is dropped when the table or tablespace is dropped
An Introduction to Mainframes - 135 - DB2 – Tips and Tricks
2.5. Alias
Alias is a locally defined name for a table or view in the same local DB2 subsystem or in a remote DB2 subsystem. Aliases give DB2 location independence because an alias can be created for a table at a remote site, thereby freeing the user from specifying the site that contains the data. Aliases can be used also as a type of global synonym. This is so because they can be accessed by anyone, not only by their creator (as is the case with synonyms)
2.6. Views
View is nothing but a stored query. Views are not supported by their own, physically separate, distinguishable stored data. Instead, their definition in terms of other tables is stored in the catalog table (SYSVIEWS). For example
CREATE VIEW GOOD_SUPPLIERES AS SELECT S#, STATUS, CITY FROM S WHERE STATUS > 15;
When this CREATE VIEW is executed, the sub query following the AS is not executed; instead it is simply saved in the catalog, under the specified view name (GOOD- SUPPLIERS)
GOOD_SUPPLIERS is in effect a “window” into the real table S. Furthermore that window is dynamic: changes to S will be automatically and instantaneously visible through that window. Likewise, changes to GOOD_SUPPLIERS will automatically and instantaneously be applied to the real table S.
Consider a retrieval operation.
SELECT * FROM GOOD_SUPPLIERS WHERE CITY = ‘LONDON’ ;
The system handles such an operation by converting it into an equivalent operation on the underlying base table(s). In this example, the equivalent operation is
SELECT S#, STATUS, CITY FROM S WHERE CITY = ‘LONDON’ AND STATUS > 15;
ARE THE VIEWS UPDATABLE ?
Not all of them. Some views are updatable e.g. single table view with all the fields or mandatory fields. Examples of non-updatable views are views which are joins, views that contain aggregate functions(such as MIN this is obvious).
An Introduction to Mainframes - 136 - DB2 – Tips and Tricks
2.7. How to Run a DB2 Batch Program
Use DSN utility to run a DB2 batch program. An example is shown:
DSN SYSTEM(DSP3) RUN PROGRAM(EDD470BD) PLAN(EDD470BD) LIB('EDGS01T.OBJ.LOADLIB') END
Use IKJEFT01 utility program to run this command in a JCL.
2.8. Why SELECT * is not preferred in embedded SQL programs?
For three reasons: • If the table structure is changed ( a field is added ), the program will have to be modified • Program might retrieve the columns which it might not use, leading on I/O over head. • The chance of an index only scan is lost.
2.9. How does DB2 store NULL physically?
High Values
2.10. Concatenate
To concatenate the FIRSTNAME and LASTNAME from EMP table to give a complete name, we can use the following syntax
SELECT FIRSTNAME || ‘ ‘ || LASTNAME FROM EMP;
2.11. COALESCE Function in DB2
The COALESCE function avoids the use of nulls in the result column of OUTER JOIN statements. Consider the following query
SELECT EMP.EMPNO, EMP.WORKDEPT, DEPT.DEPTNAME FROM EMP FULL OUTER JOIN DEPT ON EMP.WORKDEPT = DEPT.DEPTNO;
An Introduction to Mainframes - 137 - DB2 – Tips and Tricks
Let us say the result of this query looks as follows:
EMPNO WORKDEPT DEPTNAME 3089 S12 SOFTWARE QUALITY 7654 A09 CORPORATE ADMIN ...... TRAINING DEPT
It can be seen that the TRAINING DEPT's WORKDEPT is not shown in the table because the query selects WORKDEPT from EMP, not the DEPTNO column from DEPT. This can be rectified using the COALESCE function. The COALESCE function notifies DB2 to look for a value in the listed columns, one from each table in the outer join. If this value is found in either of the table it can be returned as a result. The following example depicts the use of COALESCE
SELECT EMP.EMPNO COALESCE(EMP.WORKDEPT, DEPT.DEPTNO) AS DEPTNUM, DEPT.DEPTNAME FROM EMP FULL OUTER JOIN DEPT ON EMP.WORKDEPT = DEPT.DEPTNO;
The O/P for the above query would be now shown as follows...
EMPNO DEPTNUM DEPTNAME 3089 S12 SOFTWARE QUALITY 7654 A09 CORPORATE ADMIN .... T01 TRAINING DEPT
We can see that the COALESCE function determines that the department code is stored in the DEPT.DEPTNO column and returns that value instead of the null because there is no corresponding WORKDEPT number.
2.12. DCLGEN
DeCLarations GENerator: used to create the host language copy books for the table definitions. Also creates the DECLARE table.
It is not mandatory to use DCLGEN. Using DCLGEN, helps detect wrongly spelt column names etc. during the precompile stage itself (because of the DECLARE TABLE). DCLGEN being a tool would generate accurate host variable definitions for the table reducing chances of error.
It not necessary to have DECLARE TABLE statement in DCLGEN - This is used by the pre- compiler to validate the table-name, view-name, column name etc.
An Introduction to Mainframes - 138 - DB2 – Tips and Tricks
2.13. EXPLAIN
EXPLAIN allows the user to obtain information regarding the optimizer’s choice of access strategy for a specified SQL statement. The information provided includes the indexes used, details of any sorts that will be needed, and (if the specified statement involves any joins) the order in which tables will be joined and the methods by which the individual joins will be performed. Such information can be useful for tuning existing applications, also for determining how projected applications will perform...
Syntax
EXPLAIN type FOR statement
Here type is PLAN or ALL, and statement is the SQL statement to be EXPLAINEd. The output from the execution of the EXPLAIN statement is placed into a table called xyz.PLAN_TABLE, which must already exist (xyz here is the authorization ID of the user issuing the EXPLAIN). Here is an example.
EXPLAIN PLAN FOR SELECT S.S#, P.P# FROM S, P WHERE S.CITY = P.CITY;
When the EXPLAIN is executed, DB2 will place information regarding its implementation of the specified SELECT statement into the PLAN_TABLE of the user issuing the EXPLAIN. The user can then interrogate that table by means of ordinary select statements in order to discover, for example whether a particular index is being used or whether creating a new index might obviate the need for a sort. Before you can use EXPLAIN, a PLAN_TABLE must be created to hold the results of EXPLAIN
2.14. FETCH FIRST n ROWS ONLY
Fetching a limited number of rows: FETCH FIRST n ROWS ONLY
In some applications, you execute queries that can return a large number of rows, but you need only a small subset of those rows. Retrieving the entire result table from the query can be inefficient. You can specify the FETCH FIRST n ROWS ONLY clause in a SELECT statement to limit the number of rows in the result table of a query to n rows.
Example: Suppose that you write an application that requires information on only the 20 employees with the highest salaries. To return only the rows of the employee table for those 20 employees, you can write a query like this:
An Introduction to Mainframes - 139 - DB2 – Tips and Tricks
SELECT LASTNAME, FIRSTNAME, EMPNO, SALARY FROM EMP ORDER BY SALARY DESC FETCH FIRST 20 ROWS ONLY;
2.15. OPTIMIZE FOR n ROWS
Minimizing overhead for retrieving few rows: OPTIMIZE FOR n ROWS
When an application executes a SELECT statement, DB2 assumes that the application will retrieve all the qualifying rows. This assumption is most appropriate for batch environments. However, for interactive SQL applications, such as SPUFI, it is common for a query to define a very large potential result set but retrieve only the first few rows. The access path that DB2 chooses might not be optimal for those interactive applications.
What OPTIMIZE FOR n ROWS does: The OPTIMIZE FOR n ROWS clause lets an application declare its intent to do either of these things:
• Retrieve only a subset of the result set • Give priority to the retrieval of the first few rows
DB2 uses the OPTIMIZE FOR n ROWS clause to choose access paths that minimize the response time for retrieving the first few rows.
Use OPTIMIZE FOR 1 ROW to avoid sorts: You can influence the access path most by using OPTIMIZE FOR 1 ROW. OPTIMIZE FOR 1 ROW tells DB2 to select an access path that returns the first qualifying row quickly. This means that whenever possible, DB2 avoids any access path that involves a sort. If you specify a value for n that is anything but 1, DB2 chooses an access path based on cost, and you won't necessarily avoid sorts.
How many rows you can retrieve with OPTIMIZE FOR n ROWS: The OPTIMIZE FOR n ROWS clause does not prevent you from retrieving all the qualifying rows. However, if you use OPTIMIZE FOR n ROWS, the total elapsed time to retrieve all the qualifying rows might be significantly greater than if DB2 had optimized for the entire result set.
When OPTIMIZE FOR n ROWS is effective: OPTIMIZE FOR n ROWS is effective only on queries that can be performed incrementally. If the query causes DB2 to gather the whole result set before returning the first row, DB2 ignores the OPTIMIZE FOR n ROWS clause, as in the following situations:
• The query uses SELECT DISTINCT or a set function distinct, such as COUNT(DISTINCT C1). • Either GROUP BY or ORDER BY is used, and no index can give the necessary ordering. • An aggregate function and no GROUP BY clause is used. • The query uses UNION.
An Introduction to Mainframes - 140 - DB2 – Tips and Tricks
Example: Suppose that you query the employee table regularly to determine the employees with the highest salaries. You might use a query like this:
SELECT LASTNAME, FIRSTNAME, EMPNO, SALARY FROM EMP ORDER BY SALARY DESC;
An index is defined on column EMPNO, so employee records are ordered by EMPNO. If you have also defined a descending index on column SALARY, that index is likely to be very poorly clustered. To avoid many random, synchronous I/O operations, DB2 would most likely use a table space scan, then sort the rows on SALARY. This technique can cause a delay before the first qualifying rows can be returned to the application. If you add the OPTIMIZE FOR n ROWS clause to the statement, DB2 will probably use the SALARY index directly because you have indicated that you expect to retrieve the salaries of only the 20 most highly paid employees.
Example: The following statement uses that strategy to avoid a costly sort operation:
SELECT LASTNAME,FIRSTNAME,EMPNO,SALARY FROM EMP ORDER BY SALARY DESC OPTIMIZE FOR 20 ROWS;
Effects of using OPTIMIZE FOR n ROWS:
• The join method could change. Nested loop join is the most likely choice, because it has low overhead cost and appears to be more efficient if you want to retrieve only one row. • An index that matches the ORDER BY clause is more likely to be picked. This is because no sort would be needed for the ORDER BY. • List prefetch is less likely to be picked. • Sequential prefetch is less likely to be requested by DB2 because it infers that you only want to see a small number of rows. • In a join query, the table with the columns in the ORDER BY clause is likely to be picked as the outer table if there is an index on that outer table that gives the ordering needed for the ORDER BY clause.
2.16. RUNSTATS
RUNSTATS is a DB2 utility to collect statistics about the data values in tables which can be used by the optimizer to decide the access path. These statistics are stored in DB2 catalog tables and is critical in determining access paths for an SQL statement.
An Introduction to Mainframes - 141 - DB2 – Tips and Tricks
2.17. IMAGECOPY
IMAGECOPY is a full backup of a DB2 table which can be used in recovery.
2.18. DECIMAL(n,m)
For SQL declaration of DECIMAL(n,m), the COBOL equivalent generated is
PIC S9(n-m)V9(m) COMP-3
2.19. Indicator Variable and -305 ABEND
DB2 doesn’t differentiate between nulls that signify unknown data and those that signify inapplicable data. This distinction must be made by the program logic of each application.
DB2 represents null in a special hidden column known as indicator variable. An indicator variable is defined to DB2 for each column that can accept nulls. The indicator variable is transparent to the end user but must be provided for when programming in a host language. Every column defined to a DB2 table must be designated as either allowing or disallowing nulls.
The default definition for columns in a DB2 table is to allow nulls. Nulls can be prohibited for a column by specifying the NOT NULL or NOT NULL WITH DEFAULT option in the CREATE TABLE statement.
Suppose we have the following SELECT statement
EXEC SQL SELECT STATUS , CITY INTO : WS-STATUS ,: WS-CITY FROM XXXX.SAMPLE WHERE S# = 1234 END-SQL
What if the SELECT statement selects exactly one record but the status value in that record happens to be null?
With this select statement, we will receive -305 SQLCODE
An Introduction to Mainframes - 142 - DB2 – Tips and Tricks
If there is a chance that the source of a retrieval operation might be null, the user should include an indicator variable in the INTO clause in addition to the normal target variable as shown below
EXEC SQL SELECT STATUS , CITY INTO : WS-STATUS:WS-STATUS-IND ,: WS-CITY FROM XXXX.SAMPLE WHERE S# = 1234 END-SQL
IF WS-STATUS-ID = -1 . .
If the field to be retrieved is null and an indicator variable has been specified, then that indicator variable will be set to the value -1 and the ordinary target variable will remain unchanged. The indicator variable will be zero otherwise (i.e. not null).
The indicator variable will be set to -2 if the null is not directly derived from a database field but is instead generated by DB2. DB2 will generate a null if an error ( for example division by zero or a data type conversion error) occurs in computing the value of some expression to be retrieved.
We can solve -305 in two ways
• Change the program to handle indicator variables • Correct the db field in error
2.20. CASE Expressions
The CASE Expression, introduced to DB2 in V5, is similar to CASE statements used by many popular programming languages. A CASE statement uses the value of a specified expression to select one statement among several for execution. A common application of the CASE statement will be to eliminate a multi table UNION statement; for example
SELECT CREATOR, NAME, ‘TABLE’ FROM SYSIBM.SYSTABLES WHERE TYPE = ‘T’
UNION ALL
SELECT CREATOR, NAME, ‘VIEW’ FROM SYSIBM.SYSTABLES WHERE TYPE = ‘V’
An Introduction to Mainframes - 143 - DB2 – Tips and Tricks
UNION ALL
SELECT CREATOR, NAME, ‘ALIAS’ FROM SYSIBM.SYSTABLES WHERE TYPE = ‘A’;
Can be coded more simply as
SELECT CREATOR, NAME, CASE TYPE WHEN ‘T’ THEN ‘TABLE’ WHEN ‘V’ THEN ‘VIEW’ WHEN ‘A’ THEN ‘ALIAS’ END FROM SYSIBM.SYSTABLES;
When CASE is used in place of multiple UNIONs, performance most likely will be improved because DB2 will make fewer passes against the data to return a result set. In the preceding example, only one pass is required instead of three.
CASE expressions enable one to do if-then-else type processing inside of SQL statements.
The sequence of the CASE conditions can affect the answer. The first WHEN check that matches is the one used.
There are two general flavors of the CASE expression. In the first kind, each WHEN statement does its own independent check. In the second kind, all of the WHEN conditions do similar "equal" checks against a common reference expression.
First type
SELECT I_ACCT_CA, C_CUST_BILL_STA AS BILL_STATUS, CASE C_CUST_BILL_STA WHEN 'PDF' THEN 'PAST DUE FINAL' WHEN 'CAN' THEN 'CANCELLED' WHEN 'COA' THEN 'CHARGED OFF' WHEN 'ACT' THEN 'ACTIVE' ELSE 'OTHER STATUS' END AS BILL_STATUS_DESC FROM DB2W1P.VCSS_CUST ORDER BY 1
Result set
I BILL ACCT BILL STATUS CA STATUS DESC ------1002539 ACT ACTIVE 1603295 ACT ACTIVE 2302772 ACT ACTIVE
An Introduction to Mainframes - 144 - DB2 – Tips and Tricks
2402770 ACT ACTIVE 2402770 FIN OTHER STATUS 2402770 COA CHARGED OFF 2502623 ACT ACTIVE 2702608 ACT ACTIVE 3002996 ACT ACTIVE 5102952 ACT ACTIVE 5102952 PDF PAST DUE FINAL 5102952 CAN CANCELLED 5102952 FIN OTHER STATUS 5102952 FIN OTHER STATUS
Second type
SELECT I_ACCT_CA, C_CUST_BILL_STA AS BILL_STATUS, CASE WHEN C_CUST_BILL_STA = 'PDF' THEN 'PAST DUE FINAL' WHEN C_CUST_BILL_STA = 'CAN' THEN 'CANCELLED' WHEN C_CUST_BILL_STA = 'COA' THEN 'CHARGED OFF' WHEN C_CUST_BILL_STA = 'ACT' THEN 'ACTIVE' ELSE 'OTHER STATUS' END AS BILL_STATUS_DESC FROM DB2W1P.VCSS_CUST ORDER BY 1
Result set
I BILL ACCT BILL STATUS CA STATUS DESC ------1002539 ACT ACTIVE 1603295 ACT ACTIVE 2302772 ACT ACTIVE 2402770 ACT ACTIVE 2402770 FIN OTHER STATUS 2402770 COA CHARGED OFF 2502623 ACT ACTIVE 2702608 ACT ACTIVE 3002996 ACT ACTIVE 5102952 ACT ACTIVE 5102952 PDF PAST DUE FINAL 5102952 CAN CANCELLED 5102952 FIN OTHER STATUS 5102952 FIN OTHER STATUS 5102952 FIN OTHER STATUS 5102952 FIN OTHER STATUS 5102952 FIN OTHER STATUS 5102952 FIN OTHER STATUS 5303050 FIN OTHER STATUS 5303050 ACT ACTIVE
An Introduction to Mainframes - 145 - DB2 – Tips and Tricks
Note
• If more than one WHEN condition is true, the first one processed that matches is used. • If no WHEN matches, the value in the ELSE clause applies. If no WHEN matches and there is no ELSE clause, the result is NULL. • There must be at least one non-null result in a CASE statement. Failing that, one of the NULL results must be inside of a CAST expression. • All result values must be of the same type. • Functions that have an external action (e.g. RAND) can not be used in the expression part of a CASE statement.
To count the total number of rows those are PDF (Past Due Final) and CAN (Cancelled)
SELECT COUNT(*) AS TOTAL_COUNT, SUM(CASE C_CUST_BILL_STA WHEN 'PDF' THEN 1 ELSE 0 END) AS PDF_COUNT, SUM(CASE C_CUST_BILL_STA WHEN 'CAN' THEN 1 ELSE 0 END) AS CAN_COUNT
FROM DB2W1P.VCSS_CUST ORDER BY 1
Result set
TOTAL PDF CAN COUNT COUNT COUNT ------402 35 18
To verify this result, see the below query
SELECT COUNT(*) AS PDF_COUNT FROM DB2W1P.VCSS_CUST WHERE C_CUST_BILL_STA = 'PDF'
PDF COUNT ------35
The CASE expression can also be used in an UPDATE statement to do any one of several alternative updates to a particular field in a single pass of the data:
UPDATE STAFF SET COMM = CASE DEPT WHEN 15 THEN COMM * 1.1 WHEN 20 THEN COMM * 1.2 WHEN 38 THEN CASE
An Introduction to Mainframes - 146 - DB2 – Tips and Tricks
WHEN YEARS < 5 THEN COMM * 1.3 WHEN YEARS >= 5 THEN COMM * 1.4 ELSE NULL END ELSE COMM END WHERE COMM IS NOT NULL AND DEPT < 50
2.21. Query Management Facility
You can access QMF either through TSOA or TSOB. TSOA is test/development region and TSOB is production region. That is if you access DB2 through TSOB, you will be directly accessing production data (that is by default, the system will be pointing to production databases)
• You can set the profile by selecting PF 11 from the QMF main panel. One important setting is the CONFIRM, if you set it to YES, the system will ask for a confirmation before you delete a table/proc etc… Printer is the 4 character Printer ID installed in the Mainframe system and the user can direct the output of a query to the printer using the 4=Print option in the query panel (by PF4). Other options include Upper/Lower case, Space (the name of DB2 DATABASE or TABLESPACE in which tables will be saved by the SAVE DATA command –explained later) etc..
• Draw function enables the user to list all the fields in a table by entering the table name in the command area (in the query panel) and by selecting the Draw option (PF 6). For example, if you enter the table name ABCD.CUSTOMER_INFO in the command line and press the PF 6 option, it will list a SELECT statement with all the fields in the table without a where clause. This option is useful when you don’t know the fields in the table. If you want to delete a line from the listing thus obtained, you can do so by selecting the line and by pressing PF 11. To insert a new line (for example to add where clause) you can place the cursor at the bottom of the query and press PF 10.
• Save Query As - You can save a query for future reference by the option SAVE QUERY AS
• Once you have saved the query, you can retrieve using LIST QUERIES (OWNER =
o Use DIS option to display a query o Run option to run the query o ERASE option to erase the query from the system
An Introduction to Mainframes - 147 - DB2 – Tips and Tricks
• Forms to format the output of a query
We can use the FORM option to format the output of a QMF Query. Press PF 9 after a query has run. This will show the default form for that query. Where you can change the form and use this while running your query. A sample form is given below
FORM.MAIN
COLUMNS: Total Width of Report Columns: 346 NUM COLUMN HEADING USAGE INDENT WIDTH EDIT SEQ ------1 N_EMPL_INIT_TEST 2 4 C 1 2 N_EMPL_LST_RSLV 2 14 C 2 3 I_DSCRP 2 10 L 3 4 C_DSCRP_PRTY_TEST 2 5 C 4 5 N_TEST_CASE_NO 2 7 C 5 6 D_EST_DLVRY 2 10 TD 6 7 T_DSCRP_ABBR_DESC 2 40 C 7 8 T_DSCRP_DESC 2 240 C 8 *** END ***
PAGE: HEADING ===> FOOTING ===> FINAL: TEXT ===> BREAK1: NEW PAGE FOR BREAK? ===> NO FOOTING ===> BREAK2: NEW PAGE FOR BREAK? ===> NO FOOTING ===> OPTIONS: OUTLINE? ===> YES DEFAULT BREAK TEXT? ===> YES
1=Help 2=Check 3=End 4=Show 5=Chart 6=Query 7=Backward 8=Forward 9= 10=Insert 11=Delete 12=Report OK, FORM is displayed. COMMAND ===> SAVE FORM AS DSCRP_FORM SCROLL ===> PAGE
Here also you can use the SHARE=Y option to make it available for all the users. Later you can use the LIST ALL option to get this form and modify it according to your requirement. The modified form can be saved by using the SAVE option.
While selecting the query to run, you can specify the form option in the command line to get your display formatted according to your form (as shown below)
An Introduction to Mainframes - 148 - DB2 – Tips and Tricks
SQL QUERY T30831.DSCRP LINE 1
SELECT N_EMPL_INIT_TEST, N_EMPL_LST_RSLV, I_DSCRP, C_DSCRP_PRTY_TEST, N_TEST_CASE_NO,D_EST_DLVRY,T_DSCRP_ABBR_DESC, T_DSCRP_DESC FROM DB27.TCSS_DSCRP
*** END ***
1=Help 2=Run 3=End 4=Print 5=Chart 6=Draw 7=Backward 8=Forward 9=Form 10=Insert 11=Delete 12=Report OK, T30831.DSCRP is displayed. COMMAND ===> (F=DSCRP_FORM) SCROLL ===> PAGE
You can change the width, indent etc… with Forms
More on FORMS
See the output display in QMF
An Introduction to Mainframes - 149 - DB2 – Tips and Tricks
REPORT LINE 73370 POS 1 79
N N C N T EMPL EMPL DSCRP TEST D DSCRP INIT LST I PRTY CASE EST ABBR TEST RSLV DSCRP TEST NO DLVRY DESC +----+------+------+-----+------+------+------* 1
G 28445 1 PRODX - P35A697R-MISSING A COD ------* 1
G CLARK 28446 2 R2 02/28/2006 J MEMBER/C MEMBER DON' ------* 1
J ESTIMATED 28447 1 EMER - CHNG WRKF DEST TABLE F ------* 1
C SGRIMES 28448 1 R15 - STL EQPT CHG ------* 1
S BRYAN 28449 3 EMER 03/02/2006 CODE TABLE REQUEST ------* 1
M 28450 2 PRODX - PSI RATE REFUND PROCES J 28451 2 - ELEC PMCHG CD CHKER NE ------* 2
======28,449
*** END *** 1=Help 2= 3=End 4=Print 5=Chart 6=Query 7=Backward 8=Forward 9=Form 10=Left 11=Right 12= OK, FORWARD performed. Please proceed. COMMAND ===> SCROLL ===> PAGE
Here, there is a break on the N_TEST_CASE_NO and a count on N_EMPL_LST_RSLV. This can be obtained by specifying a form shown in the next page
An Introduction to Mainframes - 150 - DB2 – Tips and Tricks
FORM.MAIN T30831.DSCRP_FORM
COLUMNS: Total Width of Report Columns: 338 NUM COLUMN HEADING USAGE INDENT WIDTH EDIT SEQ ------1 N_EMPL_INIT_TEST 1 4 C 1 2 N_EMPL_LST_RSLV COUNT 1 14 C 2 3 I_DSCRP 1 10 L 3 4 C_DSCRP_PRTY_TEST 1 5 C 4 5 N_TEST_CASE_NO BREAK1 1 7 C 5 6 D_EST_DLVRY 1 10 TD 6 7 T_DSCRP_ABBR_DESC 1 40 C 7 8 T_DSCRP_DESC 1 240 C 8 *** END ***
PAGE: HEADING ===> FOOTING ===> FINAL: TEXT ===> BREAK1: NEW PAGE FOR BREAK? ===> NO FOOTING ===> BREAK2: NEW PAGE FOR BREAK? ===> NO FOOTING ===> OPTIONS: OUTLINE? ===> YES DEFAULT BREAK TEXT? ===> YES
1=Help 2=Check 3=End 4=Show 5=Chart 6=Query 7=Backward 8=Forward 9= 10=Insert 11=Delete 12=Report OK, T30831.DSCRP_FORM is displayed. COMMAND ===> SCROLL ===> PAGE
You can also change the width of a field to format the display. SUM, AVERAGE also can be used to format the output for numeric items.
To list all the forms, you can use LIST FORMS or LIST FORMS (OWNER =
Saving the output of a Query
The output of a query can be saved as a table name and you can use the same in another query instead of a table. This can be done by using the option SAVE DATA AS