POS-Quizes-Answers(A1/A2)

A2

Q-1. **Advantages and disadvantages of threads compared to processes:**

   - *Advantages*: Threads share resources, such as memory, more efficiently than processes. They are lighter-weight, as they share the same address space, which reduces overhead. Threads can communicate more easily since they share memory.

   - *Disadvantages*: Threads can lead to synchronization issues, such as race conditions and deadlocks. They are also harder to debug due to shared memory.


Q-2. **Priority scheduling:**

   - Priority scheduling assigns priorities to tasks, with higher-priority tasks being executed first. Potential drawbacks include the possibility of starvation for lower-priority tasks and the potential for priority inversion.

   - Drawbacks can be mitigated by implementing techniques such as aging (increasing the priority of tasks over time) and priority boosting (temporarily raising the priority of certain tasks).


Q-3. **First Come First Served (FCFS) scheduling:**

   - FCFS scheduling is a simple scheduling algorithm where tasks are executed in the order they arrive. There is no prioritization based on task characteristics.


Q-4. **Quantum in Round Robin scheduling:**

   - In Round Robin scheduling, each process is assigned a fixed time slice (quantum) during which it can execute. If a process doesn't finish within its quantum, it's placed back in the ready queue.

   - The quantum impacts system performance by affecting the balance between throughput and response time. A shorter quantum leads to better response time but higher overhead due to frequent context switches.


Q-5. **Multi-level feedback queue scheduling:**

   - This scheduling algorithm uses multiple queues with different priorities. Processes start in the highest priority queue and move to lower priority queues if they don't finish within their time slice. This prevents long jobs from starving short ones and allows for dynamic adjustment of priorities.

A1

Certainly, let's keep it concise:


Q-1. **CPU Scheduling and its necessity:**

   - CPU scheduling is the process of deciding which process to execute next when multiple processes are ready to run. It's necessary in operating systems to maximize CPU utilization, improve system throughput, and ensure fair allocation of resources.


Q-2. **Preemptive vs. Non-preemptive CPU scheduling:**

   - *Preemptive*: Allows a process to be interrupted and moved out of the CPU, typically by a higher-priority process. Increases responsiveness but can lead to more overhead.

   - *Non-preemptive*: Once a process starts executing, it continues until it completes or voluntarily relinquishes the CPU. Simpler but may result in longer response times for high-priority tasks.


Q-3. **FCFS vs. SJF scheduling:**

   - *FCFS*: Executes tasks in the order they arrive. Simple but may result in long waiting times for longer tasks, known as the "convoy effect".

   - *SJF*: Executes the shortest job first, minimizing average waiting time. However, it requires knowledge of job lengths in advance, which may not always be available.


Q-4. **Round Robin (RR) scheduling:**

   - RR assigns a fixed time slice (quantum) to each process in a cyclic manner. After a process's quantum expires, it's moved to the back of the ready queue.

   - Advantages include fairness and responsiveness, as every process gets a turn. However, it may lead to high overhead due to frequent context switches, especially with short time slices.


Q-5. **Purpose and benefits of multilevel queue scheduling:**

   - Multilevel queue scheduling categorizes processes into different queues based on properties such as priority or process type.

   - It improves performance by allowing different scheduling algorithms to be applied to different queues, tailoring scheduling to the characteristics of the jobs in each queue. For example, interactive tasks may have higher priority than batch tasks, leading to better responsiveness.


Q-6. **Thread vs. Process:**

   - A thread is a basic unit of CPU utilization within a process. Multiple threads can exist within the same process and share resources such as memory.

   - A process, on the other hand, is a program in execution, including its associated resources such as memory, file handles, and other system resources.

   - Threads within the same process share the same memory space and resources, while processes have separate memory spaces and resources. Threads are lighter-weight than processes and are typically used for concurrent execution within a program.


Comments

Popular posts from this blog

SE

2.16 - 2.20

Synchronization