Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  Consider three CPU-intensive processes, which... Start Learning for Free
Consider three CPU-intensive processes, which require 10, 20 and 30 time units and arrive at times 0, 2 and 6, respectively. How many context switches are needed if the operating system implements a shortest remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end.
  • a)
    1
  • b)
    2
  • c)
    3
  • d)
    4
Correct answer is option 'B'. Can you explain this answer?
Verified Answer
Consider three CPU-intensive processes, which require 10, 20 and 30 ti...
Shortest remaining time, also known as shortest remaining time first (SRTF), is a scheduling method that is a pre-emptive version of shortest job next scheduling. In this scheduling algorithm, the process with the smallest amount of time remaining until completion is selected to execute. Since the currently executing process is the one with the shortest amount of time remaining by definition, and since that time should only reduce as execution progresses, processes will always run until they complete or a new process is added that requires a smaller amount of time. Solution: Let three process be P0, P1 and P2 with arrival times 0, 2 and 6 respectively and CPU burst times 10, 20 and 30 respectively. At time 0, P0 is the only available process so it runs. At time 2, P1 arrives, but P0 has the shortest remaining time, so it continues. At time 6, P2 also arrives, but P0 still has the shortest remaining time, so it continues. At time 10, P1 is scheduled as it is the shortest remaining time process. At time 30, P2 is scheduled. Only two context switches are needed. P0 to P1 and P1 to P2.
View all questions of this test
Most Upvoted Answer
Consider three CPU-intensive processes, which require 10, 20 and 30 ti...
Shortest Remaining Time First Scheduling Algorithm

- Shortest Remaining Time First is a preemptive CPU scheduling algorithm in which the process with the smallest amount of time remaining until completion is selected to execute.
- In this algorithm, the ready queue is always sorted by the remaining time of the processes.
- Whenever a new process arrives, it is compared with the currently executing process, and if the new process has a shorter remaining time, the currently executing process is preempted and the new process is scheduled for execution.

Given Processes

- Three CPU-intensive processes have been given with their arrival times and CPU burst times.
- Process 1: Arrival Time = 0, CPU Burst Time = 10
- Process 2: Arrival Time = 2, CPU Burst Time = 20
- Process 3: Arrival Time = 6, CPU Burst Time = 30

Calculation of Context Switches

- The processes will be executed in the following order based on their remaining CPU burst times:
- Process 1, Process 2, Process 3
- At time 0, Process 1 is the only process in the ready queue, so it is started and executed until completion without any context switch.
- At time 10, Process 2 arrives and has a shorter remaining time than Process 1, so Process 1 is preempted and Process 2 is scheduled for execution. This requires one context switch.
- At time 30, Process 3 arrives and has a shorter remaining time than Process 2, so Process 2 is preempted and Process 3 is scheduled for execution. This requires another context switch.
- Finally, at time 60, Process 3 completes its execution without any context switch.
- Therefore, the total number of context switches required is 2 (excluding the context switches at time 0 and at the end).
- Hence, option (B) is the correct answer.
Explore Courses for Computer Science Engineering (CSE) exam

Similar Computer Science Engineering (CSE) Doubts

Top Courses for Computer Science Engineering (CSE)

Consider three CPU-intensive processes, which require 10, 20 and 30 time units and arrive at times 0, 2 and 6, respectively. How many context switches are needed if the operating system implements a shortest remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end.a)1b)2c)3d)4Correct answer is option 'B'. Can you explain this answer?
Question Description
Consider three CPU-intensive processes, which require 10, 20 and 30 time units and arrive at times 0, 2 and 6, respectively. How many context switches are needed if the operating system implements a shortest remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end.a)1b)2c)3d)4Correct answer is option 'B'. Can you explain this answer? for Computer Science Engineering (CSE) 2024 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about Consider three CPU-intensive processes, which require 10, 20 and 30 time units and arrive at times 0, 2 and 6, respectively. How many context switches are needed if the operating system implements a shortest remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end.a)1b)2c)3d)4Correct answer is option 'B'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Consider three CPU-intensive processes, which require 10, 20 and 30 time units and arrive at times 0, 2 and 6, respectively. How many context switches are needed if the operating system implements a shortest remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end.a)1b)2c)3d)4Correct answer is option 'B'. Can you explain this answer?.
Solutions for Consider three CPU-intensive processes, which require 10, 20 and 30 time units and arrive at times 0, 2 and 6, respectively. How many context switches are needed if the operating system implements a shortest remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end.a)1b)2c)3d)4Correct answer is option 'B'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of Consider three CPU-intensive processes, which require 10, 20 and 30 time units and arrive at times 0, 2 and 6, respectively. How many context switches are needed if the operating system implements a shortest remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end.a)1b)2c)3d)4Correct answer is option 'B'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Consider three CPU-intensive processes, which require 10, 20 and 30 time units and arrive at times 0, 2 and 6, respectively. How many context switches are needed if the operating system implements a shortest remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end.a)1b)2c)3d)4Correct answer is option 'B'. Can you explain this answer?, a detailed solution for Consider three CPU-intensive processes, which require 10, 20 and 30 time units and arrive at times 0, 2 and 6, respectively. How many context switches are needed if the operating system implements a shortest remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end.a)1b)2c)3d)4Correct answer is option 'B'. Can you explain this answer? has been provided alongside types of Consider three CPU-intensive processes, which require 10, 20 and 30 time units and arrive at times 0, 2 and 6, respectively. How many context switches are needed if the operating system implements a shortest remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end.a)1b)2c)3d)4Correct answer is option 'B'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Consider three CPU-intensive processes, which require 10, 20 and 30 time units and arrive at times 0, 2 and 6, respectively. How many context switches are needed if the operating system implements a shortest remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end.a)1b)2c)3d)4Correct answer is option 'B'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev