Changeset fbb930e


Ignore:
Timestamp:
Aug 30, 2022, 4:57:46 PM (23 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, master, pthread-emulation
Children:
01ba701
Parents:
cefd0b9
Message:

Added option to explicitly poll interrupts.
Usefull in cases using nopreempt sections

Location:
libcfa/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/bits/locks.hfa

    rcefd0b9 rfbb930e  
    3232                extern void disable_interrupts() OPTIONAL_THREAD;
    3333                extern void enable_interrupts( bool poll = true ) OPTIONAL_THREAD;
     34                extern bool poll_interrupts() OPTIONAL_THREAD;
    3435                #define __cfaabi_dbg_record_lock(x, y)
    3536        }
  • libcfa/src/concurrency/preemption.cfa

    rcefd0b9 rfbb930e  
    357357                        }
    358358                }
     359        }
     360
     361        // Check whether or not there is pending preemption
     362        // force_yield( __POLL_PREEMPTION ) if appropriate
     363        // return true if the thread was in an interruptable state
     364        // i.e. on a real processor and not in the kernel
     365        // (can return true even if no preemption was pending)
     366        bool poll_interrupts() libcfa_public {
     367                // Cache the processor now since interrupts can start happening after the atomic store
     368                processor   * proc = publicTLS_get( this_processor );
     369                if ( ! proc ) return false;
     370                if ( ! __preemption_enabled() ) return false;
     371
     372                with( __cfaabi_tls.preemption_state ){
     373                        // Signal the compiler that a fence is needed but only for signal handlers
     374                        __atomic_signal_fence(__ATOMIC_RELEASE);
     375                        if( proc->pending_preemption ) {
     376                                proc->pending_preemption = false;
     377                                force_yield( __POLL_PREEMPTION );
     378                        }
     379                }
     380
     381                return true;
    359382        }
    360383}
  • libcfa/src/startup.cfa

    rcefd0b9 rfbb930e  
    4343        void disable_interrupts() __attribute__(( weak )) libcfa_public {}
    4444        void enable_interrupts() __attribute__(( weak )) libcfa_public {}
     45        bool poll_interrupts() __attribute__(( weak )) libcfa_public { return false; }
    4546
    4647
Note: See TracChangeset for help on using the changeset viewer.