Réamhrá do Semaphores i Linux

Ullmhaíodh aistriúchán an ailt ar an oíche roimh thús an chúrsa "Riarthóir Linux.Basic".

Réamhrá do Semaphores i Linux

Meicníocht is ea semaphore a ligeann do phróisis agus snáitheanna iomaíocha oibriú le hacmhainní comhroinnte agus cabhraíonn sé le fadhbanna sioncrónaithe éagsúla a réiteach, mar shampla rásaí, sábhálacha agus mí-iompar snáithe.

Chun na fadhbanna seo a réiteach, tá uirlisí cosúil le mutexes, semaphores, comharthaí agus bacainní san eithne.

Tá trí chineál semaphores ann:

  1. Semaphore dénártha
  2. Semaphore á chomhaireamh
  3. Eagair semaphore (tacar semaphore)

Féach ar Stádas IPC

Is féidir na horduithe seo a leanas a úsáid chun faisnéis a fháil faoi staid reatha na cumarsáide idirphróisis (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

Eagair semaphore gníomhacha

Taispeáin faisnéis faoi eagair ghníomhacha seimeafóir.

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

Míreanna cuimhne roinnte

Féach ar fhaisnéis faoi mhíreanna gníomhacha cuimhne roinnte.

# 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

Teorainneacha

Foireann ipcs -l taispeánann cuimhne chomhroinnte, semaphore agus teorainneacha teachtaireachta.

# 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

Cuimhne roinnte

Taispeánann an t-ordú thíos an chuimhne roinnte.

# 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

Cruthaitheoirí Acmhainní

Taispeánann an t-ordú úsáideoir agus grúpa úinéara agus cruthaitheoir na hacmhainne.

# 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

Ag baint úsáide as Uirlisí IPC

Sa sampla thíos, an paraiméadar -u Taispeánann sé achoimre ar úsáid gach uirlis 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

Nuair a stoptar seirbhísí, ní mór semaphores agus míreanna cuimhne roinnte a scriosadh freisin. Mura mbaintear iad, is féidir é seo a dhéanamh ag baint úsáide as an ordú ipcrm, ag dul thar an aitheantóir oibiachta IPC.

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

Is féidir leat teorainneacha semaphore a athrú freisin ag baint úsáide as sysctl.

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

Réamhrá do Semaphores i Linux

Foinse: will.com

Add a comment