ν‹°μŠ€ν† λ¦¬ λ·°

ν”„λ‘œμ„ΈμŠ€λž€?

ν”„λ‘œμ„ΈμŠ€(process)λž€ μš΄μ˜μ²΄μ œλ‘œλΆ€ν„° μ‹œμŠ€ν…œ μžμ›μ„ ν• λ‹Ήλ°›λŠ” μž‘μ—…μ˜ λ‹¨μœ„λ‘œ 싀행쀑에 μžˆλŠ” ν”„λ‘œκ·Έλž¨μ„ μ˜λ―Έν•©λ‹ˆλ‹€.

  • λ©”λͺ¨λ¦¬μ— μ˜¬λΌμ™€ μ‹€ν–‰λ˜κ³  μžˆλŠ” ν”„λ‘œκ·Έλž¨μ˜ 독립적인 μΈμŠ€ν„΄μŠ€
  • 기본적으둜 ν”„λ‘œμ„ΈμŠ€λ§ˆλ‹€ μ΅œμ†Œ 1개의 μŠ€λ ˆλ“œλ₯Ό μ†Œμœ (메인 μŠ€λ ˆλ“œ 포함)

 

ν”„λ‘œμ„ΈμŠ€κ°€ ν• λ‹Ήλ°›λŠ” μ‹œμŠ€ν…œ μžμ›

  • CPU μ‹œκ°„
  • 운영되기 μœ„ν•΄ ν•„μš”ν•œ μ£Όμ†Œ 곡간
  • Code, Data, Stack, Heap의 ꡬ쑰둜 λ˜μ–΄ μžˆλŠ” λ…λ¦½λœ λ©”λͺ¨λ¦¬ μ˜μ—­

 

ν”„λ‘œμ„ΈμŠ€μ˜ λ©”λͺ¨λ¦¬ ꡬ쑰

  • Code μ˜μ—­ : ν”„λ‘œκ·Έλž¨μ„ μ‹€ν–‰μ‹œν‚€λŠ” μ‹€ν–‰ 파일 λ‚΄μ˜ λͺ…령어듀이 올라감
  • Data μ˜μ—­ : μ „μ—­ λ³€μˆ˜, static λ³€μˆ˜μ˜ ν• λ‹Ή
  • Heap μ˜μ—­: 동적 할당을 μœ„ν•œ λ©”λͺ¨λ¦¬ μ˜μ—­
  • Stack μ˜μ—­ : 지역 λ³€μˆ˜, ν•¨μˆ˜ ν˜ΈμΆœμ‹œ μ „λ‹¬λ˜λŠ” 인자(νŒŒλΌλ―Έν„°)λ₯Ό μœ„ν•œ λ©”λͺ¨λ¦¬ μ˜μ—­

Code와 Data μ˜μ—­μ€ μ„ μ–Έν•  λ•Œ κ·Έ 크기가 κ²°μ •λ˜λŠ” 정적 μ˜μ—­μ΄μ§€λ§Œ, Stackκ³Ό Heapμ˜μ—­μ€ ν”„λ‘œμ„ΈμŠ€κ°€ μ‹€ν–‰λ˜λŠ” λ™μ•ˆ 크기가 λŠ˜μ–΄λ‚¬λ‹€ 쀄어듀기도 ν•˜λŠ” 동적 μ˜μ—­μž…λ‹ˆλ‹€.

 

λ©€ν‹° ν”„λ‘œμ„ΈμŠ€

λ©€ν‹° ν”„λ‘œμ„ΈμŠ€λž€ ν•˜λ‚˜μ˜ μ‘μš© ν”„λ‘œκ·Έλž¨μ„ μ—¬λŸ¬ 개의 ν”„λ‘œμ„ΈμŠ€λ‘œ κ΅¬μ„±ν•˜μ—¬ 각 ν”„λ‘œμ„ΈμŠ€κ°€ ν•˜λ‚˜μ˜ μž‘μ—…(νƒœμŠ€ν¬)λ₯Ό μ²˜λ¦¬ν•˜λ„λ‘ ν•˜λŠ” κ²ƒμž…λ‹ˆλ‹€.

  • μ—¬λŸ¬ 개의 μžμ‹ ν”„λ‘œμ„ΈμŠ€ 쀑 ν•˜λ‚˜μ— λ¬Έμ œκ°€ λ°œμƒν•˜λ©΄ κ·Έ μžμ‹ ν”„λ‘œμ„ΈμŠ€λ§Œ μ£½λŠ” 것 μ΄μƒμœΌλ‘œ λ‹€λ₯Έ 영ν–₯이 ν™•μ‚°λ˜μ§€ μ•ŠμŒ
  • *Context Switchingμ—μ„œμ˜ μ˜€λ²„ν—€λ“œκ°€ λ°œμƒν•  수 있음

 

*Context Switching(λ¬Έλ§₯ κ΅ν™˜)에 λŒ€ν•œ μžμ„Έν•œ λ‚΄μš©μ€ μ•„λž˜μ˜ ν¬μŠ€νŒ…μ„ μ°Έκ³ ν•˜μ„Έμš”.

