Answers
Answers
---
## Important Questions
### 30. How are Local & Global variables allocated by compiler?
**Answer:** Local variables are typically allocated on the stack, while global
variables are allocated in a fixed area of memory (the data segment) that persists
for the lifetime of the program.
### 55. What are Deadlock Causes, and How to Avoid Them?
**Answer:** Deadlocks occur when two or more tasks are waiting for each other to
release resources. Common causes include mutual exclusion, hold and wait, no
preemption, and circular wait. To avoid deadlocks, use resource hierarchy,
implement timeout mechanisms, and use a resource allocation graph.
### 86. How do you handle Resource Sharing and Mutual Exclusion in an RTOS?
**Answer:** Resource sharing and mutual exclusion are handled using synchronization
mechanisms such as mutexes, semaphores, and critical sections.
### 94. What are Deadlock Causes, and How to Avoid Them?
**Answer:** Deadlocks occur due to mutual exclusion, hold and wait, no preemption,
and circular wait. To avoid them, use resource hierarchy and implement timeout
mechanisms.
### 125. How do you handle Resource Sharing and Mutual Exclusion in an RTOS?
**Answer:** Resource sharing and mutual exclusion are handled using synchronization
mechanisms such as mutexes, semaphores, and critical sections.
### 133. What are Deadlock Causes, and How to Avoid Them?
**Answer:** Deadlocks occur due to mutual exclusion, hold and wait, no preemption,
and circular wait. To avoid them, use resource hierarchy and implement timeout
mechanisms.