# shpstat command

The shpstat BASIC program examines or
changes the status of shared BASIC programs that have been compiled
with FlashBASIC.

**For Windows:**Not Supported, use the D3 File Manager
to view the BASIC code.

The default behavior of shpstat is to list the status of all FlashBASIC programs currently running
in shared memory. These statistics display:

| Block | Memory block number. |
| --- | --- |
| Usage | Total number of users currently executing the program. |
| Size | Total size (in bytes) of the memory block. |
| Name | FlashBASIC program name. If the memory block is available, this column displays (free). |
At the end of the listing, these statistics display:

| Free | Total free space in shared program memory. Initially, this number should be slightly smaller than the number specified in the pick0 configuration file. A program requires a contiguous block of memory to load and free space may become fragmented. Therefore, a given program may not load even though the total amount of free space seems sufficient. |
| --- | --- |
| Max Free | Largest contiguous free block available to the system. Since FlashBASIC programs must be loaded into a single block, this indicates the maximum size of a program that can be accommodated at the present moment. |
| Used | Total number of bytes used by all shared loaded modules. Use this to determine the amount of shared FlashBASIC space required. Initially, the machine should be booted with a large shared memory space, then brought up to normal usage. The total shared memory may then be examined. Then, shut down the machine, resize the basic option in the pick0 file accordingly, and reboot. The basic shared memory segment should now be properly sized for your system. |
If shpstat is invoked with the l option,
the list displays interactively with these added options:

| | Scrolls forward one page. |
| i | Initializes shared program memory. This should be used only in the event of serious problems. It completely cleans out shared program memory, causing any users currently executing within it to abort. |
| k | Kills a module. This option is used to free a module from memory if no one is currently using it, to free up some shared space. Any users executing a module which is killed, receives the message undefined behavior, which could involve aborting. |
| q | Quits the program. |
| r | Refreshes the screen to reflect the current memory status. |
| s | Sets the sleep period in between updates. Smaller sleep times gives a more accurate view of system performance, but also uses more resources. |
The program displays some useful statistics at the bottom
of the screen:

| Current Page | Displays part of the program list that is currently being displayed. |
| --- | --- |
| Total Number of Pages | Number of screens the entire list takes. The are used to scroll through the pages. |
| Sleep Time | Current sleep period in seconds. |
To reduce fragmentation, the sticky programs start loading
at the high end of shared memory, while nonsticky programs load at
the bottom. Often used programs can be compiled with the k option to make them sticky.

```
shpstat {(options)}
```

## Parameter(s)

| options | i | Initializes the entire shared program status area. This should be used only in case of emergencies. It causes all programs running in the shared area to abort. When used with this option, shpstat clears the memory and completes. No status information displays. |
| --- | --- | --- |
| l{number} | Loops on displaying status information. This repeatedly updates the status information displayed on the screen. The default time between updates is 5 seconds. The l option may be followed by a number to override the default delay time between loops. | |
| p | Directs the output to the system printer, via the spooler. | |
| s | Suppresses detail output when used without the (l option. | |
| z | Zaps shared program memory. This is a more powerful version of the i option. | |
CAUTION: The z and i options can cause other users to abort and should be used with caution.

## Example(s)

Causes the status program to
redisplay the current status of shared programs every second. This
setting causes a very noticeable drain on system performance and should
only be used when tuning or if problems occur.

```
shpstat (l1
```
Completely reinitializes memory. This may be used if several
processes running shared code have aborted abnormally, and the shared
memory table seems corrupted. Signs of corruption include long wait
times when loading programs, and issuing a shpstat command with no options seems to hang indefinitely.

```
shpstat (i
```

```
shpstat

Block Usage Size Name
1 1 106k report.bp eep.help
2 1 15k report.bp eep.security
3 1 3k report.bp btree.root
4 1 8k cmarc.library cbw.open
5 1 18k cmarc.library cbw.place
6 1 7k cmarc.library cbw.box
7 1 27k report.bp eep.format.doc
8 2,374k (free)
Free: 2,374k Max Free: 2,374k Used: 185k
```

## See also

- [run command](https://d3codex.com/tcl/run-command/)
- [syschk command](https://d3codex.com/tcl/syschk-command/)
- [term command](https://d3codex.com/tcl/term-command/)

---
Source: https://d3codex.com/tcl/shpstat-command/ - part of the D3Codex reference.
