Process Management Programmer's Guide 900 Series HP 3000 Computer Systems ABCDE HP Part No.
The information contained in this document is subject to change without notice. Hewlett-Packard makes no warranty of any kind with regard to this material, including, but not limited to, the implied warranties of merchantability or tness for a particular purpose. Hewlett-Packard shall not be liable for errors contained herein or for direct, indirect, special, incidental or consequential damages in connection with the furnishing or use of this material.
Printing History The following table lists the printings of this document, together with the respective release dates for each edition. The software version indicates the version of the software product at the time this document was issued. Many product releases do not require changes to the document. Therefore, do not expect a one-to-one correspondence between product releases and document editions. Edition Date Software Version First Edition November 1987 A.01.
Preface (32650-90023) is written for an experienced programmer who has a working knowledge of MPE/iX and is familiar with: A text editor At least one programming language Compiling, linking, and executing a program on MPE/iX Process Management Programmer's Guide This manual contains detailed instructions describing how you can improve the performance of your program when you use system intrinsics that take advantage of MPE/iX process management capabilities.
Contents 1. 2. Processes and Process Management What is a Process? . . . . . . . . Process Components . . . . . . Process Identi cation . . . . . . Life Cycle of a Process . . . . . . . Organization of Processes . . . . . System Processes . . . . . . . . The SESSION and JOB Processes The Command Interpreter Process User Processes . . . . . . . . . Managing User Processes . . . . . Managing a Session Programmatically . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3. Deadlock Considerations 4. Managing a Session Programmatically Creating a Session Programmatically . . . . . . . . Assigning the Programmatic Sessions Capability . . STARTSESS Description . . . . . . . . . . . . . Specifying a Terminal . . . . . . . . . . . . . . Specifying the Logon . . . . . . . . . . . . . . Session Creation . . . . . . . . . . . . . . . . Using STARTSESS in a Program . . . . . . . . . Using :STARTSESS in the Startup State Con gurator Aborting a Session Programmatically . . . . .
Tables 1-1. Process Management Tasks/Intrinsics . . . . . . . . . . . . . . . . .
1 Processes and Process Management In the MPE/iX family of computer systems, the process is the basic executable entity that competes for the resources managed by MPE/iX. The notion of many active processes sharing the resources of the computer system is fundamental to the e cient operation of the MPE/iX operating system. By sharing the CPU and system resources among multiple active processes, resource utilization is greatly increased and system throughput improved.
Process Identification MPE/iX assigns each process a unique Process Identi cation Number (PIN) when the process is created. Both you and the system can use the PIN to identify a process throughout its life span. When the process is nally deleted from the system, the PIN is released, and can be used again to identify another process. Life Cycle of a Process A process exists in di erent states according to its past and present status and its present requirements for system resources.
System Processes PROGEN, the Progenitor, is the rst process created during the initialization phase of MPE/iX. PROGEN creates child processes from a set of data speci ed at system con guration time. These child processes are system processes that provide parallel functions on behalf of the operating system. The system processes that perform operating system functions can each have their own structure of descendants (children, grandchildren, and so forth).
:RUN EDITOR.PUB.SYS HP32201A.07.17 EDIT/3000 WED, SEP 24, 1987 12:55 PM c HEWLETT-PACKARD CO. 1985 \ 4BREAK5 :RUN MYPROG.PUB.MYACCT ABORT? (YES/NO) NO COMMAND NOT ALLOWED IN BREAK. (CIWARN 986) : RUN MYPROG.PUB.MYACCT ABORT? (YES/NO) YES PROGRAM ABORTED PER USER REQUEST. : RUN MYPROG.PUB.MYACCT . . . (CIERR 989) Example 1-1. Attempting to Create Multiple Child Process from Your CI As illustrated in Example 1-1, you are restricted to creating only one child process at a time while in the CI.
Managing User Processes If you have standard MPE/iX capabilities (for example, IA, BA, SF), you can use many system intrinsics to access operating system features, but you are allowed only limited programmatic control over processes. For example, your program cannot use system intrinsics to create a new process. If you wish to design large and/or complex applications that use process management capabilities to full advantage, MPE/iX provides Process Handling (PH) as an optional capability.
Table 1-1.
Managing a Session Programmatically Normally, if you wish to create a session for yourself, you must be at a terminal and log on to the system by entering the :HELLO command, then pressing 4RETURN5 . A message is sent to the system SESSION process. SESSION directs a system JSMAIN process to allocate and initialize session resources for the new session. JSMAIN then create and activates a CI process.
2 Process Management Tasks This chapter explains how you can use MPE/iX intrinsics to: Create a new process Activate a suspended process Suspend an executing process Delay a process from executing Request a process break Delete a process Interrogate a process Pass information to a process Reschedule a process Provide communication between processes For complete descriptions of the intrinsics described in this chapter, refer to the MPE/iX (32650-90028).
Creating a Process (PH Capability Required) If your program has PH capability, it can call the CREATEPROCESS intrinsic or the CREATE intrinsic to create a child process. Both intrinsics direct MPE/iX to: Initialize resources Allocate a private data area (including a stack) Load the speci ed program into virtual memory Assign a Process Identi cation Number (PIN) Place the newly created child process in a suspended state.
BNAME ITEMNUMS ITEMS Passes the name of the program le the child process is to execute. Passes the value 3 in the rst element of the array indicating that load option information is passed in the rst element of the array ITEMS. The value 0 in the second element indicates the end of the option list. Passes the value 1 in the rst element of the array indicating that the calling process is to be reactivated when the child process is deleted.
Your program can only activate the parent process or a child process. Also, your program must have permission to activate the speci ed process (refer to the discussion of suspending a process). For example, only the parent process can activate a newly created child process. This is an example of an ACTIVATE intrinsic call: . . . SUSP := 2; CREATE (BNAME,,PIN,,FLAGS); ACTIVATE (PIN,SUSP); . . . The parameters speci ed in the example above are described below.
. SUSP := 3; RIN := 3; SUSPEND (SUSP,RIN); . . . The parameters speci ed in the example above are described below. SUSP Passes activation information. The value 3 speci es that the parent process and all child processes have permission to reactivate the process. RIN Passes a local RIN (3) that is unlocked when the process is suspended.
Requesting a Process Break During a session, your program can initiate a break programmatically with the CAUSEBREAK intrinsic. The CAUSEBREAK intrinsic performs the programmatic equivalent of pressing 4BREAK5 in a session. MPE/iX suspends the entire user process structure (below the Root CI process) and activates the Root CI.
Deleting a Process with TERMINATE Your program can call the TERMINATE intrinsic to delete itself. The following is an example of a TERMINATE intrinsic call: TERMINATE; MPE/iX deletes the process by following the algorithm described in \Deleting Processes". Deleting a Child Process with KILL (PH Capability Required) If your program has PH capability, it can call the KILL intrinsic to delete a child process.
The NUM parameter is transmitted as part of the abort message to the calling process's $STDLIST. You can use this number to assist you in determining the state of the calling process when the abort occurred. In a session, your Root CI remains active even after the entire program is aborted. In a batch job, the job terminates, unless the :CONTINUE command is in e ect. Interrogating Processes MPE/iX provides intrinsics that enable your program to interrogate MPE/iX about the status of other processes.
Determining Source of Activation (PH Capability Required) If your program has PH capability, it can call the GETORIGIN intrinsic to determine who activated it, the parent process or a child process.
Determining Process Information Your program can call the PROCINFO intrinsic to determine process management information. PROCINFO returns the same information as the GETPROCINFO intrinsic, as well as: The PIN of the calling process A value indicating the success or failure of the PROCINFO call, and, if unsuccessful, the nature of the error Some of the information available through PROCINFO requires that your program have PH capability.
Rescheduling a Process (PH Capability Required) If your program has PH capability, it can call the GETPRIORITY intrinsic to change its priority class or the priority class of a child process. A process is scheduled on the basis of a particular priority class when it is created.
3 Deadlock Considerations Simultaneous use of mail transmission, process suspension, and RIN-locking intrinsics throughout a process structure could result in a deadlock if the intrinsic calls are not synchronized properly. MPE/iX ensures that deadlock between di erent jobs/sessions cannot occur as long as none of the processes have Multiple RIN (MR) capability.
4 Managing a Session Programmatically This chapter describes how your program can exercise a limited form of control over interactive sessions on an MPE/iX-based computer system. Because an interactive session (or a job) is a process created and managed by the system, a user is restricted from being able to use process management intrinsics to create, manage, and delete sessions.
If the PS capability is not found when invoking STARTSESS, the intrinsic fails and the program is aborted. If the PS capability is not found when invoking :STARTSESS, the command fails and control returns to the CI.
Session Creation If STARTSESS/:STARTSESS is successful, a session is created at the terminal speci ed in the ldev . MPE/iX returns a successful status to STARTSESS/:STARTSESS , and the session or process that called STARTSESS/:STARTSESS can continue execution without having to wait for a carriage return from the target terminal. If you execute a :SHOWJOB command from another terminal prior to 4RETURN5 being pressed on the target terminal, MPE/iX displays the newly created session in EXEC* state.
program Create_Session (input, output); {This program demonstrates the use of the MPE/iX STARTSESS intrinsic to} {programmatically create sessions on specified terminals. This program} {prompts the user for the ldev, then creates a session for NOVICE.ACCT } {specifying the :NOWAIT option. When the user inputs a zero, the } {program ends. } const logon_string_size = 20; blank = ' '; var ldev :shortint; logonstring:packed array [1..
RUN HPMENU.PUB.SYS BYE *** This UDC is executed at each session logon when the STARTSESS program is run. It automatically places the user into the application speci ed in the :RUN command (in this case, HPMENU.PUB.SYS). Using :STARTSESS in the Startup State Configurator Example 4-1 illustrates how you can programmatically create sessions on speci ed terminals. However, the system must be up and running, and you must execute the program from a session you have already logged onto.
STARTUP STREAMS 10 ALLOW @.@;COMMANDS=REPLY ALLOCATE COBOLII.PUB.SYS LIMIT 4,16 JOBFENCE 4 OUTFENCE 5 *** WARMSTART STARTSESS 20;MGR.ACCT;HIPRI;NOWAIT STARTSESS 21;NOVICE.ACCT;NOWAIT STARTSESS 22;NOVICE.ACCT.NOWAIT *** COOLSTART STARTSESS 20;MGR.ACCT;HIPRI;NOWAIT STARTSESS 21;NOVICE.ACCT;NOWAIT STARTSESS 22;NOVICE.ACCT;NOWAIT STARTSESS 23;NOVICE.ACCT;NOWAIT *** Example 4-2.
Aborting a Session Programmatically Once your program has successfully created a session using the STARTSESS intrinsic, your program no longer has any control over that session, except to abort it using the ABORTSESS intrinsic. The newly created sessions runs as an independent system-managed process and is not a child process of the process that invoked STARTSESS.
JSNUM JSSTATUS Passes the system-de ned session number or job number of the process that is to be aborted. This value was returned by the STARTSESS intrinsic when you created the session you are now planning to abort. Returns status information about the success or failure of the intrinsic call.