2 * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
5 #ifndef _KERNEL_SCHEDULING_ANALYSIS_H
6 #define _KERNEL_SCHEDULING_ANALYSIS_H
9 #include <thread_defs.h>
12 struct ConditionVariable
;
17 #if SCHEDULING_ANALYSIS_TRACING
18 namespace SchedulingAnalysisTracing
{
20 class WaitObjectTraceEntry
: public AbstractTraceEntry
{
22 virtual uint32
Type() const = 0;
23 virtual void* Object() const = 0;
24 virtual const char* Name() const = 0;
26 virtual void* ReferencedObject() const
33 class CreateSemaphore
: public WaitObjectTraceEntry
{
35 CreateSemaphore(sem_id id
, const char* name
)
38 fName(alloc_tracing_buffer_strcpy(name
, 128, false))
43 virtual void AddDump(TraceOutput
& out
)
45 out
.Print("sem create \"%s\" -> %" B_PRId32
"", fName
, fID
);
48 virtual uint32
Type() const
50 return THREAD_BLOCK_TYPE_SEMAPHORE
;
53 virtual void* Object() const
55 return (void*)(addr_t
)fID
;
58 virtual const char* Name() const
69 class InitConditionVariable
: public WaitObjectTraceEntry
{
71 InitConditionVariable(ConditionVariable
* variable
, const void* object
,
72 const char* objectType
)
76 fObjectType(alloc_tracing_buffer_strcpy(objectType
, 128, false))
81 virtual void AddDump(TraceOutput
& out
)
83 out
.Print("cvar init variable %p: object: %p \"%s\"", fVariable
,
84 fObject
, fObjectType
);
87 virtual uint32
Type() const
89 return THREAD_BLOCK_TYPE_CONDITION_VARIABLE
;
92 virtual void* Object() const
97 virtual const char* Name() const
102 virtual void* ReferencedObject() const
104 return (void*)fObject
;
108 ConditionVariable
* fVariable
;
110 const char* fObjectType
;
114 class InitMutex
: public WaitObjectTraceEntry
{
116 InitMutex(mutex
* lock
, const char* name
)
119 fName(alloc_tracing_buffer_strcpy(name
, 128, false))
124 virtual void AddDump(TraceOutput
& out
)
126 out
.Print("mutex init %p: name: \"%s\"", fMutex
, fName
);
129 virtual uint32
Type() const
131 return THREAD_BLOCK_TYPE_MUTEX
;
134 virtual void* Object() const
139 virtual const char* Name() const
150 class InitRWLock
: public WaitObjectTraceEntry
{
152 InitRWLock(rw_lock
* lock
, const char* name
)
155 fName(alloc_tracing_buffer_strcpy(name
, 128, false))
160 virtual void AddDump(TraceOutput
& out
)
162 out
.Print("rwlock init %p: name: \"%s\"", fLock
, fName
);
165 virtual uint32
Type() const
167 return THREAD_BLOCK_TYPE_RW_LOCK
;
170 virtual void* Object() const
175 virtual const char* Name() const
185 } // namespace SchedulingAnalysisTracing
187 # define T_SCHEDULING_ANALYSIS(x) \
188 new(std::nothrow) SchedulingAnalysisTracing::x;
190 # define T_SCHEDULING_ANALYSIS(x) ;
191 #endif // SCHEDULING_ANALYSIS_TRACING
193 #endif // _KERNEL_SCHEDULING_ANALYSIS_H