btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / headers / private / kernel / scheduling_analysis.h
blobfa2e9209a569b9743a5d51a3ef1894079e3843fe
1 /*
2 * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _KERNEL_SCHEDULING_ANALYSIS_H
6 #define _KERNEL_SCHEDULING_ANALYSIS_H
8 #include <tracing.h>
9 #include <thread_defs.h>
12 struct ConditionVariable;
13 struct mutex;
14 struct rw_lock;
17 #if SCHEDULING_ANALYSIS_TRACING
18 namespace SchedulingAnalysisTracing {
20 class WaitObjectTraceEntry : public AbstractTraceEntry {
21 public:
22 virtual uint32 Type() const = 0;
23 virtual void* Object() const = 0;
24 virtual const char* Name() const = 0;
26 virtual void* ReferencedObject() const
28 return NULL;
33 class CreateSemaphore : public WaitObjectTraceEntry {
34 public:
35 CreateSemaphore(sem_id id, const char* name)
37 fID(id),
38 fName(alloc_tracing_buffer_strcpy(name, 128, false))
40 Initialized();
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
60 return fName;
63 private:
64 sem_id fID;
65 const char* fName;
69 class InitConditionVariable : public WaitObjectTraceEntry {
70 public:
71 InitConditionVariable(ConditionVariable* variable, const void* object,
72 const char* objectType)
74 fVariable(variable),
75 fObject(object),
76 fObjectType(alloc_tracing_buffer_strcpy(objectType, 128, false))
78 Initialized();
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
94 return fVariable;
97 virtual const char* Name() const
99 return fObjectType;
102 virtual void* ReferencedObject() const
104 return (void*)fObject;
107 private:
108 ConditionVariable* fVariable;
109 const void* fObject;
110 const char* fObjectType;
114 class InitMutex : public WaitObjectTraceEntry {
115 public:
116 InitMutex(mutex* lock, const char* name)
118 fMutex(lock),
119 fName(alloc_tracing_buffer_strcpy(name, 128, false))
121 Initialized();
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
136 return fMutex;
139 virtual const char* Name() const
141 return fName;
144 private:
145 mutex* fMutex;
146 const char* fName;
150 class InitRWLock : public WaitObjectTraceEntry {
151 public:
152 InitRWLock(rw_lock* lock, const char* name)
154 fLock(lock),
155 fName(alloc_tracing_buffer_strcpy(name, 128, false))
157 Initialized();
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
172 return fLock;
175 virtual const char* Name() const
177 return fName;
180 private:
181 rw_lock* fLock;
182 const char* fName;
185 } // namespace SchedulingAnalysisTracing
187 # define T_SCHEDULING_ANALYSIS(x) \
188 new(std::nothrow) SchedulingAnalysisTracing::x;
189 #else
190 # define T_SCHEDULING_ANALYSIS(x) ;
191 #endif // SCHEDULING_ANALYSIS_TRACING
193 #endif // _KERNEL_SCHEDULING_ANALYSIS_H