Linux - Interview Questions #1

1. How many threads in process


/* The default maximum number of threads is set to a safe
 * value: the thread structures can take up at most half
 * of memory.
 */
Method 1 :
]$ cd /proc/sys/kernel
]$ cat threads-max
127752

Method 2: 

sysctl kernel.threads-max
kernel.threads-max = 127752


Method 3 :
max_threads = mempages / (Stack size  * THREAD_SIZE / PAGE_SIZE);
             
mempages - total virtual memory
Stack Size - 8 MB
Thread size - 8192
Page size -  default page size 4096

2. How many processes in a system  or how many child processes we can create under parent process

sysctl kernel.pid_max
default is 32768

note : init is the default process

3. How many inodes in a linux system  

- 4096

4. Default stack size - 8 MB - 8192


 Eg:  ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 20   ===========>
file size               (blocks, -f) unlimited
pending signals                 (-i) 16382
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) unlimited
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited


Comments