https://j-su2.tistory.com/63

 

[운영체제] λ¬Έλ§₯ κ΅ν™˜(Context Switching)μ΄λž€?

λ¬Έλ§₯ κ΅ν™˜μ΄λž€? λ¬Έλ§₯ κ΅ν™˜μ€ ν•˜λ‚˜μ˜ ν”„λ‘œμ„ΈμŠ€κ°€ CPUλ₯Ό μ‚¬μš© 쀑인 μƒνƒœμ—μ„œ λ‹€λ₯Έ ν”„λ‘œμ„ΈμŠ€κ°€ CPUλ₯Ό μ‚¬μš©ν•˜λ„λ‘ ν•˜κΈ° μœ„ν•΄, μ΄μ „μ˜ ν”„λ‘œμ„ΈμŠ€μ˜ μƒνƒœ(λ¬Έλ§₯)을 λ³΄κ΄€ν•˜κ³  μƒˆλ‘œμš΄ ν”„λ‘œμ„ΈμŠ€μ˜ μƒνƒœλ₯Ό 적

j-su2.tistory.com


μŠ€λ ˆλ“œλž€?

μŠ€λ ˆλ“œλž€ ν”„λ‘œμ„ΈμŠ€ μ•ˆμ—μ„œ μ‹€ν–‰λ˜λŠ” μ—¬λŸ¬ 흐름 λ‹¨μœ„λ₯Ό μ˜λ―Έν•©λ‹ˆλ‹€.

  • ν”„λ‘œμ„ΈμŠ€κ°€ 할당받은 μžμ›μ„ μ΄μš©ν•˜λŠ” μ‹€ν–‰μ˜ λ‹¨μœ„
  • ν•˜λ‚˜μ˜ ν”„λ‘œμ„ΈμŠ€λŠ” μ—¬λŸ¬κ°œμ˜ μŠ€λ ˆλ“œλ‘œ ꡬ성이 κ°€λŠ₯
  • ν”„λ‘œμ„ΈμŠ€ λ‚΄μ—μ„œ Stack만 λ”°λ‘œ ν• λ‹Ήλ°›κ³ , Code, Data, Heap λ©”λͺ¨λ¦¬ μ˜μ—­μ„ λ‹€λ₯Έ μŠ€λ ˆλ“œμ™€ 곡유

 

λ©€ν‹° μŠ€λ ˆλ“œ

ν•˜λ‚˜μ˜ μ‘μš©ν”„λ‘œκ·Έλž¨μ„ μ—¬λŸ¬ 개의 μŠ€λ ˆλ“œλ‘œ κ΅¬μ„±ν•˜κ³  각 μŠ€λ ˆλ“œλ‘œ ν•˜μ—¬κΈˆ ν•˜λ‚˜μ˜ μž‘μ—…μ„ μ²˜λ¦¬ν•˜λ„λ‘ ν•˜λŠ” κ²ƒμž…λ‹ˆλ‹€.

  • μ‹œμŠ€ν…œ μžμ› μ†Œλͺ¨ κ°μ†Œ, μ‹œμŠ€ν…œ μ²˜λ¦¬λŸ‰ 증가, κ°„λ‹¨ν•œ 톡신 λ°©λ²•μœΌλ‘œ μΈν•œ ν”„λ‘œκ·Έλž¨ 응닡 μ‹œκ°„ 단좕
  • 주의 κΉŠμ€ 섀계가 ν•„μš”ν•˜λ©° 디버깅이 κΉŒλ‹€λ‘œμ›€, 동기화 문제(μžμ› 곡유 문제)
  • ν•˜λ‚˜μ˜ μŠ€λ ˆλ“œμ— λ¬Έμ œκ°€ λ°œμƒν•˜λ©΄ 전체 ν”„λ‘œμ„ΈμŠ€κ°€ 영ν–₯을 λ°›μŒ

ν”„λ‘œμ„ΈμŠ€ VS μŠ€λ ˆλ“œ

ν”„λ‘œμ„ΈμŠ€λŠ” μ‹€ν–‰ 쀑인 ν”„λ‘œκ·Έλž¨μ„ λ§ν•˜λ©°, μ™„λ²½νžˆ 독립적이기 λ•Œλ¬Έμ— λ©”λͺ¨λ¦¬ μ˜μ—­(Code, Date, Heap, Stack)을 λ‹€λ₯Έ ν”„λ‘œμ„ΈμŠ€μ™€ κ³΅μœ ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

 

