Introduction (เคชเคฐเคฟเคเคฏ)
เค
เคฌ เคคเค เคนเคฎเคจเฅ process เคเฅ เคฌเคพเคฐเฅ เคฎเฅเค เคชเคขเคผเคพเฅค
เคฒเฅเคเคฟเคจ เคเค เคฌเคพเคฐ เคเค เคนเฅ process เคเฅ เค
เคเคฆเคฐ เคเค เคเฅเคเฅ-เคเฅเคเฅ tasks เคเค เคธเคพเคฅ เคเคฒเคคเฅ เคนเฅเคเฅค
เคเคจเฅเคนเฅเค tasks เคเฅ threads เคเคนเคพ เคเคพเคคเคพ เคนเฅเฅค
Example เคเฅ เคฒเคฟเค browser เคเฅ เคธเคฎเคเฅ:
- เคเค tab open เคนเฅ
- เคเค file download เคนเฅ เคฐเคนเฅ เคนเฅ
- เคเค page scroll เคนเฅ เคฐเคนเคพ เคนเฅ
เคฏเฅ เคเคพเคฎ เคเค เคนเฅ process เคเฅ เค เคเคฆเคฐ เค เคฒเค-เค เคฒเค threads เคเฅ เคฎเคฆเคฆ เคธเฅ เคนเฅ เคธเคเคคเฅ เคนเฅเคเฅค
Thread เคเฅเคฏเคพ เคนเฅเคคเคพ เคนเฅ
Thread process เคเคพ เคธเคฌเคธเฅ เคเฅเคเคพ execution unit เคนเฅเคคเคพ เคนเฅเฅค
เคเคฌ process run เคเคฐเคคเคพ เคนเฅ, เคคเฅ เคเคธเคเฅ เค
เคเคฆเคฐ เคเค เคฏเคพ เคเค เคธเฅ เค
เคงเคฟเค threads เคนเฅ เคธเคเคคเฅ เคนเฅเคเฅค
เคนเคฐ thread เค
เคชเคจเคพ เค
เคฒเค execution flow เคฐเคเคคเคพ เคนเฅเฅค
Simple Definition
Thread เคเค lightweight process เคนเฅ, เคเฅ process เคเฅ เค เคเคฆเคฐ independently execute เคเคฐ เคธเคเคคเคพ เคนเฅเฅค
Thread เคเฅ lightweight process เคเฅเคฏเฅเค เคเคนเคคเฅ เคนเฅเค
Process create เคเคฐเคจเคพ heavy เคเคพเคฎ เคนเฅเคคเคพ เคนเฅ, เคเฅเคฏเฅเคเคเคฟ เคเคธเคเฅ เคฒเคฟเค เค เคฒเค memory space, resources เคเคฐ control information เคเคพเคนเคฟเค เคนเฅเคคเฅ เคนเฅเฅค
เคฒเฅเคเคฟเคจ thread process เคเฅ resources เคเฅ share เคเคฐเคคเคพ เคนเฅ, เคเคธเคฒเคฟเค:
- thread create เคเคฐเคจเคพ เคเคธเคพเคจ เคนเฅเคคเคพ เคนเฅ
- thread switching fast เคนเฅเคคเฅ เคนเฅ
- system performance เคฌเฅเคนเคคเคฐ เคนเฅเคคเฅ เคนเฅ
Process aur Thread เคฎเฅเค เค เคเคคเคฐ
| Basis | Process | Thread |
|---|---|---|
| Meaning | Running program | Process เคเคพ execution unit |
| Memory | เค เคฒเค memory space | Shared memory space |
| Resource | เค เคฒเค resources | Process ke resources share เคเคฐเคคเคพ เคนเฅ |
| Creation | Slow | Fast |
| Switching | More time | Less time |
| Communication | เคฎเฅเคถเฅเคเคฟเคฒ | เคเคธเคพเคจ |
Thread Structure
เคเค process เคเฅ เค เคเคฆเคฐ เคเฅเค เคเฅเคเฅเค shared เคนเฅเคคเฅ เคนเฅเค เคเคฐ เคเฅเค เคเฅเคเฅเค เคนเคฐ thread เคเฅ เค เคชเคจเฅ เคนเฅเคคเฅ เคนเฅเคเฅค
Shared by all threads
- Code section
- Data section
- Open files
- Process resources
Separate for each thread
- Program Counter
- Registers
- Stack
เคเคธเคเคพ เคฎเคคเคฒเคฌ เคฏเคน เคนเฅ เคเคฟ เคธเคญเฅ threads เคเค เคนเฅ process เคเฅ data ko use เคเคฐ เคธเคเคคเฅ เคนเฅเค, เคฒเฅเคเคฟเคจ เคนเคฐ thread เคเคพ execution path เค เคฒเค เคนเฅเคคเคพ เคนเฅเฅค
Single Threaded aur Multithreaded Process
Single Threaded Process
เคเคธเคฎเฅเค process เคเฅ เค
เคเคฆเคฐ เคเฅเคตเคฒ เคเค เคนเฅ thread เคนเฅเคคเคพ เคนเฅเฅค
เคเค เคธเคฎเคฏ เคฎเฅเค เคเค เคนเฅ เคเคพเคฎ properly execute เคนเฅเคคเคพ เคนเฅเฅค
Example:
เคเฅเค simple calculator app
Multithreaded Process
เคเคธเคฎเฅเค process เคเฅ เค
เคเคฆเคฐ เคเค threads เคนเฅเคคเฅ เคนเฅเคเฅค
เคเค เคนเฅ process เคเค เคธเคพเคฅ multiple tasks handle เคเคฐ เคธเคเคคเคพ เคนเฅเฅค
Example:
Browser, media player, online editor
Multithreading เคเฅเคฏเคพ เคนเฅเคคเคพ เคนเฅ
เคเคฌ เคเค process เคเฅ เค เคเคฆเคฐ multiple threads เคนเฅเคคเฅ เคนเฅเค เคเคฐ เคตเฅ เค เคฒเค-เค เคฒเค tasks perform เคเคฐเคคเฅ เคนเฅเค, เคคเฅ เคเคธเฅ multithreading เคเคนเคคเฅ เคนเฅเคเฅค
เคฏเคน technique modern operating systems เคฎเฅเค เคฌเคนเฅเคค useful เคนเฅ เคเฅเคฏเฅเคเคเคฟ เคเคธเคธเฅ system responsive เคฌเคจเคคเคพ เคนเฅเฅค
Types of Threads
1. User-Level Threads
เคฏเฅ threads user space เคฎเฅเค manage เคนเฅเคคเฅ เคนเฅเคเฅค
Operating System directly เคเคจเฅเคนเฅเค manage เคจเคนเฅเค เคเคฐเคคเคพเฅค
Features
- Fast creation
- Fast switching
- OS เคเฅ direct เคเคพเคจเคเคพเคฐเฅ เคจเคนเฅเค เคนเฅเคคเฅ
Problem
เค เคเคฐ เคเค thread block เคนเฅ เคเคพเค, เคคเฅ เคฌเคพเคเฅ threads เคญเฅ เคฐเฅเค เคธเคเคคเฅ เคนเฅเค
2. Kernel-Level Threads
เคฏเฅ threads Operating System เคฆเฅเคตเคพเคฐเคพ manage เคเคฟเค เคเคพเคคเฅ เคนเฅเคเฅค
Features
- Better control
- True parallelism possible
- OS scheduling เคเคฐเคคเคพ เคนเฅ
Problem
เคเคจเคเคพ creation เคเคฐ switching เคฅเฅเคกเคผเคพ slow เคนเฅ เคธเคเคคเคพ เคนเฅ
Threads เคเฅ เคซเคพเคฏเคฆเฅ
1. Responsiveness
Application เคเคฒเฅเคฆเฅ response เคฆเฅเคคเคพ เคนเฅ
Example:
Download เคเคฒเคคเฅ เคนเฅเค เคญเฅ browser open เคฐเคนเคคเคพ เคนเฅ
2. Resource Sharing
เคธเคญเฅ threads same memory เคเคฐ resources เคเฅ share เคเคฐเคคเฅ เคนเฅเค
3. Economy
Threads เคฌเคจเคพเคจเคพ process เคเฅ เคคเฅเคฒเคจเคพ เคฎเฅเค เคเคฎ costly เคนเฅเคคเคพ เคนเฅ
4. Better CPU Utilization
Multiple tasks efficiently run เคนเฅ เคธเคเคคเฅ เคนเฅเค
5. Parallelism
Multi-core system เคฎเฅเค multiple threads parallel run เคเคฐ เคธเคเคคเฅ เคนเฅเค
Threads เคเฅ เคเคฎเคฟเคฏเคพเค
1. Synchronization Problem
Shared data เคนเฅเคจเฅ เคเฅ เคตเคเคน เคธเฅ conflict เคนเฅ เคธเคเคคเคพ เคนเฅ
2. Debugging Difficult
Multithreaded programs เคเฅ debug เคเคฐเคจเคพ เคฎเฅเคถเฅเคเคฟเคฒ เคนเฅเคคเคพ เคนเฅ
3. Security Risk
เคเค thread เคเฅ problem เคชเฅเคฐเฅ process เคเฅ affect เคเคฐ เคธเคเคคเฅ เคนเฅ
4. Deadlock Possibility
เค เคเคฐ threads proper coordination เคจ เคเคฐเฅเค, เคคเฅ deadlock เคนเฅ เคธเคเคคเคพ เคนเฅ
Example (เคธเคฎเคเคจเฅ เคเฅ เคฒเคฟเค)
เคฎเคพเคจ เคฒเฅ เคเค browser process เคนเฅ:
- Thread 1 page load เคเคฐ เคฐเคนเคพ เคนเฅ
- Thread 2 video play เคเคฐ เคฐเคนเคพ เคนเฅ
- Thread 3 file download เคเคฐ เคฐเคนเคพ เคนเฅ
- Thread 4 user input handle เคเคฐ เคฐเคนเคพ เคนเฅ
เคฏเคน เคธเคญเฅ threads เคเค เคนเฅ process เคเฅ เค
เคเคฆเคฐ เคเคพเคฎ เคเคฐ เคฐเคนเฅ เคนเฅเคเฅค
เคเคธเฅ เคตเคเคน เคธเฅ browser fast เคเคฐ responsive เคฒเคเคคเคพ เคนเฅเฅค
Real Life Analogy
เคเค office เคเฅ process เคฎเคพเคจเฅ เคเคฐ office เคเฅ employees เคเฅ threadsเฅค
- Office = Process
- Employees = Threads
เคธเคญเฅ employees same office resources use เคเคฐเคคเฅ เคนเฅเค, เคฒเฅเคเคฟเคจ เคนเคฐ employee เคเคพ เคเคพเคฎ เค
เคฒเค เคนเฅเคคเคพ เคนเฅเฅค
เคเคธเฅ เคคเคฐเคน threads process เคเฅ resources share เคเคฐเคคเฅ เคนเฅเค เค
เคฒเค-เค
เคฒเค tasks เคเคฐเคคเฅ เคนเฅเคเฅค
Exam Point of View
Threads topic เคฎเฅเค เค เคเฅเคธเคฐ เคฏเฅ points เคชเฅเคเฅ เคเคพเคคเฅ เคนเฅเค:
- Thread เคเฅเคฏเคพ เคนเฅ
- Process aur Thread เคฎเฅเค เค เคเคคเคฐ
- Multithreading เคเฅเคฏเคพ เคนเฅ
- User-Level aur Kernel-Level Threads
- Threads เคเฅ advantages
Conclusion
Threads Operating System เคเคพ เคฌเคนเฅเคค important concept เคนเฅเฅค
เคฏเคน เคเค process เคเฅ เค
เคเคฆเคฐ multiple execution units provide เคเคฐเคคเฅ เคนเฅเค, เคเคฟเคธเคธเฅ system fast, efficient เคเคฐ responsive เคฌเคจเคคเคพ เคนเฅเฅค
Modern applications เคฎเฅเค multithreading เคเคพ use เคฌเคนเฅเคค common เคนเฅ, เคเฅเคฏเฅเคเคเคฟ เคเคธเคธเฅ เคเค เคนเฅ application เคเค เคเคพเคฎ เคเค เคธเคพเคฅ handle เคเคฐ เคธเคเคคเฅ เคนเฅเฅค