Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > S

setmemwindow(1M)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

setmemwindow — change window ID of running program or start program in particular memory window

SYNOPSIS

setmemwindow [-bcfjnov] [-i WinId] { -p pid | program [arg]... }

DESCRIPTION

setmemwindow is the command that changes the window ID of a running process or starts a specified program in a particular memory window.

If the -p option is specified with a nonzero pid, only the process's window ID is changed, and any value specified for program is ignored.

The executable program is only executed if the process ID pid is either 0 or unspecified.

Changing the window ID for the running process does not mean the process immediately attaches to or creates objects using that window. The targeted process does not begin using the window until it executes a new image.

setmemwindow, used as a wrapper for an existing executable, starts the program in the desired (see -i option below) memory window. In order to execute program, setmemwindow changes the window ID, forks a child and executes program in the child process. The default behavior of setmemwindow is to wait until program finishes. If -n is specified, the waiting for program is bypassed and setmemwindow exits immediately after forking the child.

If -c and -j are unspecified, the default behavior is to place the process into the window specified by WinId. If WinId exists, then the process is placed into that memory window. If no window exists with WinId, an unused window is allocated and associated with WinId. -c specifies the creation of a window. If the window already exists and -c is specified, the call fails. -j specifies the joining to an existing window. If the window does not exist and -j is specified, the call fails.

The -f option instructs the command to execute program even if setmemwindow is unable to change the process's window to the specified WinId. The failure to create a specific window may be the effect of the lack of available memory windows; that is, the underlying kernel:

  • Has not been configured with enough memory windows (exit status ENOMEM);

  • Was unable to allocate memory for a new window to meet this request (exit status ENOMEM); or

  • Does not implement the feature (exit status ENOSYS).

Options

-b

Create a memory window where both memory window quadrants use the same space ID. For SHMEM_MAGIC executables this generates two quadrants with the same space ID. Applications can use this to generate the appearance of larger contiguous shared memory ranges with a maximum of 2 gigabytes. For example, an application that generates a 1 gigabyte shared memory segment has that segment placed into the 2nd quadrant by default. If the application creates another 1 gigabyte segment that segment is placed in the 3rd quadrant. Both segments are contiguous virtually, allowing the application to treat the virtual range as if it were a contiguous 2 gigabyte segment.

This option only benefits SHMEM_MAGIC executables. They are the only type of executable format able to place shared objects in the 2nd quadrant.

-c

Create a window with ID WinId and attach the specified process to it. If WinId already exists the call fails.

-f

The default behavior for setmemwindow is to exit without executing the user specified program if the memory window cannot be set. The failure to set the memory window may be caused by:

  • The lack of enough memory windows in the system.

  • The memory windows feature is not implemented.

  • The request requires a new memory window be initialized and the system was not able to allocate the memory to do so.

  • A memory window with WinId could not be found in the attempt to join a memory window.

  • A memory window with the WinId was found in the attempt to create a memory window.

The -f option instructs setmemwindow to execute program whether the desired memory window was set or not. Obviously, using this option there is no guarantee program has been attached to the desired memory window and it is unclear in what memory window it is running. Using this option is strongly discouraged.

-i WinId

Specifies the desired memory window. WinId is a key to the desired memory window. WinId is a user specified value and should be one of the values contained in the file /etc/services.window.

Applications extract the user key from /etc/services.window according to a unique string contained in /etc/services.window, using the getmemwindow command. (See getmemwindow(1M) and services.window(4).)

The kernel tries to locate an existing window with WinId. If one is found, that window is used. If no window with WinId is found, an unused entry is located and assigned to WinId.

The value 0 for WinID is special. If specified, the process/program is placed into the default global window instead of a unique window with ID WinId.

If WinID is unspecified, the process and its children will run in a private memory window, and no other processes in the system can attach to this memory window. This memory window remains active until the process and its children terminate.

-j

