+def SchedPriorityStableQueueRootPri(root, element_type, field_name):
+ """ Return the root level priority of a priority queue as defined with struct priority_queue from osfmk/kern/priority_queue.h
+ root - value : Value object for the priority queue
+ element_type - str : Type of the link element
+ field_name - str : Name of the field in link element's structure
+ returns:
+ The sched pri of the root element.
+ """
+ def _make_pqe(addr):
+ return value(root.GetSBValue().CreateValueFromExpression(None,'(struct priority_queue_entry_stable *)'+str(addr)))
+
+ elt = _make_pqe(unsigned(root.pq_root))
+ return (elt.key >> 8);
+