Ignore:
Timestamp:
Apr 10, 2019, 10:09:39 AM (5 years ago)
Author:
alain
Message:

Fix a bug in the vmm_remove_vseg() function: the physical pages
associated to an user DATA vseg were released to the kernel when
the target process descriptor was in the reference cluster.
This physical pages release should be done only when the page
forks counter value is zero.
All other modifications are cosmetic.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/scheduler.c

    r624 r625  
    180180    sched = &core->scheduler;
    181181
    182     /////////////// scan user threads to handle both ACK and DELETE requests
     182    ////////////////// scan user threads to handle both ACK and DELETE requests
    183183    root = &sched->u_root;
    184184    iter = root->next;
     
    240240            busylock_release( &sched->lock );
    241241
    242 // check th_nr value
    243 assert( (process->th_nr > 0) , "process th_nr cannot be 0\n" );
    244 
    245             // remove thread from process th_tbl[]
    246             process->th_tbl[ltid] = NULL;
    247             count = hal_atomic_add( &process->th_nr , - 1 );
    248  
    249             // release memory allocated for thread descriptor
    250             thread_destroy( thread );
     242            // release memory allocated for thread
     243            count = thread_destroy( thread );
    251244
    252245            hal_fence();
     
    255248uint32_t cycle = (uint32_t)hal_get_cycles();
    256249if( DEBUG_SCHED_HANDLE_SIGNALS < cycle )
    257 printk("\n[%s] thread[%x,%x] on core[%x,%d] deleted / cycle %d\n",
    258 __FUNCTION__ , process->pid , thread->trdid , local_cxy , thread->core->lid , cycle );
     250printk("\n[%s] thread[%x,%x] on core[%x,%d] deleted / %d threads / cycle %d\n",
     251__FUNCTION__, process->pid, thread->trdid, local_cxy, thread->core->lid, count, cycle );
    259252#endif
    260253            // destroy process descriptor if last thread
     
    274267    }  // end user threads
    275268
    276     ////// scan kernel threads for DELETE only
     269    ///////////// scan kernel threads for DELETE only
    277270    root = &sched->k_root;
    278271    iter = root->next;
     
    290283
    291284// check process descriptor is local kernel process
    292 assert( ( thread->process == &process_zero ) , "illegal process descriptor\n");
     285assert( ( thread->process == &process_zero ) , "illegal process descriptor");
    293286
    294287            // get thread ltid
     
    325318
    326319// check th_nr value
    327 assert( (process_zero.th_nr > 0) , "kernel process th_nr cannot be 0\n" );
     320assert( (process_zero.th_nr > 0) , "kernel process th_nr cannot be 0" );
    328321
    329322            // remove thread from process th_tbl[]
     
    477470}  // end sched_register_thread()
    478471
    479 //////////////////////////////////////
    480 void sched_yield( const char * cause )
     472//////////////////////////////////////////////////////////////////
     473void sched_yield( const char * cause __attribute__((__unused__)) )
    481474{
    482475    thread_t      * next;
     
    512505// check next thread kernel_stack overflow
    513506assert( (next->signature == THREAD_SIGNATURE),
    514 "kernel stack overflow for thread %x on core[%x,%d] \n", next, local_cxy, lid );
     507"kernel stack overflow for thread %x on core[%x,%d]", next, local_cxy, lid );
    515508
    516509// check next thread attached to same core as the calling thread
    517510assert( (next->core == current->core),
    518 "next core %x != current core %x\n", next->core, current->core );
     511"next core %x != current core %x", next->core, current->core );
    519512
    520513// check next thread not blocked when type != IDLE
    521514assert( ((next->blocked == 0) || (next->type == THREAD_IDLE)) ,
    522 "next thread %x (%s) is blocked on core[%x,%d]\n",
     515"next thread %x (%s) is blocked on core[%x,%d]",
    523516next->trdid , thread_type_str(next->type) , local_cxy , lid );
    524517
     
    561554#if (DEBUG_SCHED_YIELD & 1)
    562555// if( sched->trace )
    563 if(uint32_t)hal_get_cycles() > DEBUG_SCHED_YIELD )
     556if( (uint32_t)hal_get_cycles() > DEBUG_SCHED_YIELD )
    564557printk("\n[%s] core[%x,%d] / cause = %s\n"
    565558"      thread %x (%s) (%x,%x) continue / cycle %d\n",
     
    584577    list_entry_t * iter;
    585578    thread_t     * thread;
    586 
    587 // check lid
    588 assert( (lid < LOCAL_CLUSTER->cores_nr),
    589 "illegal core index %d\n", lid);
    590579
    591580    core_t       * core    = &LOCAL_CLUSTER->core_tbl[lid];
     
    644633{
    645634    thread_t     * thread;
    646 
    647 // check cxy
    648 assert( (cluster_is_undefined( cxy ) == false),
    649 "illegal cluster %x\n", cxy );
    650 
    651 assert( (lid < hal_remote_l32( XPTR( cxy , &LOCAL_CLUSTER->cores_nr ) ) ),
    652 "illegal core index %d\n", lid );
    653635
    654636    // get local pointer on target scheduler
Note: See TracChangeset for help on using the changeset viewer.