λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°
Computer Science/Operating System

5 User Space in Process (ν”„λ‘œμ„ΈμŠ€ μ‚¬μš©μž μ˜μ—­)

by Dowon Kang 2023. 12. 23.

λ©”λͺ¨λ¦¬ κ΄€λ¦¬μ˜ κΈ°λ³Έ κ°œλ… μ€‘ ν•˜λ‚˜λŠ” μ‚¬μš©μž μ˜μ—­(User Space)κ³Ό μ»€λ„ μ˜μ—­(Kernel Space) μ‚¬μ΄μ˜ κ΅¬λΆ„μž…λ‹ˆλ‹€.

 

컀널 μ˜μ—­ (Kernel Space): 운영체제 컀널이 λ™μž‘ν•˜λŠ” μ˜μ—­μž…λ‹ˆλ‹€. 이 뢀뢄은 μ‹œμŠ€ν…œ λ¦¬μ†ŒμŠ€ 및 운영체제의 핡심 κΈ°λŠ₯을 μ§€μ›ν•˜λŠ” 데이터 및 μ½”λ“œλ‘œ μ±„μ›Œμ Έ μžˆμŠ΅λ‹ˆλ‹€. 컀널 μ˜μ—­μ€ 일반적으둜 μ‹œμŠ€ν…œ 레벨의 κΆŒν•œμ΄ ν•„μš”ν•œ μž‘μ—…λ“€μ„ μ²˜λ¦¬ν•©λ‹ˆλ‹€.

μš΄μ˜μ²΄μ œλŠ” 컀널 μ˜μ—­μ— 적재된 PCBλ₯Ό 톡해 ν”„λ‘œμ„ΈμŠ€λ₯Ό 관리

μ‚¬μš©μž λͺ¨λ“œ (User Space): μ‚¬μš©μž μ˜μ—­μ€ μ‚¬μš©μž μ‘μš© ν”„λ‘œκ·Έλž¨μ΄ μ‹€ν–‰λ˜κ³  λ™μž‘ν•˜λŠ” κ³΅κ°„μž…λ‹ˆλ‹€. μ—¬κΈ°μ—λŠ” ν…μŠ€νŠΈ νŽΈμ§‘κΈ°, μ›Ή λΈŒλΌμš°μ €, κ²Œμž„κ³Ό κ°™μ€ μ‘μš© ν”„λ‘œκ·Έλž¨λ“€μ΄ μ‚¬μš©ν•˜λŠ” λ©”λͺ¨λ¦¬κ°€ ν¬ν•¨λ©λ‹ˆλ‹€. μ΄ κ³΅κ°„μ—μ„œ μ‘μš© ν”„λ‘œκ·Έλž¨μ€ μ‹œμŠ€ν…œ λ¦¬μ†ŒμŠ€μ— μ œν•œλœ μ ‘근을 κ°–κ²Œ λ˜μ–΄ κ²©λ¦¬μ™€ λ³΄μ•ˆ μˆ˜μ€€μ΄ μœ μ§€λ©λ‹ˆλ‹€. 

 

 

 


 

μ‚¬μš©μž μ˜μ—­μ—λŠ” λ‹€μ–‘ν•œ μ˜μ—­λ“€μ΄ μ‘΄μž¬ν•©λ‹ˆλ‹€. 

 

1) μ½”λ“œ μ˜μ—­ (Code Segment): ν”„λ‘œκ·Έλž¨μ˜ μ‹€ν–‰ μ½”λ“œκ°€ μ €μž₯λ˜λŠ” λΆ€λΆ„μž…λ‹ˆλ‹€. CPUλŠ” 이 μ½”λ“œλ₯Ό ν•˜λ‚˜μ”© μ‹€ν–‰ν•˜μ—¬ ν”„λ‘œμ„ΈμŠ€μ˜ λ™μž‘μ„ μˆ˜ν–‰ν•©λ‹ˆλ‹€.

 

2) 데이터 μ˜μ—­ (Data Segment): 정적 λ³€μˆ˜, μ „μ—­ λ³€μˆ˜ λ“± ν”„λ‘œκ·Έλž¨μ˜ 데이터가 μ €μž₯λ˜λŠ” λΆ€λΆ„μž…λ‹ˆλ‹€. ν”„λ‘œκ·Έλž¨μ΄ μ‹€ν–‰λ˜λ©΄μ„œ μƒμ„±λ˜λŠ” 동적인 데이터도 이 μ˜μ—­μ— 할당될 수 μžˆμŠ΅λ‹ˆλ‹€.


