Contents:
- 1 ¾²·¹µå µ¿±âÈ (Thread Synchronization)
- 1.1 À¯Àú ¸ðµå (User Mode) ¿Í Ä¿³Î ¸ðµå (Kernel Mode)
- 1.2 À¯Àú ¸ðµå¿¡¼ÀÇ µ¿±âÈ (Synchronization in User Mode)
- 1.3 Ä¿³Î ¸ðµå¿¡¼ÀÇ µ¿±âÈ (Synchronization in Kernel Mode )
- 2 µ¿±âÈ ¿ÀºêÁ§Æ®
- 2.1 CRITICAL_SECTION
- 2.2 Mutex (Mutual Exclusion)
- 2.3 Semaphore
- 2.4 Event
1 ¾²·¹µå µ¿±âÈ (Thread Synchronization) #
1.1 À¯Àú ¸ðµå (User Mode) ¿Í Ä¿³Î ¸ðµå (Kernel Mode) #
Windows ÇÁ·Î±×·¥Àº ÀϹÝÀûÀ¸·Î ÀÌÁß ¸ðµå ¿¬»ê (Dual-Mode Operation) ¿¡ ÀÇÇÏ¿© ½ÇÇàµÈ´Ù. À¯Àú ¸ðµå¿Í Ä¿³Î ¸ðµå·Î ±¸¼ºµÇ¾î ÀÖÀ¸¸ç, À¯Àú ¸ðµå´Â ÀÀ¿ë ÇÁ·Î±×·¥ÀÇ ±âº» ¸ðµå·Î Á¢±ÙÇÒ ¼ö ÀÖ´Â ¸Þ¸ð¸® Á¦ÇÑ, ¹°¸®ÀûÀÎ ¿µ¿ª ( Çϵå¿þ¾î ) ÀÇ Á÷Á¢ Á¢±ÙÀÌ Çã¿ëµÇÁö ¾Ê´Â´Ù. Ä¿³Î ¸ðµå´Â ¸®¼Ò½º Á¢±Ù, Çϵå¿þ¾î Á¢±ÙÀÌ °¡´ÉÇÏ´Ù.
1.2 À¯Àú ¸ðµå¿¡¼ÀÇ µ¿±âÈ (Synchronization in User Mode) #
À¯Àú ¸ðµå µ¿±âÈ ±â¹ýÀº CRITICAL_SECTION ¿ÀºêÁ§Æ® ( Object ) ¸¦ »ç¿ëÇÑ´Ù. À¯Àú ¸ðµå¿¡¼ µ¿±âȰ¡ ÀÌ·ç¾îÁö¹Ç·Î Ä¿³Î ¸ðµå Àüȯ¿¡ ´ëÇÑ ºÎ´ãÀÌ ¾øÁö¸¸ Ä¿³Î ¸ðµå µ¿±âÈ ±â¹ý¿¡ ºñÇØ Á¦ÇÑµÈ ±â´É¸¸ »ç¿ëÇÒ ¼ö ÀÖ´Ù. ( ´ÜÀÏ ÇÁ·Î¼¼½º¿¡¼¸¸ »ç¿ë °¡´ÉÇÏ´Ù. )
1.3 Ä¿³Î ¸ðµå¿¡¼ÀÇ µ¿±âÈ (Synchronization in Kernel Mode ) #
Ä¿³Î ¸ðµå µ¿±âÈ ±â¹ýÀº ´Ù¸¥ ÇÁ·Î¼¼½º ¾È¿¡ Á¸ÀçÇÏ´Â ¾²·¹µåµé°£ÀÇ µ¿±âȰ¡ °¡´ÉÇÏ´Ù. À¯Àú ¸ðµå µ¿±âÈ ±â¹ýÀº Deadlock ¹ß»ý °¡´É¼ºÀÌ ÀÖÁö¸¸ Ä¿³Î ¸ðµå µ¿±âÈ ±â¹ý¿¡¼´Â Deadlock À» ¹æÁöÇϱâ À§ÇÏ¿© ŸÀÓ ¾Æ¿ôÀ» ¼³Á¤ÇÒ ¼ö ÀÖ´Ù. Ä¿³Î ¸ðµå µ¿±âÈ ±â¹ýÀº Event, Semaphore, Mutex ¿ÀºêÁ§Æ®¸¦ »ç¿ëÇϸç, À̵éÀº ¸ðµÎ Ä¿³Î ¿ÀºêÁ§Æ® ÀÌ´Ù.
À¯Àú ¸ðµå µ¿±âÈ ±â¹ýÀ¸·Î ´ÜÀÏ ÇÁ·Î¼¼½º¿¡¼¸¸ »ç¿ëµÈ´Ù. ( Ä¿³Î ¿ÀºêÁ§Æ®°¡ ¾Æ´Ï´Ù. )
| ÇÔ ¼ö | ¼³ ¸í |
| InitializeCriticalSection | Initializes a critical section object. |
| InitializeCriticalSectionAndSpinCount | Initializes a critical section object and sets the spin count for the critical section. |
| EnterCriticalSection | Waits for ownership of the specified critical section object. |
| LeaveCriticalSection | Releases ownership of the specified critical section object. |
| DeleteCriticalSection | Releases all resources used by an unowned critical section object. |
| SetCriticalSectionSpinCount | Sets the spin count for the specified critical section. |
| TryEnterCriticalSection | Attempts to enter a critical section without blocking. |
2.2 Mutex (Mutual Exclusion) #
Ä¿³Î ¿ÀºêÁ§Æ®·Î CRITICAL_SECTION °ú ºñ½ÁÇÑ ¹æ¹ýÀ¸·Î »ç¿ëÇÑ´Ù.
| ÇÔ ¼ö | ¼³ ¸í |
| CreateMutex | Creates or opens a named or unnamed mutex object.
bInitialOwner - FALSE ·Î Àü´ÞÇϸé Mutex ¼ÒÀ¯ÀÚ°¡ Á¸ÀçÇÏÁö ¾ÊÀ¸¸ç Signaled »óŰ¡ µÈ´Ù. |
| OpenMutex | Opens an existing named mutex object. |
| ReleaseMutex | Releases ownership of the specified mutex object. |
Mutex ¿ÀºêÁ§Æ®´Â ¼ÒÀ¯ÀÚ°¡ Á¸ÀçÇÒ °æ¿ì Non-Signaled »óÅÂ, ¼ÒÀ¯ÀÚ°¡ Á¸ÀçÇÏÁö ¾ÊÀ» °æ¿ì Signaled »óŰ¡ µÇ´Â Ä¿³Î ¿ÀºêÁ§Æ®ÀÌ´Ù.
| ÇÔ ¼ö | ¼³ ¸í |
| CreateSemaphore | Creates or opens a named or unnamed semaphore object. |
| OpenSemaphore | Opens an existing named semaphore object. |
| ReleaseSemaphore | Increases the count of the specified semaphore object by a specified amount. |
| ÇÔ ¼ö | ¼³ ¸í |
| CreateEvent | Creates or opens a named or unnamed event object. |
| OpenEvent | Opens an existing named event object. |
| PulseEvent | Sets the specified event object to the signaled state and then resets it to the nonsignaled state after releasing the appropriate number of waiting threads. |
| ResetEvent | Sets the specified event object to the nonsignaled state. |
| SetEvent | Sets the specified event object to the signaled state. |