Jump to content

SMPProgAdd - View and Set Program Type For Executable File (MARKEXE)

From EDM2

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

SMP Programming Addendum
  1. How to Use the SMP Programming Addendum
  2. Introduction to OS/2 Warp Server Version 4 Advanced
  3. Platform Specific Drivers (PSDs)
  4. High Memory Support
  5. Raw File System
  6. Processor Management and Performance Functions
  7. Application Considerations
  8. Device Drivers In OS/2 Warp Server for SMP
  9. New Device Helper (DevHlp) Routines
  10. Kernel Debugger
  11. The ICAT Debugger
  12. Software Trace Facility (STRACE)
  13. View and Set Program Type For Executable File (MARKEXE)
  14. Data Types
  15. Errors
  16. Generic IOCtl Commands
  17. Sample Source Code for a PSD
  18. Comments, Please!
  19. Glossary
  20. Notices

The MARKEXE program enables you to view and set the program type for an executable file. The program type identifies the OS/2 sessions in which a program can run.

For applications running on OS/2 Warp Server for SMP, MARKEXE enables you to set the MPUNSAFE bit, which forces the application to always run in uniprocessor mode. See Requirements for Multi-Processing for information on when to set the MPUN profitable bit.

Use MARKEXE with the OS/2 Linear Executable Linker (LINK386) or the OS/2 Segmented Executable Linker (LINK) to change or set the program type of programs you have created and to set or unset the MPUNSAFE bit.

You can set DLL initialization and termination and also enable long file name support. When using LINK386, you can set DLL initialization and termination; long file name support is already set. When using LINK, you can set DLL initialization and long file name support.

Command-Line Syntax

MARKEXE uses the following syntax:

MARKEXE [/?] [FORCE] [NO] [option] filename...

Filename is a file name or a list of file names. Global file-name characters (*.EXE) also can be used. For descriptions of the above terms, see Syntax Definitions. If no option is given, DISPLAY is assumed.

Typing MARKEXE /? at the command line displays the appropriate copyright statement along with a list of options:

DISPLAY         - display status of flags
DLLINIT         - per-process initialization
DLLTERM         - per-process termination
WINDOWAPI       - window api (PM application)
WINDOWCOMPAT    - window compatible application
NOTWINDOWCOMPAT - not window compatible application
UNSPECIFIED     - unspecified application type
LFNS            - long file name support
MPUNSAFE        - multi-processor unsafe application

Syntax Definitions

MARKEXE has the following keywords, options, and program types. You can also specify any number of files to be viewed or marked.

KEYWORDS

  • FORCE Marks the executable file with OS/2 as the target operating system even though the file was marked for another operating system. Using FORCE might produce internally inconsistent executable files.
  • NO Sets the command to the opposite condition. This keyword does not apply to the DISPLAY option or any of the Program Type options.

OPTIONS

  • DISPLAY Displays the application type in a message; does not make any changes. (This is the default option.)
  • DLLINIT Sets per process initialization for the dynamic link library.
  • DLLTERM Sets per process termination for the dynamic link library. (Use with LINK386 only.)
  • LFNS Enables support of long file names. (Use with LINK only.)
  • MPUNSAFE Marks the application as unsafe for running in a multi-processor environment.

Note: Only one option may be entered on the command line.

PROGRAM TYPES

MARKEXE does not modify the file if the executable file's program type is the same as the requested type. It displays a message instead.

  • WINDOWAPI The application is a Presentation Manager application and can run in the Presentation Manager session only.
  • WINDOWCOMPAT The application can run in a Presentation Manager window or in a full-screen session.
  • NOTWINDOWCOMPAT The application must run in an OS/2 full-screen session.
  • UNSPECIFIED The application type is not known. By default, the OS/2 operating system will force the program to run in a full-screen session.

Note: Specifying an incorrect program type might cause undesirable results when you try to run that program. For example, do not change a WINDOWCOMPAT program to WINDOWAPI.

Only one program type may be entered on the command line.

Viewing Program Type

To display the program type of an executable file without changing the file, specify only a file name, omitting an option:

MARKEXE filename.exe

Example

To view the program type of MYPROG.EXE, type the following:

MARKEXE myprog.exe

MARKEXE displays the type in a message that looks like this:

myprog.exe: OS/2 1.x, WINDOWCOMPAT, LFNS

Setting Program Type

To set the program type of an executable file, specify one of the program types. More than one executable file can be set to the same program type on a single command line:

MARKEXE type filename.exe another.exe

Examples

To set WINDOWCOMPAT as the program type of MYPROG.EXE, type:

MARKEXE WINDOWCOMPAT myprog.exe

To set WINDOWAPI as the program type of several executable files, type:

MARKEXE WINDOWAPI marion.exe alex.exe

Requirements for Multi-Processing

The following should be considered before running an application in multi-processor mode:

  • An application or associated subsystem must not use the 'INC' instruction as a semaphore without prepending a 'LOCK' prefix. On a UniProcessor (UP) system this instruction can be used as a high-performance semaphore without calling any other operating system service if the semaphore is free and when the semaphore is clear and there are no waiters for the semaphore. Because the INC instruction cannot be interrupted once started, and because the results would be stored in the flags register which are per thread, then it could be used safely as a semaphore.
  • In an OS/2 Warp Server for SMP environment, this technique will not work because it is possible that two or more threads could be executing the same INC instruction, receiving the same results in each processor's or thread's flag register and thinking that they have the semaphore.
  • A 486 or greater instruction such as CMPXCHG has the same problem as above if a 'LOCK' prefix is not prepended before the instruction.
  • An application or associated subsystem which relies on priorities to guarantee execution of its threads within a process will not work in OS/2 Warp Server for SMP.
  • For example, an application may have a time-critical and an idle thread, and may assume that while the time-critical thread is executing the idle thread will not get any execution time unless the time-critical thread explicitly yields the CPU. In an OS/2 Warp Server for SMP environment it is possible that both the time-critical and the idle threads are executing simultaneously on different processors.

The above compatibility requirements apply only to multi-threaded applications, and therefore do not apply to DOS and WINOS2 applications. However, you are strongly encouraged to write 32-bit multi-threaded applications for better performance and portability on OS/2 Warp Server for SMP.

Given the possibility that some set of applications may use one of these techniques, OS/2 Warp Server for SMP provides a mechanism that allows these multi-threaded applications to execute in UP mode. UP mode permits only one thread of that process to execute at a time. That thread could execute on any one of the available processors.

MARKEXE, described in View and Set Program Type For Executable File (MARKEXE), is used to mark an executable file as uniprocessor only. When an executable file that has the uniprocessor mode flag set is loaded, OS/2 ensures that only one thread of that process will ever execute at a time. Multiple uniprocessor only processes may be active in the system at the same time, but only one thread from each process may be active at a time.