0% found this document useful (0 votes)
9 views3 pages

Advanced Process and Thread Management

The document discusses advanced process and thread management, focusing on multithreading models (Many-to-One, One-to-One, Many-to-Many), thread pools, context switching, synchronization issues and solutions, and CPU scheduling in multi-core systems. It outlines the pros and cons of different threading models, the benefits of using thread pools, and various synchronization techniques such as semaphores and monitors. Additionally, it addresses the challenges of CPU scheduling in multi-core environments and provides a simulation activity for CPU scheduling.

Uploaded by

priya selvakumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Advanced Process and Thread Management

The document discusses advanced process and thread management, focusing on multithreading models (Many-to-One, One-to-One, Many-to-Many), thread pools, context switching, synchronization issues and solutions, and CPU scheduling in multi-core systems. It outlines the pros and cons of different threading models, the benefits of using thread pools, and various synchronization techniques such as semaphores and monitors. Additionally, it addresses the challenges of CPU scheduling in multi-core environments and provides a simulation activity for CPU scheduling.

Uploaded by

priya selvakumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Advanced Process and Thread

Management
1. Multithreading Models
Multithreading allows multiple threads to exist within the context of a single process,
sharing resources while running independently.

Models:

1. Many-to-One Model
- Many user threads mapped to a single kernel thread.
- Pros: Simple, efficient thread management.
- Cons: Entire process blocks if one thread blocks; limited parallelism.
Diagram:
[User Threads] → [1 Kernel Thread]

2. One-to-One Model
- Each user thread maps to a kernel thread.
- Pros: True concurrency on multi-core systems.
- Cons: Overhead of creating many kernel threads.
Diagram:
[User Thread] ↔ [Kernel Thread]

3. Many-to-Many Model
- Many user threads mapped to many kernel threads.
- Pros: Balances flexibility and concurrency.
- Cons: More complex to implement.
Diagram:
[User Threads] ↔ [Kernel Threads]

2. Thread Pools
A collection of pre-created threads that wait for tasks.
- Improves performance by reducing thread creation/destruction overhead.
Process:
1. Tasks arrive in a queue.
2. Available thread picks up a task.
3. On completion, the thread returns to pool.
Diagram:
[Task Queue] → [Thread Pool] → [CPU Execution]
3. Context Switching
Switching CPU from one process/thread to another.
Involves saving the state (registers, program counter, etc.) of the old process and loading
the state of the new one.
Diagram:
[Process A State Saved] → [CPU Switch] → [Process B State Restored]
Overhead: Time lost in switching, not in execution.

4. Synchronization Issues & Solutions


Issues:
- Race Condition: Two threads access shared data concurrently → inconsistent result.
- Deadlock: Threads wait indefinitely for resources held by each other.
- Starvation: Low-priority thread never gets CPU.

Solutions:

1. Semaphores
- Integer variable used for signaling.
- Types:
* Binary Semaphore (0/1, like a lock)
* Counting Semaphore (allows multiple resources)
Example:
wait(S) { while S <= 0 ; S--; }
signal(S) { S++; }

2. Monitors
- High-level abstraction with mutual exclusion + condition variables.
- Encapsulates shared variables, procedures, and synchronization.

3. Lock-Free Data Structures


- Uses atomic operations (CAS – Compare-And-Swap).
- Avoids blocking, better performance in multicore systems.

5. CPU Scheduling in Multi-Core Systems


Traditional Scheduling: One CPU, one ready queue.
Multi-Core Challenges:
- Core Affinity (keeping a thread on the same core improves cache performance).
- Load Balancing across cores.

Algorithms:
- Symmetric Multiprocessing (SMP): All cores share ready queue.
- Asymmetric Multiprocessing: One core is master, schedules for others.
Diagram:
[Ready Queue] → {Core1, Core2, Core3}

6. Activity: CPU Scheduler Simulation for Multi-Core Systems


Objective: Simulate scheduling on multi-core CPU.
Steps:
1. Create a ready queue of processes with burst times & priorities.
2. Assign processes to available cores.
3. Apply scheduling algorithm (e.g., Round Robin, Priority, FCFS).
4. Observe execution, context switches, and waiting times.

Example (2-core, Round Robin):


Time 0-2: Core 1 → P1, Core 2 → P2
Time 2-4: Core 1 → P3, Core 2 → P4 ...

You might also like