It-traduzzjoni tal-artiklu tħejjiet lejlet il-bidu tal-kors
Semaforu huwa mekkaniżmu li jippermetti li proċessi u ħjut li jikkompetu jaħdmu b'riżorsi kondiviżi u jgħin biex isolvi diversi problemi ta 'sinkronizzazzjoni bħal tiġrijiet, deadlocks u mġiba ħażina tal-ħajt.
Biex issolvi dawn il-problemi, il-kernel fih għodod bħal mutex, semaphores, sinjali u barrieri.
Hemm tliet tipi ta’ semafori:
- Semaforu binarju
- Semaforu tal-għadd
- Arrays tas-semafori (sett tas-semafori)
Ara l-Istatus tal-IPC
Il-kmandi li ġejjin jistgħu jintużaw biex tinkiseb informazzjoni dwar l-istat attwali tal-komunikazzjoni bejn il-proċessi (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
Arrays tas-semafori attivi
Uri informazzjoni dwar arrays tas-semafori attivi.
# ipcs -s
------ Semaphore Arrays --------
key semid owner perms nsems
Segmenti tal-memorja maqsuma
Ara l-informazzjoni dwar is-segmenti tal-memorja kondiviża attiva.
# 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
Limiti
Team ipcs -l
juri memorja kondiviża, semaforu u limiti tal-messaġġ.
# 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
Memorja maqsuma
Il-kmand hawn taħt juri l-memorja kondiviża.
# 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
Ħallieq tar-Riżorsi
Il-kmand juri l-utent u l-grupp tas-sid u l-kreatur tar-riżorsa.
# 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
Bl-użu tal-Għodod tal-IPC
Fl-eżempju hawn taħt, il-parametru -u
Juri sommarju tal-użu tal-għodod kollha tal-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
Meta s-servizzi jitwaqqfu, is-semafori u s-segmenti tal-memorja kondiviża jridu jitħassru wkoll. Jekk ma jitneħħewx, dan jista 'jsir bl-użu tal-kmand ipcrm, li jgħaddi l-identifikatur tal-oġġett IPC.
# ipcs -a
# ipcrm -s < sem id>
Tista 'wkoll tibdel il-limiti tas-semafori bl-użu sysctl
.
# /sbin/sysctl -w kernel.sem=250
Sors: www.habr.com