Jump to content

CPGuide - Program Execution Control

From EDM2
Revision as of 17:33, 27 March 2020 by Martini (talk | contribs)

Reprint Courtesy of International Business Machines Corporation, © International Business Machines Corporation

Control Program Programming Guide and Reference
  1. Introduction to the Control Program
  2. Control Program Functions
  3. Keyboard Functions
  4. Mouse Functions
  5. Video Functions
  6. Data Types
  7. Errors
  8. Debugging
  9. Kernel Debugger Communications Protocol
  10. Device I/O
  11. Dynamic Linking
  12. Error Management
  13. Exception Management
  14. Extended Attributes
  15. File Management
  16. File Names
  17. File Systems
  18. Generic IOCtl Commands
  19. Memory Management
  20. Message Management
  21. National Language Support
  22. Pipes
  23. Program Execution Control
  24. Queues
  25. Semaphores
  26. Timers
  27. Notices
  28. Glossary

Multitasking is the ability of OS/2 to manage the execution of more than one application at a time. A multitasking operating system, such as OS/2 enables users to run many applications simultaneously.

For the programmer, OS/2 supports two types of multitasking. An application can start other programs, in separate processes, that will execute concurrently with the application. These programs can be a new copy of the application, a related program that is designed to work with the application, or an unrelated program. Running multiple processes is the first type of multitasking provided for programmers.

Running multiple threads is the second type of multitasking supported by OS/2. OS/2 enables applications to run multiple threads of execution within the same process; separate activities can be multitasked within the application. An example of multiple-thread multitasking would be for the application to dispatch a separate subroutine to load a file from the disk, and have the subroutine execute at the same time the main program continues to monitor and respond to user input.

This chapter describes processes, threads, and sessions, and the OS/2 functions used to create and manage them. Additionally, there is a section describing CPU scheduling.

The following topics are related to the information in this chapter:

  • Memory
  • Semaphores
  • Queues
  • Pipes
  • Exception handling
  • Debugging

About Program Execution Control-Thread, Processes, and Sessions

Threads

Processes

Creating Processes

Process Termination

Process Exit Lists

Multitasking with Threads and Multitasking with Processes

Sessions

Creating Sessions

Child Session Control

Child Session Termination

About CPU Scheduling

Priority Classes

Priority Levels

Priority Guidelines

Dynamic Priority Alteration

Altering the Size of the Time Slice

Using Processes

Starting a Child Process

Starting an Asynchronous Child Process

Starting a Background Process

Setting the Command Line and Environment for a Child Process

Changing the Priority of a Process

Obtaining Information about Child Processes

Waiting for a Child Process to End

Ending the Current Process

Terminating a Process

Creating an Exit Lis

Using Threads

Creating a Thread

Obtaining Information about a Thread

Changing the Priority of a Thread

Suspending the Current Thread

Suspending and Resuming Execution of a Thread

Entering Critical Sections

Waiting for a Thread to End

Ending the Current Thread

Ending a Thread

Using Sessions

Starting a Session

Controlling the Execution of Child Sessions

Setting User Selectability of a Child Session

Binding Child Sessions to Parent Sessions

Switching a Session to the Foreground

Terminating a Session