Process Management 2 - hochan222/Everything-in-JavaScript GitHub Wiki

λ°”λ‘œκ°€κΈ°

  • Copy-on-write(COW)
    • writeκ°€ λ°œμƒν–ˆμ„λ•Œ μƒˆλ‘œμš΄κ±Έ λ§Œλ“¬. λ‚΄μš©μ΄ μ‹œμž‘λ˜κΈ°μ „κΉŒμ§€λŠ” λΆ€λͺ¨κΊΌ μ‚¬μš©

ν”„λ‘œμ„ΈμŠ€μ™€ κ΄€λ ¨ν•œ μ‹œμŠ€ν…œ 콜

fork() μ‹œμŠ€ν…œ 콜

exec() μ‹œμŠ€ν…œ 콜

wait() μ‹œμŠ€ν…œ 콜

  • ν”„λ‘œμ„ΈμŠ€ Aκ°€ wait() μ‹œμŠ€ν…œ μ½œμ„ ν˜ΈμΆœν•˜λ©΄
    • 컀널은 childκ°€ μ’…λ£Œλ  λ•ŒκΉŒμ§€ ν”„λ‘œμ„ΈμŠ€ Aλ₯Ό sleep μ‹œν‚¨λ‹€.(block μƒνƒœ)
    • Child processκ°€ μ’…λ£Œλ˜λ©΄ 컀널은 ν”„λ‘œμ„ΈμŠ€ Aλ₯Ό κΉ¨μš΄λ‹€. (ready μƒνƒœ)

exit() μ‹œμŠ€ν…œ 콜

  • ν”„λ‘œμ„ΈμŠ€λ₯Ό μ’…λ£Œ μ‹œν‚¬ λ•Œ ν˜ΈμΆœν•˜λŠ” μ‹œμŠ€ν…œμ½œ
  • 자발적 μ’…λ£Œ
    • λ§ˆμ§€λ§‰ statement μˆ˜ν–‰ ν›„ exit() μ‹œμŠ€ν…œ μ½œμ„ 톡해
    • ν”„λ‘œκ·Έλž¨μ— λͺ…μ‹œμ μœΌλ‘œ 적어주지 μ•Šμ•„λ„ main ν•¨μˆ˜κ°€ λ¦¬ν„΄λ˜λŠ” μœ„μΉ˜μ— μ»΄νŒŒμΌλŸ¬κ°€ λ„£μ–΄μ€Œ
  • λΉ„μžλ°œμ  μ’…λ£Œ
    • λΆ€λͺ¨ ν”„λ‘œμ„ΈμŠ€κ°€ μžμ‹ ν”„λ‘œμ„ΈμŠ€λ₯Ό κ°•μ œ μ’…λ£Œμ‹œν‚΄
      • μžμ‹ ν”„λ‘œμ„ΈμŠ€κ°€ ν•œκ³„μΉ˜λ₯Ό λ„˜μ–΄μ„œλŠ” μžμ› μš”μ²­
      • μžμ‹μ—κ²Œ ν• λ‹Ήλœ νƒœμŠ€ν¬κ°€ 더 이상 ν•„μš”ν•˜μ§€ μ•ŠμŒ
    • ν‚€λ³΄λ“œλ‘œ kill, break등을 친 경우
    • λΆ€λͺ¨κ°€ μ’…λ£Œν•˜λŠ” 경우
      • λΆ€λͺ¨ ν”„λ‘œμ„ΈμŠ€κ°€ μ’…λ£Œν•˜κΈ° 전에 μžμ‹λ“€μ΄ λ¨Όμ € μ’…λ£Œλ¨.

ν”„λ‘œμ„ΈμŠ€ κ°„ ν˜‘λ ₯

  • 독점적 ν”„λ‘œμ„ΈμŠ€(Independent process)
    • ν”„λ‘œμ„ΈμŠ€λŠ” 각자의 μ£Όμ†Œ 곡간을 가지고 μˆ˜ν–‰λ˜λ―€λ‘œ μ›μΉ™μ μœΌλ‘œ ν•˜λ‚˜μ˜ ν”„λ‘œμ„ΈμŠ€λŠ” λ‹€λ₯Έ ν”„λ‘œμ„ΈμŠ€μ˜ μˆ˜ν–‰μ— 영ν–₯을 λ―ΈμΉ˜μ§€ λͺ»ν•¨
  • ν˜‘λ ₯ ν”„λ‘œμ„ΈμŠ€(Cooperating process)
    • ν”„λ‘œμ„ΈμŠ€ ν˜‘λ ₯ λ§€μ»€λ‹ˆμ¦˜μ„ 톡해 ν•˜λ‚˜μ˜ ν”„λ‘œμ„ΈμŠ€κ°€ λ‹€λ₯Έ ν”„λ‘œμ„ΈμŠ€μ˜ μˆ˜ν–‰μ— 영ν–₯을 λ―ΈμΉ  수 있음
  • ν”„λ‘œμ„ΈμŠ€ κ°„ ν˜‘λ ₯ λ§€μ»€λ‹ˆμ¦˜(IPC: Interprocess Communication)
    • λ©”μ‹œμ§€λ₯Ό μ „λ‹¬ν•˜λŠ” 방법
      • message passing: 컀널을 톡해 메세지 전달
    • μ£Όμ†Œ 곡간을 κ³΅μœ ν•˜λŠ” 방법
      • shared memory:μ„œλ‘œ λ‹€λ₯Έ ν”„λ‘œμ„ΈμŠ€ 간에도 일뢀 μ£Όμ†Œ 곡간을 κ³΅μœ ν•˜κ²Œ ν•˜λŠ” shared memory λ©”μ»€λ‹ˆμ¦˜μ΄ 있음

thread: threadλŠ” 사싀상 ν•˜λ‚˜μ˜ ν”„λ‘œμ„ΈμŠ€μ΄λ―€λ‘œ ν”„λ‘œμ„ΈμŠ€ κ°„ ν˜‘λ ₯으둜 λ³΄κΈ°λŠ” μ–΄λ ΅μ§€λ§Œ λ™μΌν•œ processλ₯Ό κ΅¬μ„±ν•˜λŠ” threadλ“€κ°„μ—λŠ” μ£Όμ†Œ 곡간을 κ³΅μœ ν•˜λ―€λ‘œ ν˜‘λ ₯이 κ°€λŠ₯

Message Passing

  • Message system
    • ν”„λ‘œμ„ΈμŠ€ 사이에 곡유 λ³€μˆ˜(shared variable)λ₯Ό 일체 μ‚¬μš©ν•˜μ§€ μ•Šκ³  ν†΅μ‹ ν•˜λŠ” μ‹œμŠ€ν…œ
  • Direct Communication
    • ν†΅μ‹ ν•˜λ €λŠ” ν”„λ‘œμ„ΈμŠ€μ˜ 이름을 λͺ…μ‹œμ μœΌλ‘œ ν‘œ μ‹œ
  • Indirect Communication
    • mailbox λ˜λŠ” portλ₯Ό 톡해 메세지λ₯Ό 직접 전달.