Ignore:
Timestamp:
Aug 20, 2018, 1:04:16 PM (3 years ago)
Author:
alain
Message:

1) Introduce the libsemaphore library.
2) Introduce a small libmath library, required by the "fft" application..
3) Introduce the multithreaded "fft" application.
4) Fix a bad synchronisation bug in the Copy-On-Write mechanism.

File:
1 edited

Legend:

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

    r457 r469  
    8686    // return pointer on new thread descriptor
    8787    xptr_t base_xp = ppm_page2base( XPTR(local_cxy , page ) );
    88     return (thread_t *)GET_PTR( base_xp );
     88    return GET_PTR( base_xp );
    8989
    9090}  // end thread_alloc()
     
    419419uint32_t cycle = (uint32_t)hal_get_cycles();
    420420if( DEBUG_THREAD_USER_FORK < cycle )
    421 printk("\n[DBG] %s : thread %x enter / child_process %x / cycle %d\n",
    422 __FUNCTION__, CURRENT_THREAD, child_process->pid, cycle );
     421printk("\n[DBG] %s : thread %x in process %x enter / child_process %x / cycle %d\n",
     422__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, child_process->pid, cycle );
    423423#endif
    424424
     
    428428    // get cluster and local pointer on parent thread descriptor
    429429    parent_cxy = GET_CXY( parent_thread_xp );
    430     parent_ptr = (thread_t *)GET_PTR( parent_thread_xp );
     430    parent_ptr = GET_PTR( parent_thread_xp );
    431431
    432432    // get relevant fields from parent thread
     
    538538        if( mapped )
    539539        {
     540            // get pointers on the page descriptor
    540541            xptr_t   page_xp  = ppm_ppn2page( ppn );
    541542            cxy_t    page_cxy = GET_CXY( page_xp );
    542             page_t * page_ptr = (page_t *)GET_PTR( page_xp );
     543            page_t * page_ptr = GET_PTR( page_xp );
     544
     545            // get extended pointers on forks and lock fields
     546            xptr_t forks_xp = XPTR( page_cxy , &page_ptr->forks );
     547            xptr_t lock_xp  = XPTR( page_cxy , &page_ptr->lock );
     548
     549            // increment the forks counter
     550            remote_spinlock_lock( lock_xp ); 
    543551            hal_remote_atomic_add( XPTR( page_cxy , &page_ptr->forks ) , 1 );
     552            remote_spinlock_unlock( lock_xp ); 
    544553
    545554#if (DEBUG_THREAD_USER_FORK & 1)
    546555cycle = (uint32_t)hal_get_cycles();
    547556if( DEBUG_THREAD_USER_FORK < cycle )
    548 printk("\n[DBG] %s : thread %x copied stack PTE to child GPT : vpn %x\n",
    549 __FUNCTION__, CURRENT_THREAD, vpn );
     557printk("\n[DBG] %s : thread %x in process %x copied one PTE to child GPT : vpn %x / forks %d\n",
     558__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, vpn,
     559hal_remote_lw( XPTR( page_cxy , &page_ptr->forks) ) );
    550560#endif
    551561
     
    561571cycle = (uint32_t)hal_get_cycles();
    562572if( DEBUG_THREAD_USER_FORK < cycle )
    563 printk("\n[DBG] %s : thread %x exit / child_process %x / child_thread %x / cycle %d\n",
    564 __FUNCTION__, CURRENT_THREAD, child_process->pid, child_ptr, cycle );
     573printk("\n[DBG] %s : thread %x in process %x exit / child_thread %x / cycle %d\n",
     574__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, child_ptr, cycle );
    565575#endif
    566576
     
    631641    }
    632642
    633     // update user stack in stack descriptor
     643    // update user stack in thread descriptor
    634644    thread->u_stack_base = vseg->min;
    635645    thread->u_stack_size = vseg->max - vseg->min;
     
    11721182    {
    11731183        target_process_xp  = XLIST_ELEMENT( iter , process_t , local_list );
    1174         target_process_ptr = (process_t *)GET_PTR( target_process_xp );
     1184        target_process_ptr = GET_PTR( target_process_xp );
    11751185        target_process_pid = hal_remote_lw( XPTR( target_cxy , &target_process_ptr->pid ) );
    11761186        if( target_process_pid == pid )
Note: See TracChangeset for help on using the changeset viewer.