The kernel transfers control the newly loaded process
Solved Step by step with Explanation-Context Switching and Communication
Question
Q4) Compare and contrast the benefits and the disadvantages of each of the following. Your result should be in tabular form and consider both the system level and the programmer level.
a. Synchronous and asynchronous communication
Solved Step by step with Explanation-Context Switching and Communication
Part 1: Theory
Q1) In your own words, describe the actions which a kernel will perform to context switch between processes as we have discussed them in this course. Draw a diagram to assist in your explanation.
Updating kernel data structures: The kernel updates various data structures, such as the ready queue, scheduling information, and accounting data, to reflect the context switch.
Resuming execution: Finally, the kernel transfers control to the newly loaded process, which resumes execution from where it left off during the previous context switch.
Context switching, as covered in this course, refers to the process of switching the CPU from one process to another. It involves saving the state of the currently executing process and restoring the saved state of a different process.
Performing too many context switches can lead to several problems, including:
For example, consider a scenario where a system is heavily multitasking, with numerous processes frequently switching between execution. If the context switches occur too frequently, the CPU spends a significant amount of time and resources on the switching itself rather than executing the processes' tasks. This can result in degraded system performance, increased latency, and decreased overall efficiency.
Q3) Give an example of a situation in which ordinary pipes are more suitable than named pipes and an example of a situation in which named pipes are more suitable than ordinary pipes.
a. Synchronous and asynchronous communication
| Synchronous Communication | Asynchronous Communication | |
|---|---|---|
| System Level | - Simpler implementation and coordination between processes. | - Allows processes to continue working independently without waiting for each other. |
| - Provides a natural flow of control between sender and receiver. | Enhances system responsiveness and scalability by enabling concurrent execution. | |
| - Easier error handling as failures are immediately known. | - More complex error handling due to the possibility of delayed responses. | |
| Programmer Level | - Straightforward to understand and reason about. | - More complex to implement and debug due to the need for synchronization mechanisms. |
| - Blocking nature ensures the receiver gets data in a timely manner. | - Non-blocking nature allows the sender to proceed without waiting for the receiver. | |
| - Suitable for scenarios where sequential execution and coordination are required. | - Suitable for scenarios where decoupling and parallelism are desired. |
b. Automatic and explicit buffering
| Send by Copy | Send by Reference | |
|---|---|---|
| System Level | - Provides isolation and security by sending a copy of data. | - Enhances performance by avoiding data duplication. |
| - Suitable for scenarios where data integrity and security are critical. | - Suitable for scenarios where efficiency and performance are paramount |


