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...
Explanation:
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...
First process for 0-10 sec second process for 10-28 sec third process for 28-58 sec. without considering the first and end context switch, there are 2 context switches in between.
Free Test
Community Answer
Consider three CPU-intensive processes, which require 10, 20 and 30 ti...
Explanation:

Arrival times and CPU burst times:
- Process P1 arrives at time 0 and requires 10 time units of CPU burst.
- Process P2 arrives at time 2 and requires 20 time units of CPU burst.
- Process P3 arrives at time 6 and requires 30 time units of CPU burst.

Shortest Remaining Time First (SRTF) scheduling:
- In SRTF scheduling, the process with the shortest remaining time is given the CPU next.
- At time 0, only P1 is available, so it starts executing.
- At time 2, P2 arrives, but P1 still has 8 units of CPU burst left, which is less than the remaining time of P2 (20 units). So, P1 continues to execute.
- At time 6, P3 arrives, but P1 still has 4 units of CPU burst left, which is less than the remaining time of P3 (30 units). So, P1 continues to execute.
- At time 10, P1 completes its execution, and P2 with 20 units of CPU burst becomes the shortest remaining time process and starts executing.
- At time 30, P2 completes its execution, and P3 with 30 units of CPU burst becomes the shortest remaining time process and starts executing.
- The total number of context switches required in this scenario is 2 (from P1 to P2 and from P2 to P3).
Therefore, the correct answer is option B) 2.
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