|HP-UX Reference > S
HP-UX 11i Version 3: February 2007
setmemwindow — change window ID of running program or start program in particular memory window
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:
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.
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.
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
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.