The thread model does now also store the scheduling events for the thread.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30506 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -83,3 +83,46 @@ ThreadModel::AddWaitObjectGroup(
|
|||||||
|
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
ThreadModel::AddSchedulingEvent(const system_profiler_event_header* eventHeader)
|
||||||
|
{
|
||||||
|
return fSchedulingEvents.AddItem(eventHeader);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32
|
||||||
|
ThreadModel::FindSchedulingEvent(bigtime_t time)
|
||||||
|
{
|
||||||
|
if (time < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
time += fModel->BaseTime();
|
||||||
|
|
||||||
|
int32 lower = 0;
|
||||||
|
int32 upper = CountSchedulingEvents();
|
||||||
|
|
||||||
|
while (lower < upper) {
|
||||||
|
int32 mid = (lower + upper) / 2;
|
||||||
|
const system_profiler_event_header* header = SchedulingEventAt(mid);
|
||||||
|
system_profiler_thread_scheduling_event* event
|
||||||
|
= (system_profiler_thread_scheduling_event*)(header + 1);
|
||||||
|
if (event->time < time)
|
||||||
|
lower = mid + 1;
|
||||||
|
else
|
||||||
|
upper = mid;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We've found the first event that has a time >= the given time. If its
|
||||||
|
// time is >, we rather return the previous event.
|
||||||
|
if (lower > 0) {
|
||||||
|
const system_profiler_event_header* header = SchedulingEventAt(lower);
|
||||||
|
system_profiler_thread_scheduling_event* event
|
||||||
|
= (system_profiler_thread_scheduling_event*)(header + 1);
|
||||||
|
if (event->time > time)
|
||||||
|
lower--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lower;
|
||||||
|
}
|
||||||
|
|||||||
@@ -30,13 +30,23 @@ public:
|
|||||||
inline int32 CountWaitObjectGroups() const;
|
inline int32 CountWaitObjectGroups() const;
|
||||||
inline WaitObjectGroup* WaitObjectGroupAt(int32 index) const;
|
inline WaitObjectGroup* WaitObjectGroupAt(int32 index) const;
|
||||||
|
|
||||||
|
bool AddSchedulingEvent(
|
||||||
|
const system_profiler_event_header*
|
||||||
|
eventHeader);
|
||||||
|
inline int32 CountSchedulingEvents() const;
|
||||||
|
inline const system_profiler_event_header* SchedulingEventAt(
|
||||||
|
int32 index) const;
|
||||||
|
int32 FindSchedulingEvent(bigtime_t time);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef BObjectList<WaitObjectGroup> WaitObjectGroupList;
|
typedef BObjectList<WaitObjectGroup> WaitObjectGroupList;
|
||||||
|
typedef BObjectList<const system_profiler_event_header> EventList;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Model* fModel;
|
Model* fModel;
|
||||||
Model::Thread* fThread;
|
Model::Thread* fThread;
|
||||||
WaitObjectGroupList fWaitObjectGroups;
|
WaitObjectGroupList fWaitObjectGroups;
|
||||||
|
EventList fSchedulingEvents;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -93,6 +103,20 @@ ThreadModel::WaitObjectGroupAt(int32 index) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32
|
||||||
|
ThreadModel::CountSchedulingEvents() const
|
||||||
|
{
|
||||||
|
return fSchedulingEvents.CountItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const system_profiler_event_header*
|
||||||
|
ThreadModel::SchedulingEventAt(int32 index) const
|
||||||
|
{
|
||||||
|
return fSchedulingEvents.ItemAt(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - WaitObjectGroup
|
// #pragma mark - WaitObjectGroup
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user