SettingPriorityUnderLinux
Here are the step-by-step instructions to set up the goxpyriment group with those high-priority privileges.
Step 1: Create the Group¶
First, you need to create the group in the system database.
Step 2: Create the Limits Configuration¶
Linux stores these specific "privilege" rules in /etc/security/limits.d/. You should create a new file specifically for your group so it doesn't mess with other system settings.
- Open a new config file:
- Paste the following lines into the file:
- Save and Exit: Press
Ctrl + O, thenEnterto save, andCtrl + Xto exit.
Step 3: Add Yourself (and others) to the Group¶
Simply creating the group isn't enough; you have to tell Linux which users belong to it. Replace $USER with a specific username if you are adding someone else.
Step 4: Apply the Changes¶
Important: Linux only checks group memberships and limits when a user logs in.
- You must log out of your Linux session and log back in.
- Alternatively, you can run
su - $USERin your terminal to start a sub-shell with the new permissions for testing.
How to Verify it Worked¶
Once you’ve logged back in, you can verify that your Go program (or any process) will have these rights.
1. Check Group Membership:
Run the command groups. You should see goxpyriment in the list.
2. Check the Memory Lock Limit: Run this command to see your current "Max locked memory" limit:
If it saysunlimited, you are good to go!
3. Check Real-Time Priority: Run:
It should return50.
⚠️ A Friendly "Warning"¶
Since you are giving your code the ability to run at -20 niceness (the highest possible priority), a "busy loop" in your Go code (like for { } without a sleep) could potentially freeze your entire desktop.
Because your code is now more "important" than the mouse driver or the window manager, the OS won't interrupt your code to let you click "Stop." Always keep a terminal open with a top or htop window ready, or test your logic with lower priority first!