Email Address Password
Remember Me

Or Create a (Free) Account.
2004JanFebMarAprMayJunJul Aug Sep Oct Nov Dec
2005 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2006 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Oct Oct
2007JanFebMarAprMayJunJulAugSepOctNovDec2007
2008JanFebMarAprMayJunJulAugSepOctNovDec2008
2009JanFebMarAprMayJunJulAugSepOctNovDec2009
2010JanFebMarAprMayJunJulAugSepOctNovDec2010
2011JanFebMarAprMayJunJulAugSepOctNovDec2011
2012JanFebMarAprMayJunJulAugSepOctNovDec2012
2013JanFebMarAprMayJunJulAugSepOctNovDec2013
2014JanFebMarAprMayJunJulAugSepOctNovDec2014

Wed 5th Nov 2014 @ 16:54 2014: Linux Kernel Semaphores

Semaphores are a tunable in the Linux kernel, but they're a bit more awkward than some, just because it's a single tunable which contains 4 different variables, and I for one can never remember which is which.

The Red Hat 5 documentation has a great article about kernel semaphores which explains it all very clearly, including the names. I'll just add the comment about what they are all for.


$ cat /proc/sys/kernel/sem
250 32000 32 128

These are SEMMSL, SEMMNS, SEMOPM and SEMMNI respectively. As the article states, "ipcs -ls" gives you these, with a description:


# ipcs -ls
------ Semaphore Limits --------
max number of arrays = 128
max semaphores per array = 250
max semaphores system wide = 32000
max ops per semop call = 32
semaphore max value = 32767


Which gives us this handy table - where "Index" is the order in which they appear in the kernel.sem variable:




VariableIndexDescription
SEMMSL1Max Semaphores Per Array
SEMMNS2Max Semaphores System Wide
SEMOPM3Max Ops Per Semop Call
SEMMNI4Max Number of Arrays


To change any variable, you have to update all four. For example:


# sysctl -w kernel.sem="250 32000 100 128"
... or
# echo "250 32000 100 128" > /proc/sys/kernel/sem
... or
# echo "kernel.sem = 250 32000 100 128" >> /etc/sysctl.conf
# sysctl -p

Post a Comment               

Steve's urandom blog
Share on Twitter Share on Facebook Share on LinkedIn Share on Identi.ca Share on StumbleUpon
My Shell Scripting Book:
    Shell Scripting, Expert Recipes for Linux, Bash and more
is available online and from all good booksellers:


DefectiveByDesign.org