#pragma alloc_text(PAGE, foo)
void foo() { }
This code is usually used in device drivers.
The foo function will be swapped whenever system needs.
Questions.
User mode programs are swapped by default. It is unusual that you would need something else. Sounds like a device driver requirement to be resident to handle interrupts or such things. User mode programs don't do that.