3) μŠ€νƒ μ˜μ—­ (Stack Segment): ν•¨μˆ˜ 호좜과 κ΄€λ ¨λœ 정보, 지역 λ³€μˆ˜, ν•¨μˆ˜μ˜ λ°˜ν™˜ μ£Όμ†Œ 등이 μ €μž₯λ˜λŠ” λΆ€λΆ„μž…λ‹ˆλ‹€. μŠ€νƒμ€ ν›„μž…μ„ μΆœ(LIFO) ꡬ쑰둜 데이터λ₯Ό μ €μž₯ν•˜λ©°, ν•¨μˆ˜ 호좜과 λ°˜ν™˜μ— 따라 계속 λ³€ν•©λ‹ˆλ‹€.

 

4) νž™ μ˜μ—­ (Heap Segment): 동적 할당을 μœ„ν•œ κ³΅κ°„μœΌλ‘œ ν”„λ‘œκ·Έλž¨μ˜ μ‹€ν–‰ 쀑에 λ™μ μœΌλ‘œ ν• λ‹Ήλ˜λŠ” λ©”λͺ¨λ¦¬λ₯Ό μœ„ν•œ μ˜μ—­μž…λ‹ˆλ‹€. μ‚¬μš©μžκ°€(=ν”„λ‘œκ·Έλž˜λ¨Έ) 직접 λ©”λͺ¨λ¦¬λ₯Ό ν• λ‹Ήν•˜κ³  ν•΄μ œν•˜λŠ” 데 μ‚¬μš©λ˜λ©°, 주둜 동적 데이터 κ΅¬μ‘°λ‚˜ κ°€λ³€ 크기의 데이터λ₯Ό μ €μž₯ν•˜λŠ” 데 ν™œμš©λ©λ‹ˆλ‹€. μš”μ¦˜ 언어듀은 가비지 μ»¬λ ‰μ…˜μœΌλ‘œ ν• λ‹Ήν•œ 곡간을 μžλ™μœΌλ‘œ μ œκ±°ν•΄μ€λ‹ˆλ‹€. ν•˜μ§€λ§Œ C언어와 같은 언어듀은 μ΄λŸ¬ν•œ κΈ°λŠ₯이 μ—†κΈ° λ•Œλ¬Έμ— 곡간을 μ‚¬μš©ν•˜κ³  λ°©μΉ˜ν•˜λ©΄ λ©”λͺ¨λ¦¬ λˆ„μˆ˜(Memory leak)κ°€ μΌμ–΄λ‚©λ‹ˆλ‹€. 

 

μ΄λŸ¬ν•œ μ˜μ—­λ“€μ€ ν”„λ‘œμ„ΈμŠ€κ°€ μ‹€ν–‰λ˜λŠ” λ™μ•ˆ λ™μ μœΌλ‘œ λ³€ν•˜λ©°, 각각의 역할에 따라 λ©”λͺ¨λ¦¬κ°€ ν• λ‹Ήλ˜κ³  μ‚¬μš©λ©λ‹ˆλ‹€.

 

 

 


Kernel Space
The kernel space is a privileged area of memory where the core components of the operating system, including device drivers and system call interfaces, reside. It has elevated system-level permissions, allowing it to control hardware and manage critical system functions.

User Space
The user space is the memory region where user applications execute, isolated from the kernel. It contains the code, data, and stack segments of user programs, operating with restricted permissions to ensure security and stability.

 

 

'Computer Science > Operating System' μΉ΄ν…Œκ³ λ¦¬μ˜ λ‹€λ₯Έ κΈ€

7 Thread in Software  (0) 2023.12.28
6 ν”„λ‘œμ„ΈμŠ€ μƒνƒœμ™€ 계측 ꡬ쑰  (1) 2023.12.28
4 Process Outline (+Kernel Space)  (1) 2023.12.23
3 Dual Mode (User & Kernel mode) + System Call  (1) 2023.12.21
2 컀널 (Kernel)  (0) 2023.12.21

λŒ“κΈ€