Changeset d6ff3ff


Ignore:
Timestamp:
Jul 13, 2017, 3:51:00 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
0764cfb, 24fc196, 3d4b23f
Parents:
35b06a8
Message:

Kernel shoud now drop preemptions during other preemptions

Location:
src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/benchmark/create_pthrd.c

    r35b06a8 rd6ff3ff  
    1717
    1818        for (size_t i = 0; i < n; i++) {
    19                 pthread_attr_t attr;
    20                 if (pthread_attr_init(&attr) < 0) {
     19                pthread_t thread;
     20                if (pthread_create(&thread, NULL, foo, NULL) < 0) {
    2121                        return 1;
    2222                }
    23                 if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) < 0) {
    24                         return 1;
    25                 }
    26                 pthread_t thread;
    27                 if (pthread_create(&thread, &attr, foo, NULL) < 0) {
     23
     24                if (pthread_join( thread, NULL) < 0) {
    2825                        return 1;
    2926                }
  • src/libcfa/concurrency/kernel.c

    r35b06a8 rd6ff3ff  
    6060volatile thread_local coroutine_desc * this_coroutine;
    6161volatile thread_local thread_desc * this_thread;
     62volatile thread_local bool preemption_in_progress = 0;
    6263volatile thread_local unsigned short disable_preempt_count = 1;
    6364
  • src/libcfa/concurrency/kernel_private.h

    r35b06a8 rd6ff3ff  
    7979extern volatile thread_local coroutine_desc * this_coroutine;
    8080extern volatile thread_local thread_desc * this_thread;
     81extern volatile thread_local bool preemption_in_progress;
    8182extern volatile thread_local unsigned short disable_preempt_count;
    8283
  • src/libcfa/concurrency/preemption.c

    r35b06a8 rd6ff3ff  
    180180
    181181static inline bool preemption_ready() {
    182         return disable_preempt_count == 0;
     182        return disable_preempt_count == 0 && !preemption_in_progress;
    183183}
    184184
     
    218218
    219219void kernel_stop_preemption() {
     220        LIB_DEBUG_PRINT_SAFE("Kernel : Preemption stopping\n");
     221
    220222        sigset_t mask;
    221223        sigfillset( &mask );
     
    248250        LIB_DEBUG_DO( last_interrupt = (void *)(cxt->uc_mcontext.gregs[CFA_REG_IP]); )
    249251        if( preemption_ready() ) {
     252                preemption_in_progress = true;
    250253                signal_unblock( SIGUSR1 );
     254                this_processor->pending_preemption = false;
     255                preemption_in_progress = false;
    251256                BlockInternal( (thread_desc*)this_thread );
    252257        }
     
    255260        }
    256261}
    257 
    258 // void sigHandler_alarm( __CFA_SIGPARMS__ ) {
    259 //      LIB_DEBUG_DO( last_interrupt = (void *)(cxt->uc_mcontext.gregs[CFA_REG_IP]); )
    260 //      verify( this_processor == systemProcessor );
    261 
    262 //      if( try_lock( &systemProcessor->alarm_lock DEBUG_CTX2 ) ) {
    263 //              tick_preemption();
    264 //              systemProcessor->pending_alarm = false;
    265 //              unlock( &systemProcessor->alarm_lock );
    266 //      }
    267 //      else {
    268 //              defer_alarm();
    269 //      }
    270 
    271 //      signal_unblock( SIGALRM );
    272 
    273 //      if( preemption_ready() && this_processor->pending_preemption ) {
    274 
    275 //              this_processor->pending_preemption = false;
    276 //              BlockInternal( (thread_desc*)this_thread );
    277 //      }
    278 // }
    279262
    280263void * alarm_loop( __attribute__((unused)) void * args ) {
  • src/tests/preempt_longrun/Makefile.am

    r35b06a8 rd6ff3ff  
    1616
    1717repeats=10
    18 max_time=30
     18max_time=600
    1919preempt=1_000ul
    2020
  • src/tests/preempt_longrun/Makefile.in

    r35b06a8 rd6ff3ff  
    449449top_srcdir = @top_srcdir@
    450450repeats = 10
    451 max_time = 30
     451max_time = 600
    452452preempt = 1_000ul
    453453REPEAT = ${abs_top_srcdir}/tools/repeat -s
  • src/tests/preempt_longrun/create.c

    r35b06a8 rd6ff3ff  
    1515
    1616int main(int argc, char* argv[]) {
     17        processor p;
    1718        for(int i = 0; i < 10_000ul; i++) {
    1819                worker_t w[7];
Note: See TracChangeset for help on using the changeset viewer.