terça-feira, janeiro 31, 2017

[linux] Semáforos e threads

Pesquisando o funcionamento de semáforos e threads no Linux...

Semáforos



https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Tuning_and_Optimizing_Red_Hat_Enterprise_Linux_for_Oracle_9i_and_10g_Databases/sect-Oracle_9i_and_10g_Tuning_Guide-Setting_Semaphores-Setting_Semaphore_Parameters.html

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

linux ~ # ipcs -l

------ Messages Limits --------
max queues system wide = 32000
max size of message (bytes) = 8192
default max size of queue (bytes) = 16384

------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 18014398509465599
max total shared memory (kbytes) = 18014398442373116
min seg size (bytes) = 1

------ Semaphore Limits --------
max number of arrays = 32000
max semaphores per array = 32000
max semaphores system wide = 1024000000
max ops per semop call = 500
semaphore max value = 32767


3.3 - Set them ?

In the file, /etc/sysctl.conf

kernel.sem = 2200 6400 200 25
Where:

kernel.sem = SEMMSL SEMMNS SEMOPM SEMMNI
Then reboot or run this command:

# /sbin/sysctl -p


Threads

http://stackoverflow.com/questions/344203/maximum-number-of-threads-per-process-in-linux

We can see the maximum number of threads defined in the following file in linux

# cat /proc/sys/kernel/threads-max

(OR)

# sysctl -a | grep threads-max

To set permanently,

# vim /etc/sysctl.conf

and add line:

kernel.threads-max = "value"


http://unix.stackexchange.com/questions/892/is-there-a-way-to-see-details-of-all-the-threads-that-a-process-has-in-linux

The classical tool top shows processes by default but can be told to show threads with the H key press or -H command line option.
                                                                                       
top - 17:04:05 up 1 day, 12:13,  1 user,  load average: 0,00, 0,02, 0,00
Threads: 512 total,   1 running, 511 sleeping,   0 stopped,   0 zombie

Nenhum comentário: