Multilevel Feedback queue preemptive - resumption - operating-system

Suppose I have a multilevel feedback queue with two round robins queues having time quanta 1 sec and 2 sec respectively.
Now let us consider a situation where two processes P1,P2 are in the second queue(lower priority) and P1 gets scheduled and after 1 second ( that is before the time quanta of P1 expired) process P3 comes into the top queue.
Since top queue is higher priority P1 is preempted and P3 is scheduled and after P3 is complete, now in the second queue, does P1 is resumed to complete its remaining time quanta (or) P2 is scheduled with a new timer

Related

Is it possible that you have the same arrival time in CPU Scheduling?

I have searched the internet for examples for the algorithms in cpu scheduling and I have never seen any examples with the same arrival time.
Is it possible to make the processes have the same arrival time?
For example:
Algorithm: Round Robin
Process ---- Arrival Time ----- Burst Time
P1 ----------------- 3 ------------------ 4 -----
P2 ----------------- 1 ------------------ 5 -----
P3 ----------------- 1 ------------------ 3 -----
Quantum = 1
What would be the gantt chart look like?
Is it possible to make the processes have the same arrival time?
Yes, for normal definitions of "same time" (e.g. excluding "in the same Planck time quantum") it's possible for processes to have the same arrival time.
For an example, imagine if 100 tasks sleep until midnight. When midnight occurs a timer IRQ handler processes a list of tasks waiting to wake up and wakes up 100 tasks at the "same" time.
Now, for this example you could say that "same time" is stricter; and that the timer IRQ handler processes the list of tasks sequentially and adds them to scheduler's queues sequentially, and that it's only "almost at the same time". In this case it's still possible to have N CPUs running in parallel (with a different timer for each CPU) that happen to wake (up to) N tasks at the same time.
Of Course, multiple processes can have the same arrival time i.e the time they came for looking the CPU to execute them. And its the responsibility of the Processor to handle and schedule them accordingly as per the appropriate Scheduling Algorithms.
When the Arrival time for two or more processes are same, then the RR-Scheduling follows FCFS {First come first serve} approach. Here in Round robin scheduling with quantum = 1, we have
Gantt Chart
At time 0, no process
At time 1 , we have P2 and P3 with P2 first then after a quantum RR executes P3,
At time 3 we have all three processes with order P2,P3,P1 hence the RR-Algorithm will keep switching between them until they complete their execution (burst) time.
And we will get all executed at time 13.

What has higher priority on MLFQ?

Hello I'm undergraduate student of computer programming
I take operating system class and I have question about MLFQ scheduling
Suppose that MLFQ has two ready queues, and they use both round-robin scheduling method which of time quantum is 3 seconds and 5 seconds each
Of course priority of Q1 is higher.
Then suppose that there are no ready process in Q1, so process in Q2 can be allocated on CPU.
However, a process that finished IO bound burst returns to Q1, and process in CPU which belonged to Q2 is not done(just 3 seconds gone)
In this situation, What happen?
Is the process in Q1 preempt the CPU right now?
Or process in CPU now(which is come from Q2) is allocated on CPU until time quantum of it(still 2 seconds needed) is reached?
Thank you for reading.
The process that arrives after completing I/O burst in Q1, will preempte the process in Q2. Quoting from the Operating Systems principles by Galvin,Gagne and Silberchatz:
A process that arrives in Q1, will preempt a process in Q2. A process
in Q1 will in turn be preempted by a process arriving in Q0(if Q0
exists).
SO,Any process that arrives in a higher priority Q, will preempt the process of a lower priority Q, even if the time quantum of lower process is not reached. A process gets to have the CPU as long as the ready Q of higher priority is empty.

Round Robin Scheduling with arrival time and priority level

I have this Round Robin problem that I was wondering whether it was correct or not. The lower the number the higher the priority.
The Table is:
p0 p1 p2
Arrival Time 3ms 0ms 1ms
Burst Time 3ms 25ms 7ms
Priority 1 7 5
With a time quantum of 5 ms.
This is my Gantt Chart:
p1 p2 p0 p2 p1
0----1----3----6----11------------------------35
My understanding is that if it is preemptive and using priority then if during any given time a process with a higher priority enters the ready queue and the current process has a lower priority then it is preempted. Is my chart correct?

Related to Scheduling: aging

Can any one guide how to implement Process Aging?
I would Like to know on what factors does this Aging factor depend on?
According to me, it should depend on present priority and average waiting time.
How do I implement averaging waiting time?
Can any one please give clear idea on it?
The process aging should depend only on the waiting time (according to the original concept) of the process. Based on its original idea, the priority of a process will be increased accordingly to the time it is waiting in the ready queue.
read the process arrival time, burst time, process id, priority from the text file and calculate the average waiting time and show the cpu utilization of each cycle like this,
Time 1 P3 arrives
Time 1 P3 runs
Time 2 P5 arrives
Time 2 P3 runs
Time 10 P1 arrives
Time 10 P3 runs
Time 13 P3 finishes
Time 13 P5 runs
Time 16 P4 arrives
Time 16 P5 runs
Time 53 P5 finishes
Time 53 P1 runs
Time 82 P1 finishes
Time 82 P4 runs
Time 112 P4 finishes

Shortest Remaining Time First Query

If they are two processes with the following Data, How should the Gantt Chart be?(SRTF scheduling)
Process Arrival Burst
P1 0 17
P2 1 16
So will the process P1 be completed first and then P2 will start executing..or P1 will have to wait for 16 milli seconds?
I feel the conflict can be resolved either by choosing the process which came earlier or by the process which has the longest burst. In this case, on choosing either of the approaches, P1 will be completed first.
It's going to choose P1 because at the time P2 didn't exist
P1 AT =0 thus will start first
next step they will be equal but as the processor is working already on p1 it will prefer to keep working on it until interruption or termination
In this case it gets P2 at 1, then it checks for remaining time. As both remaining times are same, it put new process; P2 in the queue for next execution(after P1's completion).