Task Communication and IPC - Detailed Notes
1. Message Passing Technique for Inter-Process Communication (IPC)
Message Passing is a method where processes communicate by sending and receiving messages without
sharing a memory space.
Key Concepts:
- Requires a communication link between processes.
- Involves two main operations: send(message) and receive(message).
- Can use fixed or variable message sizes.
Characteristics:
- Easier to program for distributed systems.
- Useful when processes are on different systems or do not share memory.
- Example: Chat programs, network services.
Advantages:
- No need for synchronization over shared variables.
- Safer for inter-machine communication.
Drawbacks:
- Slower than shared memory.
- Requires careful design for reliability and performance.
2. Shared Memory in Task Communication
Shared Memory allows two or more processes to access the same region of memory.
Process:
1. Process P1 creates a shared memory segment using shmget() and writes data.
2. Process P2 attaches to the shared memory using shmat() and reads the data.
System Calls:
Task Communication and IPC - Detailed Notes
- shmget(): Creates the shared memory.
- shmat(): Attaches memory to a process.
- Also includes shmdt() and shmctl().
Advantages:
- Faster IPC mechanism.
- Enables parallel processing by sharing large data sets.
- Suitable for modular design in multitasking systems.
3. Task Communication/Synchronization Issues in IPC
Common Issues in IPC:
- Race Condition: Occurs when multiple processes access shared data simultaneously without proper
synchronization.
- Deadlock: Tasks wait indefinitely for each other to release resources.
- Starvation: A task is continuously denied access to a resource due to unfair scheduling.
- Livelock: Processes keep changing states but make no progress.
- Priority Inversion: A low-priority task blocks a high-priority task.
4. Task Communication/Synchronization Methods
Synchronization ensures processes communicate without conflicts.
Techniques:
- Mutex (Mutual Exclusion): Only one task can access a critical section at a time.
- Semaphores: Wait (P) and Signal (V) operations control access to resources.
- Message Queues: FIFO communication mechanism between tasks.
- Events & Signals: Notify a task when a condition is met.
- Busy Waiting / Spin Locks: Task keeps checking until resource becomes free (inefficient).
- Sleep and Wakeup: More efficient alternative to busy waiting.
Task Communication and IPC - Detailed Notes
5. Priority Inversion and Handling Techniques
Priority Inversion occurs when a high-priority task is blocked by a lower-priority one that holds a needed
resource.
Solutions:
- Priority Inheritance: Temporarily boosts the low-priority task's priority.
- Priority Ceiling Protocol: Restricts tasks from accessing resources unless they meet the required priority.
- Avoid Busy Waiting: Use sleep-wakeup mechanisms.
6. Role of Device Driver & Architecture in Embedded Systems
Role:
Device drivers are interface software that allow OS to communicate with hardware.
Types:
1. Kernel-mode Drivers: Access hardware directly.
2. User-mode Drivers: Access via OS calls.
Architecture:
Application Layer -> OS Kernel -> Device Driver -> Hardware
In Embedded Systems:
- Embedded in firmware.
- Control sensors, actuators, I/O.
- Written for specific hardware.
7. How to Choose an Operating System
Considerations for Selecting RTOS:
System Requirements:
Task Communication and IPC - Detailed Notes
- Type: Hard, soft, or firm real-time.
- Task priority and complexity.
- Hardware limitations.
RTOS Features:
- Scheduling (preemptive, round-robin).
- Communication: semaphores, mutexes, message queues.
- Interrupt handling efficiency.
Performance:
- Low context switch and interrupt latency.
- Small memory footprint.
Ecosystem:
- IDE, debugging tools, documentation.
Licensing & Certification:
- Open-source vs. commercial.
- Compliance (e.g., ISO 26262).
Vendor Reputation:
- Industry use cases.
- Long-term support and updates.