home *** CD-ROM | disk | FTP | other *** search
- @echo OFF
- cls
- ECHO ***************************************************************************
- ECHO * SAMPLE PROGRAM 02: SAMPLE02.C *
- ECHO * *
- ECHO * COPYRIGHT: *
- ECHO * ---------- *
- ECHO * Copyright (C) International Business Machines Corp., 1991,1992. *
- ECHO * *
- ECHO * STATUS: VERSION 1, RELEASE 0, MODIFICATION 0 *
- ECHO * *
- ECHO * DISCLAIMER OF WARRANTIES: *
- ECHO * ------------------------- *
- ECHO * The following [enclosed] code is sample code created by IBM *
- ECHO * Corporation. This sample code is not part of any standard IBM product *
- ECHO * and is provided to you solely for the purpose of assisting you in the *
- ECHO * development of your applications. The code is provided "AS IS", *
- ECHO * without warranty of any kind. IBM shall not be liable for any damages *
- ECHO * arising out of your use of the sample code, even if they have been *
- ECHO * advised of the possibility of such damages. *
- ECHO * *
- ECHO * ----------------------------------------------------------------------- *
- ECHO * *
- ECHO * Sample to demonstrate a multithread program *
- ECHO * *
- ECHO * This program demonstrates the multithread programming capability *
- ECHO * of the IBM C Set/2 compiler. *
- ECHO * *
- ECHO * This sample program creates one thread for each argument. Each *
- ECHO * thread prints "Hello world from thread n!" the number of times *
- ECHO * specified in the corresponding argument. For example *
- ECHO * *
- ECHO * SAMPLE02 2 4 6 *
- ECHO * *
- ECHO * creates three threads; the first thread displays "Hello" *
- ECHO * two times, the second thread displays "Hello" four times, *
- ECHO * and the third thread displays "Hello" six times. *
- ECHO * *
- ECHO * In operation, the program works in the following order: *
- ECHO * *
- ECHO * 1. Creates the requested number of threads *
- ECHO * 2. Waits until all threads have been created *
- ECHO * 3. Begins multithread execution and waits for completion *
- ECHO * *
- ECHO * NOTE: The program also requires the IBM TOOLKIT 2.0 headers *
- ECHO * *
- ECHO * File list: *
- ECHO * *
- ECHO * SAMPLE02.C - source code to create the .EXE file *
- ECHO * SAMPLE02.DEF - module definition file for SAMPLE02.C *
- ECHO * BUILD02D.CMD - command file to link the program dynamically *
- ECHO * BUILD02S.CMD - command file to link the program statically *
- ECHO ***************************************************************************
- PAUSE
- SETLOCAL
- echo ************************************************************************
- echo Call CSETENV.CMD to set up the IBM C Set/2 environment
- echo ************************************************************************
- :ENV
- IF NOT EXIST ..\..\BIN\CSETENV.CMD GOTO ERROR1
- CALL ..\..\BIN\CSETENV.CMD
- GOTO CHECK
- :ERROR1
- ECHO ERROR: Failed to locate CSETENV.CMD command file
- ECHO REMEDY: Verify that CSETENV.CMD is in the \BIN directory and try again
- PAUSE
- GOTO END
- :CHECK
- echo ************************************************************************
- ECHO Check that all required files exist
- echo ************************************************************************
- IF NOT EXIST ..\..\LIB\DDE4MBSI.LIB GOTO ERROR2
- GOTO EXEC
- :ERROR2
- echo ERROR: One or more libraries are missing
- echo REMEDY: Make sure that you have installed the correct libraries
- echo and try again
- PAUSE
- GOTO END
- :EXEC
- echo ***************************************************************************
- ECHO * Building program *
- ECHO * *
- ECHO * icc /c /Gd+ /Ge /Gm+ /Re /Se SAMPLE02.C *
- ECHO * *
- ECHO * compiler options: *
- ECHO * *
- ECHO * /c : perform compile only, no link *
- ECHO * /Gd+ : dynamically link the run-time library *
- ECHO * /Ge : build a .EXE file *
- ECHO * /Gm+ : use the multithread library *
- ECHO * /Re : the .EXE is compatible with the run-time environment *
- ECHO * /Se : allow the standard IBM C Set/2 extensions *
- ECHO * *
- echo ***************************************************************************
- icc /c /Gd+ /Ge /Gm+ /Re /Se SAMPLE02.C
- IF NOT ERRORLEVEL 1 GOTO LINK
- echo ERROR: Failed to compile SAMPLE02.C
- echo REMEDY: Make sure that you have installed the correct components,
- echo and try again
- PAUSE
- GOTO END
- :LINK
- echo ***************************************************************************
- ECHO * Linking program *
- ECHO * *
- ECHO * link386 /NOE /NOD /NOI SAMPLE02,,NUL,DDE4MBSI+os2386,SAMPLE02.def *
- ECHO * *
- echo * link options: *
- echo * *
- echo * /NOE - no extra dictionary *
- echo * /NOD - ignore default libraries *
- echo * /NOI - differentiate between cases *
- echo * NUL - do not create mapping file *
- echo * *
- echo * LIBRARIES: *
- echo * DDE4MBSI - Dynamically bound, multithread, standard library *
- echo * OS2386 - OS/2 import library *
- echo * *
- echo * SAMPLE02.DEF - module definition file *
- echo * *
- echo ***************************************************************************
- link386 /NOE /NOD /NOI SAMPLE02,,NUL,DDE4MBSI+OS2386,SAMPLE02.def;
- IF NOT ERRORLEVEL 1 GOTO RUN
- echo ERROR: Failed to create SAMPLE02.EXE
- echo REMEDY: Make sure that you have installed the correct components,
- echo and try again
- PAUSE
- GOTO END
- :RUN
- echo ************************************************************************
- ECHO Running SAMPLE02.EXE with 3 secondary threads
- echo ************************************************************************
- SAMPLE02 2 4 6
- PAUSE
- echo ************************************************************************
- REM Clean up files and environment
- echo ************************************************************************
- :CLEANUP
- IF EXIST SAMPLE02.EXE ERASE SAMPLE02.EXE
- IF EXIST SAMPLE02.OBJ ERASE SAMPLE02.OBJ
- :END
- ENDLOCAL