What's the difference between Quantum and Timeslice ?

View: New views
3 Messages — Rating Filter:   Alert me  

What's the difference between Quantum and Timeslice ?

by lion :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi, All

        What's the difference between Quantum and Timeslice ?
Timeslice is used for thread scheduler. Then Quantum used for what ?

Thanks,

---
Best regards

Bo Liu


_________________________________________________________________
Discover the new Windows Vista
http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE


Re: What's the difference between Quantum and Timeslice ?

by Raphael Neider :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Bob,

>         What's the difference between Quantum and Timeslice ?
> Timeslice is used for thread scheduler. Then Quantum used for what ?

A new timeslice is allocated every time a thread is scheduled and (only)
serves to implement round-robin-scheduling: after at most "timeslice"
time, the thread is preempted and another thread can be scheduled. The
preempted thread may be scheduled again.

The (total) quantum was intended to limit the total time the thread may
spend executing on any CPU. It is decreased every time a timer interrupt
occurs (just like timeslices are, see schedule.cc,
handle_timer_interrupt()), but never reset automatically (only via a
schedule syscall). Once a thread runs out of time (no quantum left), it
will not be scheduled again (a preemption IPC should be sent to its
scheduler, but that's disabled due to major problems, see scheduler.cc,
total_quantum_expired()).

In short, the timeslice determines for how long a thread can
continuously occupy a CPU before being preempted, the quantum limits the
total time the thread may spend on the CPUs accumulated over all
occasions the thread was scheduled.

Regards,
Raphael


RE: What's the difference between Quantum and Timeslice ?

by lion :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Thanks Raphael.

I have got there differences now.

An addition question. In handle_timer_interrupt(schedule.cc),
why useing  (get_prio_queue(current)->current_timeslice -= get_timer_tick_length()) <= 0 to determine
whether end of a thread's timeslice?  
Why not just use "(tcb->current_timeslice -= get_timer_tick_length) <= 0".

So as in end_of_timeslice():
tcb->current_timeslice = prio_queue->current_timeslice + tcb->timeslice_length;
prio_queue->current_timeslice = prio_queue->get(get_priority (tcb))->current_timeslice;

Why there must  a prio_queue->current_timeslice but not just use tcb->timeslice ?

Thank you for you time!

---
Best regards

Bo Liu



> Date: Thu, 18 Sep 2008 11:04:12 +0200
> From: neider@...
> To: bo-liu@...; l4ka@...
> Subject: Re: What's the difference between Quantum and Timeslice ?
>
> Hi Bob,
>
>> What's the difference between Quantum and Timeslice ?
>> Timeslice is used for thread scheduler. Then Quantum used for what ?
>
> A new timeslice is allocated every time a thread is scheduled and (only)
> serves to implement round-robin-scheduling: after at most "timeslice"
> time, the thread is preempted and another thread can be scheduled. The
> preempted thread may be scheduled again.
>
> The (total) quantum was intended to limit the total time the thread may
> spend executing on any CPU. It is decreased every time a timer interrupt
> occurs (just like timeslices are, see schedule.cc,
> handle_timer_interrupt()), but never reset automatically (only via a
> schedule syscall). Once a thread runs out of time (no quantum left), it
> will not be scheduled again (a preemption IPC should be sent to its
> scheduler, but that's disabled due to major problems, see scheduler.cc,
> total_quantum_expired()).
>
> In short, the timeslice determines for how long a thread can
> continuously occupy a CPU before being preempted, the quantum limits the
> total time the thread may spend on the CPUs accumulated over all
> occasions the thread was scheduled.
>
> Regards,
> Raphael

_________________________________________________________________
Discover the new Windows Vista
http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE