Hordhac Semaphores gudaha Linux

Turjumaada maqaalka waxaa la diyaariyay ka hor bilowga koorsada "Maamulka Linux. Aasaasiga ah".

Hordhac Semaphores gudaha Linux

Semaphore-ku waa hannaan u oggolaanaya geeddi-socodyada tartamaya iyo dunta inay la shaqeeyaan kheyraadka la wadaago oo ka caawiya xallinta dhibaatooyinka is-dhexgalka ee kala duwan sida jinsiyadaha, xannibaadaha iyo dhaqan-xumada dunta.

Si loo xalliyo dhibaatooyinkan, kernel-ku waxa uu ka kooban yahay qalab ay ka mid yihiin mutexes, semaphores, calaamadaha iyo caqabadaha.

Waxaa jira saddex nooc oo semaphores:

  1. semaphore binary
  2. Tirinta semaphore
  3. Arrays semaphore (semaphore set)

Eeg heerka IPC

Amarradan soo socda ayaa loo isticmaali karaa in lagu helo macluumaadka ku saabsan xaaladda hadda jirta ee isgaadhsiinta hab-socodka dhex-dhexaadinta (IPC).

# ipcs
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 65536 root 600 393216 2 dest
0x00000000 98305 root 600 393216 2 dest
0x00000000 131074 root 600 393216 2 dest
0x00000000 163843 root 600 393216 2 dest
0x00000000 196612 root 600 393216 2 dest
0x00000000 229381 root 600 393216 2 dest
0x00000000 262150 root 600 393216 2 dest
0x00000000 294919 root 600 393216 2 dest
0x00000000 327688 root 600 393216 2 dest
------ Semaphore Arrays --------

key semid owner perms nsems

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

Qaabab semaphore firfircoon

Soo bandhig macluumaadka ku saabsan qaababka semaphore ee firfircoon.

# ipcs -s
------ Semaphore Arrays --------
key semid owner perms nsems

Qaybaha xusuusta la wadaago

Arag macluumaadka ku saabsan qaybaha xusuusta la wadaago ee firfircoon.

# ipcs -m
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 65536 root 600 393216 2 dest
0x00000000 98305 root 600 393216 2 dest

Xadka

kooxda ipcs -l waxay soo bandhigaysaa xusuusta la wadaago, semaphore iyo xadka fariimaha.

# ipcs -l
------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 4194303
max total shared memory (kbytes) = 1073741824
min seg size (bytes) = 1

------ 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

------ Messages: Limits --------
max queues system wide = 16
max size of message (bytes) = 65536
default max size of queue (bytes) = 65536

Xusuusta la wadaago

Amarka hoose wuxuu muujinayaa xusuusta la wadaago.

# ipcs -m
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 65536 root 600 393216 2 dest
0x00000000 98305 root 600 393216 2 dest
0x00000000 131074 root 600 393216 2 dest
0x00000000 163843 root 600 393216 2 dest
0x00000000 196612 root 600 393216 2 dest
0x00000000 229381 root 600 393216 2 dest
0x00000000 262150 root 600 393216 2 dest
0x00000000 294919 root 600 393216 2 dest
0x00000000 327688 root 600 393216 2 dest

Abuurayaasha Khayraadka

Amarku waxa uu soo bandhigay isticmaalaha iyo kooxda milkiilaha iyo abuuraha kheyraadka.

# ipcs -m -c

------ Shared Memory Segment Creators/Owners --------
shmid perms cuid cgid uid gid
65536 600 root root root root
98305 600 root root root root
131074 600 root root root root
163843 600 root root root root
196612 600 root root root root
229381 600 root root root root
262150 600 root root root root
294919 600 root root root root
327688 600 root root root root

Isticmaalka Qalabka IPC

Tusaalaha hoose, halbeegga -u Wuxuu soo bandhigayaa soo koobidda isticmaalka dhammaan qalabka IPC.

# ipcs -u

------ Shared Memory Status --------
segments allocated 9
pages allocated 864
pages resident 477
pages swapped 0
Swap performance: 0 attempts 0 successes

------ Semaphore Status --------
used arrays = 0
allocated semaphores = 0

------ Messages: Status --------
allocated queues = 0
used headers = 0
used space = 0 bytes

Marka adeegyada la joojiyo, semaphores iyo qaybaha xusuusta la wadaago waa in sidoo kale la tirtiraa. Haddii aan la saarin, tan waxaa la samayn karaa iyadoo la adeegsanayo amarka ipcrm, gudbinta aqoonsiga shayga IPC.

# ipcs -a
# ipcrm -s < sem id>

Waxa kale oo aad bedeli kartaa xadka semaphore adiga oo isticmaalaya sysctl.

# /sbin/sysctl -w kernel.sem=250

Hordhac Semaphores gudaha Linux

Source: www.habr.com

Add a comment