Ignore:
Timestamp:
Feb 14, 2018, 3:40:19 PM (6 years ago)
Author:
alain
Message:

blip

File:
1 edited

Legend:

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

    r428 r433  
    227227    assert( (attr != NULL) , __FUNCTION__, "pthread attributes must be defined" );
    228228
    229 thread_dmsg("\n[DBG] %s : core[%x,%d] enter for process %x\n",
    230 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, process->pid );
     229#if CONFIG_DEBUG_THREAD_USER_CREATE
     230uint32_t cycle = (uint32_t)hal_get_cycles();
     231if( CONFIG_DEBUG_THREAD_USER_CREATE < cycle )
     232printk("\n[DBG] %s : thread %x enter / process %x / cycle %d\n",
     233__FUNCTION__, CURRENT_THREAD, pid , cycle );
     234#endif
    231235
    232236    // get process descriptor local copy
    233237    process = process_get_local_copy( pid );
    234 
    235238    if( process == NULL )
    236239    {
     
    326329    dqdt_local_update_threads( 1 );
    327330
    328 thread_dmsg("\n[DBG] %s : core[%x,%d] exit for process %x / trdid = %x / core = %d\n",
    329 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, process->pid, thread->trdid, core_lid );
     331#if CONFIG_DEBUG_THREAD_USER_CREATE
     332cycle = (uint32_t)hal_get_cycles();
     333if( CONFIG_DEBUG_THREAD_USER_CREATE < cycle )
     334printk("\n[DBG] %s : thread %x exit / process %x / new_thread %x / core %d / cycle %d\n",
     335__FUNCTION__, CURRENT_THREAD, pid, thread, core_lid, cycle );
     336#endif
    330337
    331338    *new_thread = thread;
     
    359366    vseg_t       * vseg;             // child thread STACK vseg
    360367
    361 thread_dmsg("\n[DBG] %s : core[%x,%d] enters at cycle %d\n",
    362 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , hal_get_cycles() );
     368#if CONFIG_DEBUG_THREAD_USER_FORK
     369uint32_t cycle = (uint32_t)hal_get_cycles();
     370if( CONFIG_DEBUG_THREAD_USER_FORK < cycle )
     371printk("\n[DBG] %s : thread %x enter / child_process %x / cycle %d\n",
     372__FUNCTION__, CURRENT_THREAD, child_process->pid, cycle );
     373#endif
    363374
    364375    // select a target core in local cluster
     
    474485        }
    475486
    476         // increment page descriptor fork_nr for the referenced page if mapped
     487        // increment pending forks counter for the page if mapped
    477488        if( mapped )
    478489        {
     
    480491            cxy_t    page_cxy = GET_CXY( page_xp );
    481492            page_t * page_ptr = (page_t *)GET_PTR( page_xp );
    482             hal_remote_atomic_add( XPTR( page_cxy , &page_ptr->fork_nr ) , 1 );
    483 
    484 thread_dmsg("\n[DBG] %s : core[%x,%d] copied PTE to child GPT : vpn %x\n",
    485 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , vpn );
     493            hal_remote_atomic_add( XPTR( page_cxy , &page_ptr->forks ) , 1 );
     494
     495#if (CONFIG_DEBUG_THREAD_USER_FORK & 1)
     496cycle = (uint32_t)hal_get_cycles();
     497if( CONFIG_DEBUG_THREAD_USER_FORK < cycle )
     498printk("\n[DBG] %s : thread %x copied stack PTE to child GPT : vpn %x\n",
     499__FUNCTION__, CURRENT_THREAD, vpn );
     500#endif
    486501
    487502        }
    488503    }
    489504
    490     // set COW flag for STAK vseg in parent thread GPT
    491     hal_gpt_flip_cow( true,                               // set cow
    492                       parent_gpt_xp,
    493                       vpn_base,
    494                       vpn_size );
     505    // set COW flag for all mapped entries of STAK vseg in parent thread GPT
     506    hal_gpt_set_cow( parent_gpt_xp,
     507                     vpn_base,
     508                     vpn_size );
    495509 
    496510        // update DQDT for child thread
    497511    dqdt_local_update_threads( 1 );
    498512
    499 thread_dmsg("\n[DBG] %s : core[%x,%d] exit / created main thread %x for process %x\n",
    500 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, child_ptr->trdid, child_process->pid );
     513#if CONFIG_DEBUG_THREAD_USER_FORK
     514cycle = (uint32_t)hal_get_cycles();
     515if( CONFIG_DEBUG_THREAD_USER_FORK < cycle )
     516printk("\n[DBG] %s : thread %x exit / child_process %x / child_thread %x / cycle %d\n",
     517__FUNCTION__, CURRENT_THREAD, child_process->pid, child_ptr, cycle );
     518#endif
    501519
    502520        return 0;
     
    514532        thread_t     * thread;       // pointer on new thread descriptor
    515533
    516 thread_dmsg("\n[DBG] %s : core[%x,%d] enters / type %s / cycle %d\n",
    517 __FUNCTION__ , local_cxy , core_lid , thread_type_str( type ) , hal_time_stamp() );
    518 
    519534    assert( ( (type == THREAD_IDLE) || (type == THREAD_RPC) || (type == THREAD_DEV) ) ,
    520535    __FUNCTION__ , "illegal thread type" );
     
    522537    assert( (core_lid < LOCAL_CLUSTER->cores_nr) ,
    523538            __FUNCTION__ , "illegal core_lid" );
     539
     540#if CONFIG_DEBUG_THREAD_KERNEL_CREATE
     541uint32_t cycle = (uint32_t)hal_get_cycles();
     542if( CONFIG_DEBUG_THREAD_KERNEL_CREATE < cycle )
     543printk("\n[DBG] %s : thread %x enter / requested_type %s / cycle %d\n",
     544__FUNCTION__, CURRENT_THREAD, thread, thread_type_str(type), cycle );
     545#endif
    524546
    525547    // allocate memory for new thread descriptor
     
    549571    dqdt_local_update_threads( 1 );
    550572
    551 thread_dmsg("\n[DBG] %s : core = [%x,%d] exit / trdid = %x / type %s / cycle %d\n",
    552 __FUNCTION__, local_cxy, core_lid, thread->trdid, thread_type_str(type), hal_time_stamp() );
     573#if CONFIG_DEBUG_THREAD_KERNEL_CREATE
     574cycle = (uint32_t)hal_get_cycles();
     575if( CONFIG_DEBUG_THREAD_KERNEL_CREATE < cycle )
     576printk("\n[DBG] %s : thread %x exit / new_thread %x / type %s / cycle %d\n",
     577__FUNCTION__, CURRENT_THREAD, thread, thread_type_str(type), cycle );
     578#endif
    553579
    554580    *new_thread = thread;
     
    589615void thread_destroy( thread_t * thread )
    590616{
    591         uint32_t     tm_start;
    592         uint32_t     tm_end;
    593617    reg_t        save_sr;
    594618
     
    596620    core_t     * core       = thread->core;
    597621
    598     thread_dmsg("\n[DBG] %s : enters for thread %x in process %x / type = %s\n",
    599                 __FUNCTION__ , thread->trdid , process->pid , thread_type_str( thread->type ) );
     622#if CONFIG_DEBUG_THREAD_DESTROY
     623uint32_t cycle = (uint32_t)hal_get_cycles();
     624if( CONFIG_DEBUG_THREAD_DESTROY < cycle )
     625printk("\n[DBG] %s : thread %x enter to destroy thread %x in process %x / cycle %d\n",
     626__FUNCTION__, CURRENT_THREAD, thread, process->pid, cycle );
     627#endif
    600628
    601629    assert( (thread->children_nr == 0) , __FUNCTION__ , "still attached children" );
     
    604632
    605633    assert( (thread->remote_locks == 0) , __FUNCTION__ , "all remote locks not released" );
    606 
    607         tm_start = hal_get_cycles();
    608634
    609635    // update intrumentation values
     
    635661    thread_release( thread );
    636662
    637         tm_end = hal_get_cycles();
    638 
    639         thread_dmsg("\n[DBG] %s : exit for thread %x in process %x / duration = %d\n",
    640                        __FUNCTION__, thread->trdid , process->pid , tm_end - tm_start );
     663#if CONFIG_DEBUG_THREAD_DESTROY
     664cycle = (uint32_t)hal_get_cycles();
     665if( CONFIG_DEBUG_THREAD_DESTROY < cycle )
     666printk("\n[DBG] %s : thread %x exit / destroyed thread %x in process %x / cycle %d\n",
     667__FUNCTION__, CURRENT_THREAD, thread, process->pid, cycle );
     668#endif
    641669
    642670}   // end thread_destroy()
     
    779807    hal_fence();
    780808
     809#if CONFIG_DEBUG_THREAD_BLOCK
     810uint32_t cycle = (uint32_t)hal_get_cycles();
     811if( CONFIG_DEBUG_THREAD_BLOCK < cycle )
     812printk("\n[DBG] %s : thread %x blocked thread %x / cause %x / state %x / cycle %d\n",
     813__FUNCTION__ , CURRENT_THREAD , thread , cause , thread->blocked , cycle );
     814#endif
     815
    781816} // end thread_block()
    782817
    783 /////////////////////////////////////////
    784 uint32_t thread_unblock( xptr_t   thread,
     818////////////////////////////////////////////
     819uint32_t thread_unblock( xptr_t   thread_xp,
    785820                         uint32_t cause )
    786821{
    787822    // get thread cluster and local pointer
    788     cxy_t      cxy = GET_CXY( thread );
    789     thread_t * ptr = (thread_t *)GET_PTR( thread );
     823    cxy_t      cxy = GET_CXY( thread_xp );
     824    thread_t * ptr = GET_PTR( thread_xp );
    790825
    791826    // reset blocking cause
     
    793828    hal_fence();
    794829
     830#if CONFIG_DEBUG_THREAD_BLOCK
     831uint32_t cycle = (uint32_t)hal_get_cycles();
     832if( CONFIG_DEBUG_THREAD_BLOCK < cycle )
     833printk("\n[DBG] %s : thread %x unblocked thread %x / cause %x / state %x / cycle %d\n",
     834__FUNCTION__ , CURRENT_THREAD , ptr , cause , ptr->blocked , cycle );
     835#endif
     836
    795837    // return a non zero value if the cause bit is modified
    796838    return( previous & cause );
     
    805847    thread_t * killer = CURRENT_THREAD;
    806848
    807 thread_dmsg("\n[DBG] %s : killer thread %x enter for target thread %x\n",
    808 __FUNCTION__, local_cxy, killer->trdid , target->trdid );
     849#if CONFIG_DEBUG_THREAD_KILL
     850uint32_t cycle  = (uint32_t)hal_get_cycles;
     851if( CONFIG_DEBUG_THREAD_KILL < cycle )
     852printk("\n[DBG] %s : thread %x enter for target thread %x / cycle %d\n",
     853__FUNCTION__, killer, target, cycle );
     854#endif
    809855
    810856    // set the global blocked bit in target thread descriptor.
     
    835881        hal_atomic_or( &target->flags , THREAD_FLAG_REQ_DELETE );
    836882
    837 thread_dmsg("\n[DBG] %s : killer thread %x exit for target thread %x\n",
    838 __FUNCTION__, local_cxy, killer->trdid , target->trdid );
     883#if CONFIG_DEBUG_THREAD_KILL
     884cycle  = (uint32_t)hal_get_cycles;
     885if( CONFIG_DEBUG_THREAD_KILL < cycle )
     886printk("\n[DBG] %s : thread %x exit for target thread %x / cycle %d\n",
     887__FUNCTION__, killer, target, cycle );
     888#endif
    839889
    840890}  // end thread_kill()
     
    851901        {
    852902
    853 idle_dmsg("\n[DBG] %s : core[%x][%d] goes to sleep at cycle %d\n",
    854 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , hal_get_cycles() );
     903#if CONFIG_DEBUG_THREAD_IDLE
     904uint32_t cycle  = (uint32_t)hal_get_cycles;
     905thread_t * this = CURRENT_THREAD;
     906if( CONFIG_DEBUG_THREAD_IDLE < cycle )
     907printk("\n[DBG] %s : idle thread %x on core[%x,%d] goes to sleep / cycle %d\n",
     908__FUNCTION__, this, local_cxy, this->core->lid, cycle );
     909#endif
    855910
    856911            hal_core_sleep();
    857912
    858 idle_dmsg("\n[DBG] %s : core[%x][%d] wake up at cycle %d\n",
    859 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , hal_get_cycles() );
     913#if CONFIG_DEBUG_THREAD_IDLE
     914cycle  = (uint32_t)hal_get_cycles;
     915if( CONFIG_DEBUG_THREAD_IDLE < cycle )
     916printk("\n[DBG] %s : idle thread %x on core[%x,%d] wake up / cycle %d\n",
     917__FUNCTION__, this, local_cxy, this->core->lid, cycle );
     918#endif
    860919
    861920        }
Note: See TracChangeset for help on using the changeset viewer.