3dDeconvolve on FreeBSD
These instructions are tested on FreeBSD 5.x and 6.x. They may also work on other versions, but you'll need to verify this for yourself.Running 3dDeconvolve with multiple jobs requires the use of shared memory. The default shared memory limit of 32 megabytes should be enough for most analyses. However, it may be necessary to increase the limit for large analyses. The examples below demonstrate how to double it for FreeBSD 5.x:
To find out your current limits, type:
sysctl -a | grep shm
Method 1: Rebuild the kernel
This method is pretty simple, but rebuilding the kernel can be time-consuming, especially when rebuilding for the first time on an older machine. However, if you're rebuilding the kernel anyway for some other purpose, this is a good way to go, since all your kernel mods will be conveniently stored in one place. It's also a good thing to learn, since rebuilding the kernel is still a necessary for some things. Be sure to get your ducks in a row before rebuilding - it's annoying to have to do it again because you forgot something!The SHMMAX kernel variable, which is what we are aiming to increase, is computed as SHMALL * PAGESIZE (4096 by default) at boot time. Hence, we will increase SHMALL in the kernel. It may also be helpful to increase SHMSEG, although it isn't generally necessary for typical fMRI analyses.
- cd /usr/src/sys/i386/conf
- cp GENERIC <file>
- Add the following (along with your other changes) to /usr/src/sys/i386/conf/<file>
SHMALL=16384 SHMSEG=256 (optional)
- cd /usr/src
- make buildkernel KERNCONF=<file>
- make installkernel KERNCONF=<file>
- shutdown -r now
Method 2: Tweak kernel variables without building a new kernel
This is the quick method. Some kernel variables can be changed without even rebooting, while others can only be changed at boot-time. Fortunately, shmmax can be changed without rebooting, so you can play with it a little to determine just how big it needs to be for your 3dDeconvolve jobs.
- Run the following commands:
sysctl kern.ipc.shmall=16384 sysctl kern.ipc.shmmax=67108864Note that we must manually change SHMMAX here, since it will not automatically be recomputed when changing SHMALL with sysctl. It is computed from the kernel's compiled-in SHMALL value only at boot time. After that, it's up to us to keep them in sync. Make sure that you set shmmax to shmall * pagesize.
- To make these changes survice a reboot, add the following to /etc/sysctl.conf.
kern.ipc.shmall=16384 kern.ipc.shmmax=67108864The SHMSEG variable is read-only in FreeBSD, so it cannot be changed using sysctl. The default value of 128 should be sufficient for most purposes, however. It can be set at bootup by adding the following to /boot/loader.conf:
kern.ipc.shmseg=256