From: savolainen_p@kulminator.salcom.fi (Pekka Savolainen, Salcom Finland)
Newsgroups: vmsnet.internals
Subject: Re: How to force a process into one CPU on a 6640?
Date: 24 Jan 93 11:37:35 +0200
Reply-To: Pekka.Savolainen@Salcom.Fi
Organization: Salcom Finland, Jyvaskyla Finland


In article <1993Jan24.003820.13857@rks.se>, vaxmith@rks.se writes:
> 
> I have a small but maybe a littlebit tricky question.
> I want to force some processes in a 6640 to run on only one and always the 
> same processor. Is this possible and if so, can someone explain how or 
> include an MAR-example of how to do it. I can't relink the images so it has 
> to be a utility that can change the PCB when the process is running.


Included, please find sys$examples:bind_read_me.txt
In the same location you'll also find bind_main.exe and bind.cld.
This is exactly what you want. This example came with VMS 5.5-2, I think.
If you don't have 5.5-2, please drop me a message, so I'll get
the files to you.

> Thanks
> 
> -- Michael
> 

Pekka


------------------------ c u t ----------------------------------

/****************************************************************************
*									    *
*  COPYRIGHT (c) 1992 BY                     				    *
*  DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASSACHUSETTS.		    *
*  ALL RIGHTS RESERVED.						            *
* 									    *
*  THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED    * 
*  ONLY IN  ACCORDANCE WITH  THE  TERMS  OF  SUCH  LICENSE  AND WITH THE    *
*  INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR  ANY  OTHER    *
*  COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY    *
*  OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF  THE  SOFTWARE IS  HEREBY    *
*  TRANSFERRED.							            *
* 									    *
*  THE INFORMATION IN THIS SOFTWARE IS  SUBJECT TO CHANGE WITHOUT NOTICE    *
*  AND  SHOULD  NOT  BE  CONSTRUED AS  A COMMITMENT BY DIGITAL EQUIPMENT    *
*  CORPORATION. 							    *
* 									    *
*  DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE  OR  RELIABILITY OF ITS    *
*  SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.		    *
* 									    *
*									    *
****************************************************************************/

/***************************************************************************** 
*
*  AUTHOR:
*
*	Nasser Abbasi, VMS Engineering
*
*  CREATION DATE:  FEB 10, 1992
*
*  VAX/VMS Version Supported:
*
*	These files should be compiled, linked and run on VMS V5.2 and above
*	only since support for Process Affinity was not added until VMS 5.2.
*
*  FACILITY:  BIND command
*
*	This program implements the BIND command.
*
*	The BIND command is the user interface to the VMS scheduler entry
*	points SCH$REQUIRE_AFFINITY and SCH$RELEASE_AFFINITY. These two
*	scheduler routines are described in detail in the "VAX/VMS
*	Internals and Data Structures" book, V5.2, pages 288-290.
*
*	The function of the BIND command is to make a process execute on
*	a specific CPU in an SMP configuration. In other words, to give a
*	process a permanent affinity for a specific CPU. The command also has a
*	REMOVE qualifier that can be used to remove process permanent affinity.
*
*	The BIND command syntax is:
*
*	    BIND [ /CPU=<cpu> ] [ <name> ]
*	         [ /ID=<pid> ]
*		 [ /REMOVE ]
*
*	where:
*	    <name>  Process name of the target process.
*	    <pid>   Process identifier (PID) of the target process (specified as
*		    a hexadecimal string).
*	    <cpu>   The number of the CPU for which affinity is to be required
*		    (specified as a decimal integer in the range 0 thru 31).
*
*	Items enclosed in square brackets are optional.
*
*	Either /CPU or /REMOVE must be specified (but not both).
*
*	The PID and process name cannot be specified at the same time.  
*
*	If you do not specify a PID or a process name, then the calling process
*	is assumed.
*
*	For example:
*	    
*	    $ BIND /CPU=2		! Binds this process to CPU 2
*	    $ BIND /CPU=2 /ID=5B	! Bind a process to CPU 5
*	    $ BIND /CPU=0 MY_PROCESS	! Bind a process to CPU 0
*	    $ BIND /REMOVE		! Remove affinity for current process
*	    $ BIND /REMOVE /ID=5B	! Remove affinity for specified PID
*	    $ BIND /REMOVE MY_PROCESS	! Remove affinity for specified process
*
*	Before using the BIND verb, it must be defined as follows:
*
*	    $ SET COMMAND BIND		! BIND.CLD is part of the kit
*
*	BIND.CLD expects the image to be located in SYS$EXAMPLES. You will have
*	to edit	the CLD file if the image is located in some other directory.
*
*	To find what CPU's you have in your SMP system, and to see any existing
*	process affinities, use the SHOW CPU command:
*
*	    $ SHOW CPU /FULL
*
*	NOTE:	BIND removes any previous affinity for a CPU before requiring
*		affinity for a different CPU.
*
*
*  Example of using BIND and $SHOW CPU/FULL
*  ----------------------------------------
*
*	$ bind /cpu=8 /id=41
*	$ show cpu /full
*   
*	CHOLLY, a VAXstation 3540
*	Multiprocessing is ENABLED. Streamlined synchronization image loaded.
*	Minimum multiprocessing revision levels: CPU = 3 FBIC = 1.
*	Default CPU capabilities:
*		QUORUM RUN
*	Default process capabilities:
*		QUORUM RUN
*   
*	PRIMARY CPU = 08
*   
*	CPU 08 is in RUN state
*	Current Process: *** None ***
*	Revision levels: CPU = 5 FBIC = 1.
*	Capabilities of this CPU:
*		PRIMARY QUORUM RUN
*	Processes which can only execute on this CPU:
*		MY_APPL          PID = 00000041  Reason: Bound to this CPU
*   
*	$!
*	$! Now we remove the process's affinity for CPU 8
*	$!
*	$ bind /remove /id=41
*	$ show cpu /full
*   
*	CHOLLY, a VAXstation 3540
*	Multiprocessing is ENABLED. Streamlined synchronization image loaded.
*	Minimum multiprocessing revision levels: CPU = 3 FBIC = 1.
*	Default CPU capabilities:
*	    QUORUM RUN
*	Default process capabilities:
*	    QUORUM RUN
*   
*	PRIMARY CPU = 08
*   
*	CPU 08 is in RUN state
*	Current Process: *** None ***
*	Revision levels: CPU = 5 FBIC = 1.
*	Capabilities of this CPU:
*		PRIMARY QUORUM RUN
*	Processes which can only execute on this CPU:
*	    *** None ***
*
*
*  WARNING:
*  --------
*  Do not use BIND /REMOVE to remove affinity for a process that you did not
*  explicitely set via a previous BIND.
*
*
*  PRIVILEGES NEEDED:
*  ------------------
*  CMKRNL is required to use the BIND program. You also need access to the
*  process you wish to affect; GROUP or WORLD privilege is needed to affect
*  processes in your group or outside.
* 
*
*****************************************************************************/