Changeset 41fcd94
- Timestamp:
- Feb 8, 2018, 4:52:56 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- ff878b7
- Parents:
- 06b176d (diff), eb7f20c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/papers/general/Paper.tex
r06b176d r41fcd94 1444 1444 In \CFA, the address of a @T&@ is a lvalue @T*@, as the address of the underlying @T@ is stored in the reference, and can thus be mutated there. 1445 1445 The result of this rule is that any reference can be rebound using the existing pointer assignment semantics by assigning a compatible pointer into the address of the reference, \eg @&r1 = &x;@ above. 1446 This rebinding can occur to an arbitrary depth of reference nesting; $n$ address-of operators applied to a reference nested $m$ times will produce an lvalue pointer nested $n$ times if $n \le m$ (note that $n = m+1$ is simply the usual C rvalue address-of operator applied to the $n = m$ case). 1447 The explicit address-of operators can be thought of as ``cancelling out'' the implicit dereference operators, \eg @(&`*`)r1 = &x@ or @(&(&`*`)`*`)r3 = &(&`*`)r1@ or even @(&`*`)r2 = (&`*`)`*`r3@ for @&r2 = &r3@. 1446 This rebinding can occur to an arbitrary depth of reference nesting; loosely speaking, nested address-of operators will produce an lvalue nested pointer up to as deep as the reference they're applied to. 1447 These explicit address-of operators can be thought of as ``cancelling out'' the implicit dereference operators, \eg @(&`*`)r1 = &x@ or @(&(&`*`)`*`)r3 = &(&`*`)r1@ or even @(&`*`)r2 = (&`*`)`*`r3@ for @&r2 = &r3@. 1448 More precisely: 1449 \begin{itemize} 1450 \item 1451 if @R@ is an rvalue of type {@T &@$_1 \cdots$@ &@$_r$} where $r \ge 1$ references (@&@ symbols) than @&R@ has type {@T `*`&@$_{\color{red}2} \cdots$@ &@$_{\color{red}r}$}, \\ \ie @T@ pointer with $r-1$ references (@&@ symbols). 1452 1453 \item 1454 if @L@ is an lvalue of type {@T &@$_1 \cdots$@ &@$_l$} where $l \ge 0$ references (@&@ symbols) then @&L@ has type {@T `*`&@$_{\color{red}1} \cdots$@ &@$_{\color{red}l}$}, \\ \ie @T@ pointer with $l$ references (@&@ symbols). 1455 \end{itemize} 1448 1456 1449 1457 Since pointers and references share the same internal representation, code using either is equally performant; in fact the \CFA compiler converts references to pointers internally, and the choice between them in user code can be made based solely on convenience. … … 1480 1488 In particular, \CFA does not implement class-based encapsulation: neither the constructor nor any other function has privileged access to the implementation details of a type, except through the translation-unit-scope method of opaque structs provided by C. 1481 1489 1482 In \CFA, a constructor is a function named @?{}@, while a destructor is a function named @^?{}@; like other \CFA operators, these names represent the syntax used to call the constructor or destructor, \eg @ S s = { ... };@ or @^(s){};@.1490 In \CFA, a constructor is a function named @?{}@, while a destructor is a function named @^?{}@; like other \CFA operators, these names represent the syntax used to call the constructor or destructor, \eg @x{ ... };@ or @^x{};@. 1483 1491 Every constructor and destructor must have a return type of @void@, and its first parameter must have a reference type whose base type is the type of the object the function constructs or destructs. 1484 1492 This first parameter is informally called the @this@ parameter, as in many object-oriented languages, though a programmer may give it an arbitrary name. … … 1533 1541 \begin{cfa} 1534 1542 Array a, b; 1535 (a){};$\C{// default construct}$1536 (b){ a }; $\C{// copy construct}$1537 ^ (a){};$\C{// destruct}$1538 (a){ 5, 0xFFFFFFFF }; $\C{// explicit constructor call}$1543 a{}; $\C{// default construct}$ 1544 b{ a }; $\C{// copy construct}$ 1545 ^a{}; $\C{// destruct}$ 1546 a{ 5, 0xFFFFFFFF }; $\C{// explicit constructor call}$ 1539 1547 \end{cfa} 1540 1548 -
src/libcfa/concurrency/kernel.c
r06b176d r41fcd94 170 170 if( ! do_terminate ) { 171 171 __cfaabi_dbg_print_safe("Kernel : core %p signaling termination\n", &this); 172 do_terminate = true;172 terminate(&this); 173 173 P( terminated ); 174 174 pthread_join( kernel_thread, NULL ); -
src/libcfa/concurrency/kernel_private.h
r06b176d r41fcd94 60 60 void runThread(processor * this, thread_desc * dst); 61 61 void finishRunning(processor * this); 62 void terminate(processor * this); 62 63 void spin(processor * this, unsigned int * spin_count); 63 64 -
src/libcfa/concurrency/preemption.c
r06b176d r41fcd94 67 67 } 68 68 69 enum { 70 PREEMPT_NORMAL = 0, 71 PREEMPT_TERMINATE = 1, 72 }; 73 69 74 //============================================================================================= 70 75 // Kernel Preemption logic … … 209 214 // kill wrapper : signal a processor 210 215 static void preempt( processor * this ) { 211 pthread_kill( this->kernel_thread, SIGUSR1 ); 216 sigval_t value = { PREEMPT_NORMAL }; 217 pthread_sigqueue( this->kernel_thread, SIGUSR1, value ); 218 } 219 220 // kill wrapper : signal a processor 221 void terminate(processor * this) { 222 this->do_terminate = true; 223 sigval_t value = { PREEMPT_TERMINATE }; 224 pthread_sigqueue( this->kernel_thread, SIGUSR1, value ); 212 225 } 213 226 … … 298 311 void sigHandler_ctxSwitch( __CFA_SIGPARMS__ ) { 299 312 __cfaabi_dbg_debug_do( last_interrupt = (void *)(cxt->uc_mcontext.CFA_REG_IP); ) 313 314 // SKULLDUGGERY: if a thread creates a processor and the immediately deletes it, 315 // the interrupt that is supposed to force the kernel thread to preempt might arrive 316 // before the kernel thread has even started running. When that happens an iterrupt 317 // we a null 'this_processor' will be caught, just ignore it. 318 if(!this_processor) return; 319 320 choose(sfp->si_value.sival_int) { 321 case PREEMPT_NORMAL : ;// Normal case, nothing to do here 322 case PREEMPT_TERMINATE: verify(this_processor->do_terminate); 323 default: 324 abortf( "internal error, signal value is %d", sfp->si_value.sival_int ); 325 } 300 326 301 327 // Check if it is safe to preempt here
Note: See TracChangeset
for help on using the changeset viewer.