I'm not sure in regards to the type of facility that the guards I spoke to worked at. One was definitely a jail, so this was pre-conviction, don't know the security level. Essentially, it's an unspoken agreement between the guards and inmates. The guards allow certain things, the inmates don't cause trouble. Without an agreement like this, the guards are outnumbered and it's practically impossible to keep the peace. So I was told anyhow.
Motherjones had a reporter get a job as a prison guard. His experience was similar: if he doesn't play nice with the inmates they will make his life hell. This was at a private prison, so the under-staffing issue might be more pronounced, but the principle applies.