Linux – What are the semaphore arrays on Linux

ipclinux

I understand semaphores, but what are these semaphore arrays being used on my Linux box?

$ ipcs

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status      
0x00000000 327681     root      644        80         2                       
0x00000000 360450     root      644        16384      2                       
0x00000000 393219     root      644        280        2                       
...

------ Semaphore Arrays --------
key        semid      owner      perms      nsems     
0x4172d4f4 290914305  lazer     660        104       
0x3b87b970 291045378  lazer     660        104       
0xa97eb380 293928963  lazer     660        104       
0x1fde2040 294191108  lazer     660        104       

------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages    

$

Also, which OS resource are they guarding?

Best Answer

ipcs -i <SEMID> -s will give you more information on the specific sem array. E.g.

[me@home]$ ipcs -i 32769 -s

Semaphore Array semid=32769
uid=537  gid=85  cuid=537        cgid=85
mode=0600, access_perms=0600
nsems = 1
otime = Mon Sep 19 12:18:53 2011
ctime = Mon Sep 19 12:07:11 2011
semnum     value      ncount     zcount     pid
0          1          0          0          7548

Use the pid to figure out who's using it.