서버 아키텍처 이해를 위한 프로세스와 쓰레드
TRANSCRIPT
PowerPoint
Process, Thread, IO Model #1
Why? / low level
CGI mod_php, mod_python ? DBMS apache server pool DB Connection pool web ?
([email protected])http://lesstif.com, https:/github.com/lesstif 5 http://wikibook.co.kr/laravel-5-programming/ https://github.com/lesstif/web-service-hardening
Program - OS
5
Program - gcc o a.out a.c a.out
6
Process OS
7
Process - Process ID, process group ID, user ID, and group ID Environment, Working directory Stack, Heap File descriptors Signal handler Shared libraries Inter-process communication tools (message queues, pipes, semaphores, shared memory).
8
9
10
Process - - #1
fork system call
11
Process - - #2 fork fork OS COW(Copy on write)
12
Process - - #3 fork (Ex: DBMS) fork
13
Process - IPC(Inter Process Communication), Socket, Pipe ipcs IPC . ( ) Process Context switching
14
Process FAQ - #1 ? init daemon(PID: 1) . (orphan process) Kernel init
15
Process FAQ - #2 ? SIGCHLD wait wait process table zombie, defunct process
16
A1. cgi mod_php cgi php httpd -> fork -> exec() php php fork httpd mod_php php httpd . fork
17
Thread thread Multi Thread
18
Thread (Data, Text, Heap) ( ) ( ) context switching
19
Thread -> ( ) ( )
20
Process ( ) DBMS
21
A2 DBMS DBMS Multi Process Shared Memory (SGA ) (Kernel IPC )
22
- 2 #1 93 SUN Micro Systems Solaris IO library Sparc machine 6 2
23
- 2 #2 x==2; = C if (x = 2) ( ) ( )
24
- 2 #3 (X) (O)
25
-2 #4 2 (Ex: PHP === )
26
Thread ( ) POSIX pthread_create !
27
Thread Mutex #1 ? (critical section) Mutex(mutual exclusion) POSIX pthread_mutex_lock mutex
28
Thread Mutex #2 mutex ? mutex blocking mutex (mutex )
29
Thread Mutex #3 mutex blocking ?pthread_mutex_trylock mutex (Non-Blocking)mutex CPU
30
Thread Cond Var mutex ?mutex_lock, trylock mutex POSIX POSIX Condition variable mutex phread_cond_wait pthread_cond_signal
31
Thread Cond Var mutex ?mutex_lock, trylock mutex POSIX POSIX Condition variable mutex phread_cond_wait pthread_cond_signal
32
Thread - thread suspend, resume, stop, kill suspend mutex lock deadlock Java .NET deprecated
33
Thread - mutex condition variable , , ( )
34
Server Pool - #1 Pool Thread Thread pool, Server Pool
35
Server Pool - #2 apache httpd, php-fpm (Ex: ) (StartServers) idle (MaxSpareServers ) idle (MinSpareServers)
MaxSpareServers - - 36
DB Connection Pool - #1 DBMS DBMS (connection , DBMS ) WAS DB Connection Pool app Pool app pool
MaxSpareServers - - 37
PHP DB Connection Pool PHP DB Connection Pool (SQLRelay ?) MySQL connect/close DBMS pool
38
DB Pool Manager ? DB Pool / . Mutex lock Pool (DB Connection) ? (Pool Manager or App ?) DBMS db pool dummy
39
DB Pool Manager ? Pool / Pool Pool 30 3 Pool 10
40
Multi Thread safety #1 PHP Zend ZTS None ZTS 2 ?ZTS(Zend Thread Safety) PHP (Thread safety) (http://sunyzero.tistory.com/97)
41
Multi Thread safety #2 ? (atomic) , static, global XPOSIX.1-2008 (http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09_01) (gcc -pthreads)
42
(Reentrant ) + _r asctime_r, ctime_r
43
& QNAAdvanced Programming in the Unix EnvironmentUnix network programingExpert C Programming: Deep C SecretsProgramming with POSIX Threads (http://sunyzero.tistory.com/)
Q&A
.
.