ஒரு process என்பது அதன் சொந்த memory-ஐக் கொண்ட ஒரு தனிமைப்படுத்தப்பட்ட program; ஒரு thread என்பது ஒரே process-இல் உள்ள மற்ற threads-உடன் memory-ஐப் பகிர்ந்து கொள்ளும் ஒரு execution unit ஆகும். ஒரு process பல threads-ஐக் கொண்டிருக்க முடியும்.
ஒரு process என்பது அதன் சொந்த memory-ஐக் கொண்ட ஒரு தனிமைப்படுத்தப்பட்ட program; ஒரு thread என்பது ஒரே process-இல் உள்ள மற்ற threads-உடன் memory-ஐப் பகிர்ந்து கொள்ளும் ஒரு execution unit ஆகும். ஒரு process பல threads-ஐக் கொண்டிருக்க முடியும்.
Process A Process B
├─ heap (shared by threads) ├─ heap
├─ Thread 1 (own stack) └─ Thread 1
└─ Thread 2 (own stack)
↑ threads share heap → must lock shared data
import threading, multiprocessing
# Threads share 'counter' — needs a lock
counter = 0
threading.Thread(target=lambda: work(counter)).start()
# Processes get separate copies — isolated, pass data via IPC/queue
multiprocessing.Process(target=work, args=(data,)).start()
scheduler ஆனது threads-க்கு CPU நேரத்தை ஒதுக்குகிறது; OS ஆனது resource ownership மற்றும் isolation-க்காக threads-ஐ processes-இன் கீழ் குழுவாக்குகிறது.
சமரசம் design தேர்வுகளை இயக்குகிறது. Threads இலகுவானவை மற்றும் data-ஐ நேரடியாகப் பகிர்கின்றன ஆனால் race conditions அபாயத்தைக் கொண்டுள்ளன; processes பாதுகாப்பானவை மற்றும் machines முழுவதும் scale ஆகின்றன ஆனால் ஒரு communication செலவைச் செலுத்துகின்றன. இதை அறிவது, எடுத்துக்காட்டாக, CPU வேலைக்காக GIL-ஐ தவிர்க்க Python ஏன் multiprocessing-ஐப் பயன்படுத்துகிறது என்பதை விளக்குகிறது.
விரிவான பதில்களுடன் கூடிய IT நேர்காணல் கேள்விகளின் நூலகம் — Junior முதல் Senior வரை.
நன்கொடை