Process Management in OS🕒:
Handles the execution of programs and manages the CPU.
1. Multitasking 🖥️
Multitasking refers to the ability of an OS to run multiple tasks simultaneously. It's like juggling multiple things at once! 💪
- Preemptive Multitasking: The OS can interrupt a process and switch to another. ⏱️
- Cooperative Multitasking: Processes must give control back to the OS to switch. 🔄
2. Processes vs Threads 🔄
Process:
A process is an independent program with its own resources. Think of it as a full-blown application! 💻Thread:
A thread is a smaller unit of execution within a process. Multiple threads share the same resources, making them faster but riskier! ⚡
3. Process Scheduling 🗓️
The OS uses scheduling algorithms to decide which process gets CPU time. 🕒
- Round Robin: Processes are given a fixed time slice.
- FCFS: First process in gets executed first.
- Priority Scheduling: The highest priority process runs first. 🚀
Hands-on: Process & Thread Management 💡
Linux (Bash) 🐧
Viewing Processes:
Creating a Process:
Viewing Threads:
Windows (PowerShell) 💻
Viewing Processes:
Creating a Process:
Creating Threads (via .NET in PowerShell) 💻:
4. Thread vs Process Handling ⚖️
- Memory: Threads share memory, processes don't. 🧠 vs 🧱
- Creation Time: Threads are quicker to create since they share resources. ⚡
- Context Switching: Switching between threads is faster than processes. 🚦
5. Advanced: Process Synchronization 🔒
When multiple threads/processes share resources, we need mutexes and semaphores to avoid chaos. 🛑
- Mutex: Ensures only one thread can access a resource at a time. 🚷
- Semaphore: Allows multiple threads to access a resource, but with limits. ⛔
Summary 📚:
- Processes: Independent units of execution. 🏃♂️
- Threads: Lighter units that share resources. 🧵
- Multitasking: Managing multiple tasks at the same time. 🏃♀️💨
- Scheduling: Decides which process runs when. ⏲️
0 Comments