Join an existing window with ID WinId. The specified process attaches to an existing memory window. If no entry exists the call fails.

-n

If program is executed, the default behavior is to waitpid() (see the wait(2) manual page) for the process to terminate. Specifying -n causes setmemwindow to exit after forking the child (that will execute program).

-o

Send the PID of the executed program to standard output. The message sent out is: setmemwindow:pid=dddd\n, where dddd is the decimal value of the PID.

-p pid | program [arg]...

Change the memory window for process pid, or start program in the specified memory window. If program has arguments (arg ...), they must also be specified.

If -p is unspecified or the value of pid is 0, the calling process has its window ID changed, and program is executed.

If a nonzero process pid is specified, only the window in that process is changed, and program is ignored.

-v

Execute in verbose (debug) mode.

Application Usage

Memory Windows helps alleviate the 1.75-gigabyte limitation on system-wide shared memory for 32-bit applications by allowing cooperating applications to configure their own 1-gigabyte window of shared resources.

The definition of a memory window is only available for 32-bit processes.

Note that memory windows allows the creation of more than 1.75 gigabytes of total system-wide shared memory, but it does not extend how much shared memory a single process can create. SHARED_MAGIC executables are still limited to 1.75 gigabytes.

HP-UX ships memory windows disabled. To enable memory windows, the kernel tunable parameter, max_mem_window, must be set to the desired number. max_mem_window represents the number of memory windows beyond the global default window. Setting max_mem_window to 2, for example, would produce a total of three memory windows, the default global window plus two user defined windows. Setting max_mem_window to 0 leaves only the default or global memory window.

There are two new commands and one file introduced by memory windows: setmemwindow, getmemwindow, and /etc/services.window file.

The /etc/services.window file maps a memory window application to a particular window ID. Using this central file allows applications to share memory windows, by using the same window ID, as well as avoid unintentional memory window collisions. See services.window(4) for more information.

The getmemwindow command is used to extract the window ID of a user process from the /etc/services.window file. The setmemwindow command starts a particular process in a memory window. A common usage of these commands is to extract a memory window ID with getmemwindow, which is then passed to setmemwindow to start a process with the given window ID.

Processes must be in the same window to share data. Processes wanting to share global data, such as shared memory or MAP_SHARED memory mapped files, must make sure all processes are in the same memory window. If processes in different memory windows wish to share data reliably, the creator of the data must take steps to guarantee the data is placed in a location accessible to all processes.

For more detailed information on memory windows, refer to the Memory Windows in HP-UX 11.0 White Paper.

RETURN VALUE

The exit value is 0 on success or a positive number on failure.

If -n is not specified, the value is the exit status of the executed program, obtained from the waitpid() system call.

EXAMPLES

Start the program myprog in a memory window extracted by the string myapp.

WinId=$(getmemwindow myapp) setmemwindow -i $WinId myprog arg1 arg2

Start the program myprog in a newly created memory window extracted by the string myapp.

WinId=$(getmemwindow myapp) setmemwindow -c -i $WinId myprog arg1 arg2

Start the program myprog in an existing memory window extracted by the string myapp.

WinId=$(getmemwindow myapp) setmemwindow -j -i $WinId myprog arg1 arg2

Start the program myprog in a private memory window. Only myprog and its descendents can access the window.

setmemwindow myprog arg1 arg2

WARNINGS

Programs using a memory window can access shared memory objects created by other programs using the same window (depending upon permissions). However, by default, programs using a memory window may not be able to access shared memory objects created by programs using other windows or those not using windows at all.

To enable access to a shared memory object across programs using different windows, or between those using windows and those not using windows, the program must specify special options when creating the object. See shmget(2) and mmap(2) for details.

AUTHOR

setmemwindow was developed by HP.

FILES

/etc/services.window

File containing applications' associated window IDs.

SEE ALSO

getmemwindow(1M), services.window(4).

Memory Windows in HP-UX 11.0 White Paper.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.