* Why Completely Fair Scheduler(CFS) using Red-Black tree instead of Min-heap?
@ 2015-10-17 18:25 venu gangireddy
2015-10-18 6:55 ` Nicholas Mc Guire
2015-10-18 7:35 ` anish singh
0 siblings, 2 replies; 3+ messages in thread
From: venu gangireddy @ 2015-10-17 18:25 UTC (permalink / raw)
To: kernelnewbies
Hi,
Currently, I am learning about CFS scheduler in linux, and I want to know
reason about the data structure chooses in CFS implementation.
CFS scheduler picks next process based on minimum virtual time and to get
this value efficiently its using Red-Black tree(rbtree), using rbtree we
will get minimum O(h) here h is height of rbtree. But, using min-heap we
can get min virtual time process in O(1) time only. I just want to know why
min-heap is not consider in CFS implementation and is there any
difficulties using min-heap in kernel level?
Thanks in advance.
--
*Regards,*
*Venugopal Reddy.*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20151017/ed7f3ade/attachment.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Why Completely Fair Scheduler(CFS) using Red-Black tree instead of Min-heap?
2015-10-17 18:25 Why Completely Fair Scheduler(CFS) using Red-Black tree instead of Min-heap? venu gangireddy
@ 2015-10-18 6:55 ` Nicholas Mc Guire
2015-10-18 7:35 ` anish singh
1 sibling, 0 replies; 3+ messages in thread
From: Nicholas Mc Guire @ 2015-10-18 6:55 UTC (permalink / raw)
To: kernelnewbies
On Sat, Oct 17, 2015 at 11:55:29PM +0530, venu gangireddy wrote:
> Hi,
>
> Currently, I am learning about CFS scheduler in linux, and I want to know
> reason about the data structure chooses in CFS implementation.
>
> CFS scheduler picks next process based on minimum virtual time and to get
> this value efficiently its using Red-Black tree(rbtree), using rbtree we
> will get minimum O(h) here h is height of rbtree. But, using min-heap we
> can get min virtual time process in O(1) time only. I just want to know why
hmm... min heap insertion/deletion is O(log N) as you may have to swap up to
log N elements in the tree.
> min-heap is not consider in CFS implementation and is there any
> difficulties using min-heap in kernel level?
>
I don't think there is any fundamental obstacle to use min-heap
but the advantage is not clear to me - a rbtree is self-balancing so
search will stay O(log N) while in non-balanced trees it can
degenerate to O(n). If you always only need min/max then min-heap
could have an advantage - but if that is actually the
case in the scheduler I don't know. I suspect that the main reason
for rbtrees is simply that they have a constant cost for all of
the operations which reduces strange corner-case behavior.
thx!
hofrat
^ permalink raw reply [flat|nested] 3+ messages in thread
* Why Completely Fair Scheduler(CFS) using Red-Black tree instead of Min-heap?
2015-10-17 18:25 Why Completely Fair Scheduler(CFS) using Red-Black tree instead of Min-heap? venu gangireddy
2015-10-18 6:55 ` Nicholas Mc Guire
@ 2015-10-18 7:35 ` anish singh
1 sibling, 0 replies; 3+ messages in thread
From: anish singh @ 2015-10-18 7:35 UTC (permalink / raw)
To: kernelnewbies
On Sat, Oct 17, 2015 at 11:25 AM, venu gangireddy <venu.gangireddy@gmail.com
> wrote:
> Hi,
>
> Currently, I am learning about CFS scheduler in linux, and I want to know
> reason about the data structure chooses in CFS implementation.
>
> Nice.
> CFS scheduler picks next process based on minimum virtual time and to get
> this value efficiently its using Red-Black tree(rbtree), using rbtree we
> will get minimum O(h) here h is height of rbtree. But, using min-heap we
> can get min virtual time process in O(1) time only. I just want to know why
> min-heap is not consider in CFS implementation and is there any
> difficulties using min-heap in kernel level?
>
I am not an expert in algorithms, but it seems that after o(1) peek you
should perform heapify (which is o(log n)) to restore heap property. So
give the reference to the implementation you talking about if I am wrong.
>
>
> Thanks in advance.
>
> --
>
> *Regards,*
> *Venugopal Reddy.*
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20151018/1696f7c1/attachment.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-10-18 7:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-17 18:25 Why Completely Fair Scheduler(CFS) using Red-Black tree instead of Min-heap? venu gangireddy
2015-10-18 6:55 ` Nicholas Mc Guire
2015-10-18 7:35 ` anish singh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).