Function Processing System (FPS)¶
The Function Processing System (FPS) is milk's core
framework for managing configuration parameters, states,
and commands for compute units. FPS instances provide a
high-performance standardized interface directly in
shared memory.
See also: Streams · Process Info · Programmer's Guide · FPS Standalone Modes
1. Architecture and Location¶
An FPS instance creates a shared memory directory
structure typically residing under
/dev/shm/fps.<fps_name>.datadir/ and
/dev/shm/fps.<fps_name>.confdir/. This allows multiple
independent processes, CLIs, and GUIs to read and modify
a running module's behavior simultaneously without
overhead.
2. Key Features¶
-
Parameter Management: FPS maps standard C variables (like strings, integers, and floats) directly into shared memory. When a user updates a parameter via the CLI (e.g.,
milk-fpsCTRLor the module's script), the compute loop instantly sees the change without needing a restart. -
Process State Control: FPS inherently tracks compute unit states such as
run,stop,step, andconf. This allows standard utilities to instruct a running process to pause, take a single execution step, or gracefully shut down. -
CLI & TUI Integration: Standard utilities like
milk-fpsCTRLprovide a Text User Interface (TUI) to interact with FPS instances in real-time. This provides an instant "dashboard" for any correctly built compute module. -
Tmux Dispatch and Isolation: When an FPS process is launched standalone (usually using
milk-fpsexec-<name>,cacao-fps-deploy, or with the-tmuxflag), the command is wrapped and dispatched into its owntmuxsession. This provides complete fault isolation. If one component segmentation faults, it does not bring down the entire pipeline, and its terminal output can be easily examined for debugging.
sequenceDiagram
participant User as CLI User (or Deploy Script)
participant Tmux as Tmux Session
participant FPSData as /dev/shm/fps.* (Shared Config)
participant FPS as Standalone fpsexec process
User->>Tmux: _run_<module> -tmux
Tmux->>FPS: Execute Module Runloop
FPS->>FPSData: Sync State (run/stop/conf)
loop Real-time configuration
User->>FPSData: Change Parameter via fpsCTRL
FPSData-->>FPS: Synchronous Read
FPS->>FPS: Adapt Compute Behavior
end
3. Usage Utilities¶
To use FPS-enabled functions from the command line efficiently, the typical workflow is:
- Define functions and their requested FPS names in
fpslist.txt. - Generate command scripts using
fpsmkcmd. - Launch and manage them via
milk-fpsCTRL.
The fpslist.txt and fpsmkcmd workflow¶
Create a file named fpslist.txt to list the functions and their instance names:
| FPS Root Name | CLI Command | Optional Arguments |
|---|---|---|
fpsrootname0 |
CLIcommand0 |
|
fpsrootname1 |
CLIcommand1 |
optarg00 ... |
Then run milk-fpsmkcmd to automatically generate startup scripts for initialization and running (<fpsname>-confinit, <fpsname>-runstart, etc.).
milk-fpsCTRL¶
The primary TUI control tool is milk-fpsCTRL. For example, milk-fpsCTRL -m _ALL scans and manages all FPS instances defined in fpslist.txt.
4. Parameter Data Types¶
FPS natively supports multiple parameter forms and configurations:
ONOFF: Booleans (0/1)INT: Integer valuesFLOAT: Floating-point measurementsSTRING: Texts and pathsTIMESPEC: Specific timestamp mapping structuresSTREAMNAME: Name of a shared memory streamFILENAME: File path on disk
4.1. Common Parameter Flags¶
When creating parameters, you can apply flags to configure their behavior and GUI visibility:
FPFLAG_DEFAULT_INPUT: Standard interactive input parameter (combinesFPFLAG_ACTIVE,FPFLAG_USED,FPFLAG_VISIBLE,FPFLAG_WRITE,FPFLAG_WRITECONF,FPFLAG_SAVEONCHANGE,FPFLAG_FEEDBACK,FPFLAG_WRITESTATUS).FPFLAG_CLI_INPUT: Typically combined with default input.FPFLAG_MINLIMIT/FPFLAG_MAXLIMIT: Enforces min/max boundaries on the parameter.
For a module developer, integrating with FPS generally
entails filling out FPS_APP_INFO to register an
identity, defining FPS_PARAMS with an X-macro to bind
shared memory to local C references, and wrapping the
core math inside fpsexec().