source: libcfa/src/concurrency/kernel.cfa@ 442b624

ADT arm-eh ast-experimental enum forall-pointer-decay jacob/cs343-translation new-ast-unique-expr pthread-emulation qualifiedEnum
Last change on this file since 442b624 was 74f5c83, checked in by Peter A. Buhr <pabuhr@…>, 5 years ago

assembler for save/restore registers FPSR/FPCR for ARM

  • Property mode set to 100644
File size: 20.8 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// kernel.c --
8//
9// Author : Thierry Delisle
10// Created On : Tue Jan 17 12:27:26 2017
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Fri Aug 14 15:23:00 2020
13// Update Count : 69
14//
15
16#define __cforall_thread__
17// #define __CFA_DEBUG_PRINT_RUNTIME_CORE__
18
19//C Includes
20#include <errno.h>
21#include <stdio.h>
22#include <signal.h>
23#include <unistd.h>
24
25//CFA Includes
26#include "kernel_private.hfa"
27#include "preemption.hfa"
28
29//Private includes
30#define __CFA_INVOKE_PRIVATE__
31#include "invoke.h"
32
33
34//-----------------------------------------------------------------------------
35// Some assembly required
36#if defined( __i386 )
37 // mxcr : SSE Status and Control bits (control bits are preserved across function calls)
38 // fcw : X87 FPU control word (preserved across function calls)
39 #define __x87_store \
40 uint32_t __mxcr; \
41 uint16_t __fcw; \
42 __asm__ volatile ( \
43 "stmxcsr %0\n" \
44 "fnstcw %1\n" \
45 : "=m" (__mxcr),\
46 "=m" (__fcw) \
47 )
48
49 #define __x87_load \
50 __asm__ volatile ( \
51 "fldcw %1\n" \
52 "ldmxcsr %0\n" \
53 ::"m" (__mxcr),\
54 "m" (__fcw) \
55 )
56
57#elif defined( __x86_64 )
58 #define __x87_store \
59 uint32_t __mxcr; \
60 uint16_t __fcw; \
61 __asm__ volatile ( \
62 "stmxcsr %0\n" \
63 "fnstcw %1\n" \
64 : "=m" (__mxcr),\
65 "=m" (__fcw) \
66 )
67
68 #define __x87_load \
69 __asm__ volatile ( \
70 "fldcw %1\n" \
71 "ldmxcsr %0\n" \
72 :: "m" (__mxcr),\
73 "m" (__fcw) \
74 )
75
76#elif defined( __ARM_ARCH )
77 #define __x87_store \
78 uint32_t __fpcntl[2]; \
79 __asm__ volatile ( \
80 "mrs x9, FPCR\n" \
81 "mrs x10, FPSR\n" \
82 "stp x9, x10, %0\n" \
83 : "=m" (__fpcntl) : : "x9", "x10" \
84 )
85
86 #define __x87_load \
87 __asm__ volatile ( \
88 "ldp x9, x10, %0\n" \
89 "msr FPSR, x10\n" \
90 "msr FPCR, x9\n" \
91 : "=m" (__fpcntl) : : "x9", "x10" \
92 )
93
94#else
95 #error unknown hardware architecture
96#endif
97
98extern $thread * mainThread;
99extern processor * mainProcessor;
100
101//-----------------------------------------------------------------------------
102// Kernel Scheduling logic
103static $thread * __next_thread(cluster * this);
104static bool __has_next_thread(cluster * this);
105static void __run_thread(processor * this, $thread * dst);
106static bool __wake_one(struct __processor_id_t * id, cluster * cltr);
107static void __halt(processor * this);
108bool __wake_proc(processor *);
109
110//=============================================================================================
111// Kernel Scheduling logic
112//=============================================================================================
113//Main of the processor contexts
114void main(processorCtx_t & runner) {
115 // Because of a bug, we couldn't initialized the seed on construction
116 // Do it here
117 kernelTLS.rand_seed ^= rdtscl();
118
119 processor * this = runner.proc;
120 verify(this);
121
122 __cfadbg_print_safe(runtime_core, "Kernel : core %p starting\n", this);
123 #if !defined(__CFA_NO_STATISTICS__)
124 if( this->print_halts ) {
125 __cfaabi_bits_print_safe( STDOUT_FILENO, "Processor : %d - %s (%p)\n", this->id, this->name, (void*)this);
126 }
127 #endif
128
129 {
130 // Setup preemption data
131 preemption_scope scope = { this };
132
133 __cfadbg_print_safe(runtime_core, "Kernel : core %p started\n", this);
134
135 $thread * readyThread = 0p;
136 for( unsigned int spin_count = 0;; spin_count++ ) {
137 // Try to get the next thread
138 readyThread = __next_thread( this->cltr );
139
140 // Check if we actually found a thread
141 if( readyThread ) {
142 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
143 /* paranoid */ verifyf( readyThread->state == Ready || readyThread->preempted != __NO_PREEMPTION, "state : %d, preempted %d\n", readyThread->state, readyThread->preempted);
144 /* paranoid */ verifyf( readyThread->link.next == 0p, "Expected null got %p", readyThread->link.next );
145 __builtin_prefetch( readyThread->context.SP );
146
147 // We found a thread run it
148 __run_thread(this, readyThread);
149
150 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
151 }
152
153 if(__atomic_load_n(&this->do_terminate, __ATOMIC_SEQ_CST)) break;
154
155 if( !readyThread ) {
156 // Block until a thread is ready
157 __halt(this);
158 }
159 }
160
161 __cfadbg_print_safe(runtime_core, "Kernel : core %p stopping\n", this);
162 }
163
164 V( this->terminated );
165
166 if(this == mainProcessor) {
167 // HACK : the coroutine context switch expects this_thread to be set
168 // and it make sense for it to be set in all other cases except here
169 // fake it
170 kernelTLS.this_thread = mainThread;
171 }
172
173 __cfadbg_print_safe(runtime_core, "Kernel : core %p terminated\n", this);
174}
175
176static int * __volatile_errno() __attribute__((noinline));
177static int * __volatile_errno() { asm(""); return &errno; }
178
179// KERNEL ONLY
180// runThread runs a thread by context switching
181// from the processor coroutine to the target thread
182static void __run_thread(processor * this, $thread * thrd_dst) {
183 $coroutine * proc_cor = get_coroutine(this->runner);
184
185 // Update global state
186 kernelTLS.this_thread = thrd_dst;
187
188 // set state of processor coroutine to inactive
189 verify(proc_cor->state == Active);
190 proc_cor->state = Blocked;
191
192 // Actually run the thread
193 RUNNING: while(true) {
194 thrd_dst->preempted = __NO_PREEMPTION;
195 thrd_dst->state = Active;
196
197 __cfaabi_dbg_debug_do(
198 thrd_dst->park_stale = true;
199 thrd_dst->unpark_stale = true;
200 )
201
202 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
203 /* paranoid */ verify( kernelTLS.this_thread == thrd_dst );
204 /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) < ((uintptr_t)__get_stack(thrd_dst->curr_cor)->base ) || thrd_dst->curr_cor == proc_cor, "ERROR : Destination $thread %p has been corrupted.\n StackPointer too small.\n", thrd_dst ); // add escape condition if we are setting up the processor
205 /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) > ((uintptr_t)__get_stack(thrd_dst->curr_cor)->limit) || thrd_dst->curr_cor == proc_cor, "ERROR : Destination $thread %p has been corrupted.\n StackPointer too large.\n", thrd_dst ); // add escape condition if we are setting up the processor
206
207 // set context switch to the thread that the processor is executing
208 verify( thrd_dst->context.SP );
209 __cfactx_switch( &proc_cor->context, &thrd_dst->context );
210 // when __cfactx_switch returns we are back in the processor coroutine
211
212 /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) > ((uintptr_t)__get_stack(thrd_dst->curr_cor)->limit), "ERROR : Destination $thread %p has been corrupted.\n StackPointer too large.\n", thrd_dst );
213 /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) < ((uintptr_t)__get_stack(thrd_dst->curr_cor)->base ), "ERROR : Destination $thread %p has been corrupted.\n StackPointer too small.\n", thrd_dst );
214 /* paranoid */ verify( kernelTLS.this_thread == thrd_dst );
215 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
216
217
218 // We just finished running a thread, there are a few things that could have happened.
219 // 1 - Regular case : the thread has blocked and now one has scheduled it yet.
220 // 2 - Racy case : the thread has blocked but someone has already tried to schedule it.
221 // 4 - Preempted
222 // In case 1, we may have won a race so we can't write to the state again.
223 // In case 2, we lost the race so we now own the thread.
224
225 if(unlikely(thrd_dst->preempted != __NO_PREEMPTION)) {
226 // The thread was preempted, reschedule it and reset the flag
227 __schedule_thread( (__processor_id_t*)this, thrd_dst );
228 break RUNNING;
229 }
230
231 if(unlikely(thrd_dst->state == Halted)) {
232 // The thread has halted, it should never be scheduled/run again
233 // We may need to wake someone up here since
234 unpark( this->destroyer __cfaabi_dbg_ctx2 );
235 this->destroyer = 0p;
236 break RUNNING;
237 }
238
239 /* paranoid */ verify( thrd_dst->state == Active );
240 thrd_dst->state = Blocked;
241
242 // set state of processor coroutine to active and the thread to inactive
243 int old_ticket = __atomic_fetch_sub(&thrd_dst->ticket, 1, __ATOMIC_SEQ_CST);
244 __cfaabi_dbg_debug_do( thrd_dst->park_result = old_ticket; )
245 switch(old_ticket) {
246 case 1:
247 // This is case 1, the regular case, nothing more is needed
248 break RUNNING;
249 case 2:
250 // This is case 2, the racy case, someone tried to run this thread before it finished blocking
251 // In this case, just run it again.
252 continue RUNNING;
253 default:
254 // This makes no sense, something is wrong abort
255 abort();
256 }
257 }
258
259 // Just before returning to the processor, set the processor coroutine to active
260 proc_cor->state = Active;
261 kernelTLS.this_thread = 0p;
262}
263
264// KERNEL_ONLY
265void returnToKernel() {
266 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
267 $coroutine * proc_cor = get_coroutine(kernelTLS.this_processor->runner);
268 $thread * thrd_src = kernelTLS.this_thread;
269
270 #if !defined(__CFA_NO_STATISTICS__)
271 struct processor * last_proc = kernelTLS.this_processor;
272 #endif
273
274 // Run the thread on this processor
275 {
276 int local_errno = *__volatile_errno();
277 #if defined( __i386 ) || defined( __x86_64 )
278 __x87_store;
279 #endif
280 verify( proc_cor->context.SP );
281 __cfactx_switch( &thrd_src->context, &proc_cor->context );
282 #if defined( __i386 ) || defined( __x86_64 )
283 __x87_load;
284 #endif
285 *__volatile_errno() = local_errno;
286 }
287
288 #if !defined(__CFA_NO_STATISTICS__)
289 if(last_proc != kernelTLS.this_processor) {
290 __tls_stats()->ready.threads.migration++;
291 }
292 #endif
293
294 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
295 /* paranoid */ verifyf( ((uintptr_t)thrd_src->context.SP) < ((uintptr_t)__get_stack(thrd_src->curr_cor)->base ), "ERROR : Returning $thread %p has been corrupted.\n StackPointer too small.\n", thrd_src );
296 /* paranoid */ verifyf( ((uintptr_t)thrd_src->context.SP) > ((uintptr_t)__get_stack(thrd_src->curr_cor)->limit), "ERROR : Returning $thread %p has been corrupted.\n StackPointer too large.\n", thrd_src );
297}
298
299//-----------------------------------------------------------------------------
300// Scheduler routines
301// KERNEL ONLY
302void __schedule_thread( struct __processor_id_t * id, $thread * thrd ) {
303 /* paranoid */ verify( thrd );
304 /* paranoid */ verify( thrd->state != Halted );
305 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
306 /* paranoid */ #if defined( __CFA_WITH_VERIFY__ )
307 /* paranoid */ if( thrd->state == Blocked || thrd->state == Start ) assertf( thrd->preempted == __NO_PREEMPTION,
308 "Error inactive thread marked as preempted, state %d, preemption %d\n", thrd->state, thrd->preempted );
309 /* paranoid */ if( thrd->preempted != __NO_PREEMPTION ) assertf(thrd->state == Active,
310 "Error preempted thread marked as not currently running, state %d, preemption %d\n", thrd->state, thrd->preempted );
311 /* paranoid */ #endif
312 /* paranoid */ verifyf( thrd->link.next == 0p, "Expected null got %p", thrd->link.next );
313
314 if (thrd->preempted == __NO_PREEMPTION) thrd->state = Ready;
315
316 ready_schedule_lock ( id );
317 push( thrd->curr_cluster, thrd );
318
319 #if !defined(__CFA_NO_STATISTICS__)
320 bool woke =
321 #endif
322 __wake_one(id, thrd->curr_cluster);
323
324 #if !defined(__CFA_NO_STATISTICS__)
325 if(woke) __tls_stats()->ready.sleep.wakes++;
326 #endif
327 ready_schedule_unlock( id );
328
329 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
330}
331
332// KERNEL ONLY
333static $thread * __next_thread(cluster * this) with( *this ) {
334 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
335
336 ready_schedule_lock ( (__processor_id_t*)kernelTLS.this_processor );
337 $thread * head = pop( this );
338 ready_schedule_unlock( (__processor_id_t*)kernelTLS.this_processor );
339
340 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
341 return head;
342}
343
344// KERNEL ONLY
345static bool __has_next_thread(cluster * this) with( *this ) {
346 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
347
348 ready_schedule_lock ( (__processor_id_t*)kernelTLS.this_processor );
349 bool not_empty = query( this );
350 ready_schedule_unlock( (__processor_id_t*)kernelTLS.this_processor );
351
352 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
353 return not_empty;
354}
355
356// KERNEL ONLY unpark with out disabling interrupts
357void __unpark( struct __processor_id_t * id, $thread * thrd __cfaabi_dbg_ctx_param2 ) {
358 // record activity
359 __cfaabi_dbg_record_thrd( *thrd, false, caller );
360
361 int old_ticket = __atomic_fetch_add(&thrd->ticket, 1, __ATOMIC_SEQ_CST);
362 __cfaabi_dbg_debug_do( thrd->unpark_result = old_ticket; thrd->unpark_state = thrd->state; )
363 switch(old_ticket) {
364 case 1:
365 // Wake won the race, the thread will reschedule/rerun itself
366 break;
367 case 0:
368 /* paranoid */ verify( ! thrd->preempted != __NO_PREEMPTION );
369 /* paranoid */ verify( thrd->state == Blocked );
370
371 // Wake lost the race,
372 __schedule_thread( id, thrd );
373 break;
374 default:
375 // This makes no sense, something is wrong abort
376 abort();
377 }
378}
379
380void unpark( $thread * thrd __cfaabi_dbg_ctx_param2 ) {
381 if( !thrd ) return;
382
383 disable_interrupts();
384 __unpark( (__processor_id_t*)kernelTLS.this_processor, thrd __cfaabi_dbg_ctx_fwd2 );
385 enable_interrupts( __cfaabi_dbg_ctx );
386}
387
388void park( __cfaabi_dbg_ctx_param ) {
389 /* paranoid */ verify( kernelTLS.preemption_state.enabled );
390 disable_interrupts();
391 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
392 /* paranoid */ verify( kernelTLS.this_thread->preempted == __NO_PREEMPTION );
393
394 // record activity
395 __cfaabi_dbg_record_thrd( *kernelTLS.this_thread, true, caller );
396
397 returnToKernel();
398
399 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
400 enable_interrupts( __cfaabi_dbg_ctx );
401 /* paranoid */ verify( kernelTLS.preemption_state.enabled );
402
403}
404
405// KERNEL ONLY
406void __leave_thread() {
407 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
408 returnToKernel();
409 abort();
410}
411
412// KERNEL ONLY
413bool force_yield( __Preemption_Reason reason ) {
414 /* paranoid */ verify( kernelTLS.preemption_state.enabled );
415 disable_interrupts();
416 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
417
418 $thread * thrd = kernelTLS.this_thread;
419 /* paranoid */ verify(thrd->state == Active);
420
421 // SKULLDUGGERY: It is possible that we are preempting this thread just before
422 // it was going to park itself. If that is the case and it is already using the
423 // intrusive fields then we can't use them to preempt the thread
424 // If that is the case, abandon the preemption.
425 bool preempted = false;
426 if(thrd->link.next == 0p) {
427 preempted = true;
428 thrd->preempted = reason;
429 returnToKernel();
430 }
431
432 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
433 enable_interrupts_noPoll();
434 /* paranoid */ verify( kernelTLS.preemption_state.enabled );
435
436 return preempted;
437}
438
439//=============================================================================================
440// Kernel Idle Sleep
441//=============================================================================================
442// Wake a thread from the front if there are any
443static bool __wake_one(struct __processor_id_t * id, cluster * this) {
444 /* paranoid */ verify( ready_schedule_islocked( id ) );
445
446 // Check if there is a sleeping processor
447 processor * p = pop(this->idles);
448
449 // If no one is sleeping, we are done
450 if( 0p == p ) return false;
451
452 // We found a processor, wake it up
453 post( p->idle );
454
455 return true;
456}
457
458// Unconditionnaly wake a thread
459bool __wake_proc(processor * this) {
460 __cfadbg_print_safe(runtime_core, "Kernel : waking Processor %p\n", this);
461
462 disable_interrupts();
463 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
464 bool ret = post( this->idle );
465 enable_interrupts( __cfaabi_dbg_ctx );
466
467 return ret;
468}
469
470static void __halt(processor * this) with( *this ) {
471 if( do_terminate ) return;
472
473 #if !defined(__CFA_NO_STATISTICS__)
474 __tls_stats()->ready.sleep.halts++;
475 #endif
476 // Push self to queue
477 push(cltr->idles, *this);
478
479 // Makre sure we don't miss a thread
480 if( __has_next_thread(cltr) ) {
481 // A thread was posted, make sure a processor is woken up
482 struct __processor_id_t *id = (struct __processor_id_t *) this;
483 ready_schedule_lock ( id );
484 __wake_one( id, cltr );
485 ready_schedule_unlock( id );
486 #if !defined(__CFA_NO_STATISTICS__)
487 __tls_stats()->ready.sleep.cancels++;
488 #endif
489 }
490
491 #if !defined(__CFA_NO_STATISTICS__)
492 if(this->print_halts) {
493 __cfaabi_bits_print_safe( STDOUT_FILENO, "PH:%d - %lld 0\n", this->id, rdtscl());
494 }
495 #endif
496
497 wait( idle );
498
499 #if !defined(__CFA_NO_STATISTICS__)
500 if(this->print_halts) {
501 __cfaabi_bits_print_safe( STDOUT_FILENO, "PH:%d - %lld 1\n", this->id, rdtscl());
502 }
503 #endif
504}
505
506//=============================================================================================
507// Unexpected Terminating logic
508//=============================================================================================
509static __spinlock_t kernel_abort_lock;
510static bool kernel_abort_called = false;
511
512void * kernel_abort(void) __attribute__ ((__nothrow__)) {
513 // abort cannot be recursively entered by the same or different processors because all signal handlers return when
514 // the globalAbort flag is true.
515 lock( kernel_abort_lock __cfaabi_dbg_ctx2 );
516
517 // first task to abort ?
518 if ( kernel_abort_called ) { // not first task to abort ?
519 unlock( kernel_abort_lock );
520
521 sigset_t mask;
522 sigemptyset( &mask );
523 sigaddset( &mask, SIGALRM ); // block SIGALRM signals
524 sigaddset( &mask, SIGUSR1 ); // block SIGALRM signals
525 sigsuspend( &mask ); // block the processor to prevent further damage during abort
526 _exit( EXIT_FAILURE ); // if processor unblocks before it is killed, terminate it
527 }
528 else {
529 kernel_abort_called = true;
530 unlock( kernel_abort_lock );
531 }
532
533 return kernelTLS.this_thread;
534}
535
536void kernel_abort_msg( void * kernel_data, char * abort_text, int abort_text_size ) {
537 $thread * thrd = ( $thread * ) kernel_data;
538
539 if(thrd) {
540 int len = snprintf( abort_text, abort_text_size, "Error occurred while executing thread %.256s (%p)", thrd->self_cor.name, thrd );
541 __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
542
543 if ( &thrd->self_cor != thrd->curr_cor ) {
544 len = snprintf( abort_text, abort_text_size, " in coroutine %.256s (%p).\n", thrd->curr_cor->name, thrd->curr_cor );
545 __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
546 }
547 else {
548 __cfaabi_bits_write( STDERR_FILENO, ".\n", 2 );
549 }
550 }
551 else {
552 int len = snprintf( abort_text, abort_text_size, "Error occurred outside of any thread.\n" );
553 __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
554 }
555}
556
557int kernel_abort_lastframe( void ) __attribute__ ((__nothrow__)) {
558 return get_coroutine(kernelTLS.this_thread) == get_coroutine(mainThread) ? 4 : 2;
559}
560
561static __spinlock_t kernel_debug_lock;
562
563extern "C" {
564 void __cfaabi_bits_acquire() {
565 lock( kernel_debug_lock __cfaabi_dbg_ctx2 );
566 }
567
568 void __cfaabi_bits_release() {
569 unlock( kernel_debug_lock );
570 }
571}
572
573//=============================================================================================
574// Kernel Utilities
575//=============================================================================================
576//-----------------------------------------------------------------------------
577// Locks
578void ?{}( semaphore & this, int count = 1 ) {
579 (this.lock){};
580 this.count = count;
581 (this.waiting){};
582}
583void ^?{}(semaphore & this) {}
584
585bool P(semaphore & this) with( this ){
586 lock( lock __cfaabi_dbg_ctx2 );
587 count -= 1;
588 if ( count < 0 ) {
589 // queue current task
590 append( waiting, kernelTLS.this_thread );
591
592 // atomically release spin lock and block
593 unlock( lock );
594 park( __cfaabi_dbg_ctx );
595 return true;
596 }
597 else {
598 unlock( lock );
599 return false;
600 }
601}
602
603bool V(semaphore & this) with( this ) {
604 $thread * thrd = 0p;
605 lock( lock __cfaabi_dbg_ctx2 );
606 count += 1;
607 if ( count <= 0 ) {
608 // remove task at head of waiting list
609 thrd = pop_head( waiting );
610 }
611
612 unlock( lock );
613
614 // make new owner
615 unpark( thrd __cfaabi_dbg_ctx2 );
616
617 return thrd != 0p;
618}
619
620bool V(semaphore & this, unsigned diff) with( this ) {
621 $thread * thrd = 0p;
622 lock( lock __cfaabi_dbg_ctx2 );
623 int release = max(-count, (int)diff);
624 count += diff;
625 for(release) {
626 unpark( pop_head( waiting ) __cfaabi_dbg_ctx2 );
627 }
628
629 unlock( lock );
630
631 return thrd != 0p;
632}
633
634//-----------------------------------------------------------------------------
635// Debug
636__cfaabi_dbg_debug_do(
637 extern "C" {
638 void __cfaabi_dbg_record_lock(__spinlock_t & this, const char prev_name[]) {
639 this.prev_name = prev_name;
640 this.prev_thrd = kernelTLS.this_thread;
641 }
642
643 void __cfaabi_dbg_record_thrd($thread & this, bool park, const char prev_name[]) {
644 if(park) {
645 this.park_caller = prev_name;
646 this.park_stale = false;
647 }
648 else {
649 this.unpark_caller = prev_name;
650 this.unpark_stale = false;
651 }
652 }
653 }
654)
655
656//-----------------------------------------------------------------------------
657// Debug
658bool threading_enabled(void) __attribute__((const)) {
659 return true;
660}
661
662//-----------------------------------------------------------------------------
663// Statistics
664#if !defined(__CFA_NO_STATISTICS__)
665 void print_halts( processor & this ) {
666 this.print_halts = true;
667 }
668#endif
669// Local Variables: //
670// mode: c //
671// tab-width: 4 //
672// End: //
Note: See TracBrowser for help on using the repository browser.