1 //===-- tsan_rtl_proc.cc ------------------------------------------------===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // This file is a part of ThreadSanitizer (TSan), a race detector.
10 //===----------------------------------------------------------------------===//
12 #include "sanitizer_common/sanitizer_placement_new.h"
14 #include "tsan_mman.h"
15 #include "tsan_flags.h"
19 Processor
*ProcCreate() {
20 void *mem
= InternalAlloc(sizeof(Processor
));
21 internal_memset(mem
, 0, sizeof(Processor
));
22 Processor
*proc
= new(mem
) Processor
;
25 AllocatorProcStart(proc
);
27 if (common_flags()->detect_deadlocks
)
28 proc
->dd_pt
= ctx
->dd
->CreatePhysicalThread();
32 void ProcDestroy(Processor
*proc
) {
33 CHECK_EQ(proc
->thr
, nullptr);
35 AllocatorProcFinish(proc
);
37 ctx
->clock_alloc
.FlushCache(&proc
->clock_cache
);
38 ctx
->metamap
.OnProcIdle(proc
);
39 if (common_flags()->detect_deadlocks
)
40 ctx
->dd
->DestroyPhysicalThread(proc
->dd_pt
);
45 void ProcWire(Processor
*proc
, ThreadState
*thr
) {
46 CHECK_EQ(thr
->proc1
, nullptr);
47 CHECK_EQ(proc
->thr
, nullptr);
52 void ProcUnwire(Processor
*proc
, ThreadState
*thr
) {
53 CHECK_EQ(thr
->proc1
, proc
);
54 CHECK_EQ(proc
->thr
, thr
);