μŠ€λ ˆλ“œλŠ” ν”„λ‘œμ„ΈμŠ€ 내에 μ‘΄μž¬ν•˜λ©° ν”„λ‘œμ„ΈμŠ€κ°€ 할당받은 μžμ›μ„ μ΄μš©ν•˜μ—¬ μ‹€ν–‰λ©λ‹ˆλ‹€. μŠ€λ ˆλ“œλŠ” ν”„λ‘œμ„ΈμŠ€ λ‚΄μ—μ„œ Stack만 λ”°λ‘œ ν• λ‹Ήλ°›κ³ , κ·Έ μ΄μ™Έμ˜ λ©”λͺ¨λ¦¬ μ˜μ—­μ„ κ³΅μœ ν•˜κΈ° λ•Œλ¬Έμ— λ‹€λ₯Έ μŠ€λ ˆλ“œμ˜ μ‹€ν–‰ κ²°κ³Όλ₯Ό μ¦‰μ‹œ 확인할 수 μžˆμŠ΅λ‹ˆλ‹€.


λ©€ν‹° ν”„λ‘œμ„ΈμŠ€ VS λ©€ν‹° μŠ€λ ˆλ“œ

λ©€ν‹° ν”„λ‘œμ„ΈμŠ€λŠ” ν•˜λ‚˜μ˜ ν”„λ‘œμ„ΈμŠ€κ°€ 죽어도 λ‹€λ₯Έ ν”„λ‘œμ„ΈμŠ€μ— 영ν–₯을 λΌμΉ˜μ§€ μ•Šκ³  계속 μ‹€ν–‰λœλ‹€λŠ” μž₯점이 μžˆμ§€λ§Œ λ©€ν‹°μŠ€λ ˆλ“œλ³΄λ‹€ λ§Žμ€ λ©”λͺ¨λ¦¬ 곡간과 CPU μ‹œκ°„μ„ μ°¨μ§€ν•œλ‹€λŠ” 단점이 μžˆμŠ΅λ‹ˆλ‹€.

 

λ©€ν‹° μŠ€ν…Œλ“œλŠ” λ©€ν‹° ν”„λ‘œμ„ΈμŠ€λ³΄λ‹€ 적은 λ©”λͺ¨λ¦¬ 곡간을 μ°¨μ§€ν•˜κ³  λ¬Έλ§₯ μ „ν™˜μ΄ λΉ λ₯΄λ‹€λŠ” μž₯점이 μžˆμ§€λ§Œ ν•˜λ‚˜μ˜ μŠ€λ ˆλ“œμ— λ¬Έμ œκ°€ 생기면 전체 μŠ€λ ˆλ“œκ°€ 영ν–₯을 λ°›μœΌλ©° 동기화 λ¬Έμ œλ„ μžˆλ‹€λŠ” 단점이 μžˆμŠ΅λ‹ˆλ‹€.


 

[μ°Έκ³ ]

https://gmlwjd9405.github.io/2018/09/14/process-vs-thread.html

 

[OS] ν”„λ‘œμ„ΈμŠ€μ™€ μŠ€λ ˆλ“œμ˜ 차이 - Heee's Development Blog

Step by step goes a long way.

gmlwjd9405.github.io

https://inpa.tistory.com/entry/%F0%9F%91%A9%E2%80%8D%F0%9F%92%BB-%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4-%E2%9A%94%EF%B8%8F-%EC%93%B0%EB%A0%88%EB%93%9C-%EC%B0%A8%EC%9D%B4

 

πŸ‘©‍πŸ’» ν”„λ‘œμ„ΈμŠ€ vs μ“°λ ˆλ“œ 차이 정리

ν”„λ‘œμ„ΈμŠ€(Process) ν”„λ‘œμ„ΈμŠ€λΌλŠ” λͺ…칭은 λ‚―μ„€μˆ˜ μžˆλŠ”λ°, ν”„λ‘œκ·Έλž¨μ€ μΉœμˆ™ν•˜λ¦¬λΌ μƒκ°λœλ‹€. μš°λ¦¬κ°€ ν”νžˆ λ§ν•˜λŠ” ν”„λ‘œκ·Έλž¨μ΄ μ‹€ν–‰λ˜λ©΄ ν”„λ‘œμ„ΈμŠ€ μΈμŠ€ν„΄μŠ€κ°€ μƒμ„±λœλ‹€. μΈμŠ€ν„΄μŠ€κ°€ μƒμ„±λœλ‹€λŠ” 의미

inpa.tistory.com

https://blockdmask.tistory.com/22

 

[운영체제] ν”„λ‘œμ„ΈμŠ€λž€? (μŠ€μΌ€μ€„λ§, λ©”λͺ¨λ¦¬κ΅¬μ‘°, μƒνƒœλ³€ν™”)

1. ν”„λ‘œμ„ΈμŠ€(process)λž€? ν”„λ‘œμ„ΈμŠ€(process)λž€ 싀행쀑에 μžˆλŠ” ν”„λ‘œκ·Έλž¨(Program)을 μ˜λ―Έν•œλ‹€. μŠ€μΌ€μ€„λ§μ˜ λŒ€μƒμ΄ λ˜λŠ” μž‘μ—…(task)κ³Ό 같은 의미둜 쓰인닀. ν”„λ‘œμ„ΈμŠ€ λ‚΄λΆ€μ—λŠ” μ΅œμ†Œ ν•˜λ‚˜μ˜ μŠ€λ ˆλ“œ(thread)λ₯Ό

blockdmask.tistory.com