Changeset 469 for trunk/kernel


Ignore:
Timestamp:
Aug 20, 2018, 1:04:16 PM (6 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.

Location:
trunk/kernel
Files:
2 added
12 edited

Legend:

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

    r459 r469  
    407407
    408408        // call nolock_printk to print core, function_name, and cycle
    409         nolock_printk("\n[PANIC] on core[%x,%d] in %s at cycle %d : " ,
    410         local_cxy, CURRENT_THREAD->core->lid, function_name, (uint32_t)hal_get_cycles() );
     409        nolock_printk("\n[PANIC] in %s => core[%x,%d] blocked at cycle %d : " ,
     410        function_name, local_cxy, CURRENT_THREAD->core->lid, (uint32_t)hal_get_cycles() );
    411411
    412412        // call kernel_printf on TXT0, in busy waiting to print format
  • trunk/kernel/kern/process.c

    r459 r469  
    11631163    }
    11641164
    1165 #if DEBUG_PROCESS_MAKE_FORK
     1165#if( DEBUG_PROCESS_MAKE_FORK & 1 )
    11661166cycle = (uint32_t)hal_get_cycles();
    11671167if( DEBUG_PROCESS_MAKE_FORK < cycle )
     
    12401240    "main thread must have LTID == 0\n" );
    12411241
    1242 #if( DEBUG_PROCESS_MAKE_FORK & 1 )
     1242//#if( DEBUG_PROCESS_MAKE_FORK & 1 )
     1243#if DEBUG_PROCESS_MAKE_FORK
    12431244cycle = (uint32_t)hal_get_cycles();
    12441245if( DEBUG_PROCESS_MAKE_FORK < cycle )
    1245 printk("\n[DBG] %s : thread %x in process %x created main thread %x on core[%x,%d] / cycle %d\n",
    1246 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid,
    1247 thread, local_cxy, thread->core->lid, cycle );
     1246printk("\n[DBG] %s : thread %x in process %x created main thread %x / cycle %d\n",
     1247__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, thread, cycle );
    12481248#endif
    12491249
     
    13421342
    13431343#if (DEBUG_PROCESS_MAKE_EXEC & 1)
     1344cycle = (uint32_t)hal_get_cycles();
    13441345if( DEBUG_PROCESS_MAKE_EXEC < cycle )
    1345 printk("\n[DBG] %s : open file <%s>\n", __FUNCTION__, path );
     1346printk("\n[DBG] %s : thread %x in process %x opened file <%s> / cycle %d\n",
     1347__FUNCTION__, thread->trdid, pid, path, cycle );
    13461348#endif
    13471349
     
    13491351    process_sigaction( pid , DELETE_ALL_THREADS );
    13501352
     1353#if (DEBUG_PROCESS_MAKE_EXEC & 1)
     1354cycle = (uint32_t)hal_get_cycles();
     1355if( DEBUG_PROCESS_MAKE_EXEC < cycle )
     1356printk("\n[DBG] %s : thread %x in process %x deleted all threads / cycle %d\n",
     1357__FUNCTION__, thread->trdid, pid, cycle );
     1358#endif
     1359
    13511360    // reset local process VMM
    13521361    vmm_destroy( process );
     
    13551364cycle = (uint32_t)hal_get_cycles();
    13561365if( DEBUG_PROCESS_MAKE_EXEC < cycle )
    1357 printk("\n[DBG] %s : thread %x in process %x / reset VMM / cycle %d\n",
     1366printk("\n[DBG] %s : thread %x in process %x reset VMM / cycle %d\n",
    13581367__FUNCTION__, thread->trdid, pid, cycle );
    13591368#endif
     
    14001409    if( error )
    14011410    {
    1402         printk("\n[ERROR] in %s : cannot reset main thread for %s\n", __FUNCTION__ , path );
     1411        printk("\n[ERROR] in %s : cannot update main thread for %s\n", __FUNCTION__ , path );
    14031412        vfs_close( file_xp , file_id );
    14041413        // FIXME restore old process VMM
  • trunk/kernel/kern/scheduler.c

    r462 r469  
    6363    list_root_init( &sched->k_root );
    6464
     65    // init spinlock
     66    spinlock_init( &sched->lock );
     67
    6568    sched->req_ack_pending = false;             // no pending request
    6669    sched->trace           = false;             // context switches trace desactivated
  • 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 )
  • trunk/kernel/kernel_config.h

    r459 r469  
    123123#define DEBUG_SYSCALLS_ERROR           2
    124124
    125 #define DEBUG_SYS_CLOSE                2
     125#define DEBUG_SYS_CLOSE                0
    126126#define DEBUG_SYS_DISPLAY              0
    127127#define DEBUG_SYS_EXEC                 0
    128 #define DEBUG_SYS_EXIT                 1
     128#define DEBUG_SYS_EXIT                 0
    129129#define DEBUG_SYS_FG                   0
    130130#define DEBUG_SYS_FORK                 0
     
    133133#define DEBUG_SYS_IS_FG                0
    134134#define DEBUG_SYS_KILL                 0
    135 #define DEBUG_SYS_OPEN                 2
     135#define DEBUG_SYS_OPEN                 0
    136136#define DEBUG_SYS_MMAP                 0
    137137#define DEBUG_SYS_READ                 0
     
    189189
    190190#define CONFIG_KERNEL_IDENTITY_MAP          true       // True for 32 bits cores             
    191 #define CONFIG_MAX_CLUSTER                  256        // max number of clusters
     191#define CONFIG_MAX_CLUSTERS                 256        // max number of clusters
    192192#define CONFIG_MAX_LOCAL_CORES              4          // max number of cores per cluster
    193193#define CONFIG_MAX_INT_DEV                  4          // max number of internal peripherals
     
    206206#define CONFIG_MAX_DMA_CHANNELS             4          // max number of DMA device channels
    207207#define CONFIG_MAX_NIC_CHANNELS             4          // max number of NIC device channels
    208 
    209 #define CONFIG_MAX_CLUSTERS                 256        // max number of clusters
    210208
    211209#define CONFIG_TXT_ECHO_MODE                1          // echo mode for TXT peripheral
  • trunk/kernel/libk/remote_sem.c

    r457 r469  
    4343    // get cluster and local pointer on reference process
    4444    cxy_t          ref_cxy = GET_CXY( ref_xp );
    45     process_t    * ref_ptr = (process_t *)GET_PTR( ref_xp );
     45    process_t    * ref_ptr = GET_PTR( ref_xp );
    4646
    4747    // get extended pointer on root of semaphores list
     
    6060        sem_xp  = XLIST_ELEMENT( iter_xp , remote_sem_t , list );
    6161        sem_cxy = GET_CXY( sem_xp );
    62         sem_ptr = (remote_sem_t *)GET_PTR( sem_xp );
     62        sem_ptr = GET_PTR( sem_xp );
    6363        ident   = (intptr_t)hal_remote_lpt( XPTR( sem_cxy , &sem_ptr->ident ) );   
     64
    6465        if( ident == vaddr )
    6566        {
  • trunk/kernel/mm/page.h

    r457 r469  
    5656 * This structure defines a physical page descriptor.
    5757 * Size is 64 bytes for a 32 bits core...
     58 * The spinlock is used to test/modify the forks counter.
    5859 * TODO : the list of waiting threads seems to be unused [AG]
    59  $ TODO : the spinlock use has to be clarified [AG]
     60 * TODO : the refcount use has to be clarified
    6061 ************************************************************************************/
    6162
     
    7071        uint32_t          refcount;       /*! reference counter                    (4)  */
    7172        uint32_t          forks;          /*! number of pending forks              (4)  */
    72         spinlock_t        lock;           /*! To Be Defined [AG]                   (16) */
     73        spinlock_t        lock;           /*! protect the forks field              (4) */
    7374}
    7475page_t;
  • trunk/kernel/mm/vmm.c

    r457 r469  
    411411                page_t   * page_ptr;
    412412                xptr_t     forks_xp;
     413                xptr_t     lock_xp;
    413414
    414415                // update flags in remote GPT
     
    433434                        if( attr & GPT_MAPPED )
    434435                        {
     436                            // get pointers and cluster on page descriptor
    435437                            page_xp  = ppm_ppn2page( ppn );
    436438                            page_cxy = GET_CXY( page_xp );
    437439                            page_ptr = GET_PTR( page_xp );
     440
     441                            // get extended pointers on "forks" and "lock"
    438442                            forks_xp = XPTR( page_cxy , &page_ptr->forks );
     443                            lock_xp  = XPTR( page_cxy , &page_ptr->lock );
     444
     445                            // increment "forks"
     446                            remote_spinlock_lock( lock_xp );
    439447                            hal_remote_atomic_add( forks_xp , 1 );
     448                            remote_spinlock_unlock( lock_xp );
    440449                        }
    441450                    }   // end loop on vpn
     
    473482    vpn_t       vpn_base;
    474483    vpn_t       vpn_size;
    475     xptr_t      page_xp;
     484    xptr_t      page_xp;        // extended pointer on page descriptor
    476485    page_t    * page_ptr;
    477486    cxy_t       page_cxy;
     487    xptr_t      forks_xp;       // extended pointer on forks counter in page descriptor
     488    xptr_t      lock_xp;        // extended pointer on lock protecting the forks counter
    478489    xptr_t      parent_root_xp;
    479490    bool_t      mapped;
     
    592603                    if( mapped )
    593604                    {
    594                         page_xp = ppm_ppn2page( ppn );
     605                        // get pointers and cluster on page descriptor
     606                        page_xp  = ppm_ppn2page( ppn );
    595607                        page_cxy = GET_CXY( page_xp );
    596608                        page_ptr = GET_PTR( page_xp );
    597                         hal_remote_atomic_add( XPTR( page_cxy , &page_ptr->forks ) , 1 );
     609
     610                        // get extended pointers on "forks" and "lock"
     611                        forks_xp = XPTR( page_cxy , &page_ptr->forks );
     612                        lock_xp  = XPTR( page_cxy , &page_ptr->lock );
     613
     614                        // increment "forks"
     615                        remote_spinlock_lock( lock_xp );
     616                        hal_remote_atomic_add( forks_xp , 1 );
     617                        remote_spinlock_unlock( lock_xp );
    598618
    599619#if DEBUG_VMM_FORK_COPY
     
    603623__FUNCTION__ , CURRENT_THREAD , vpn , cycle );
    604624#endif
    605 
    606625                    }
    607626                }
     
    670689if( DEBUG_VMM_DESTROY < cycle )
    671690printk("\n[DBG] %s : thread %x enter for process %x in cluster %x / cycle %d\n",
    672 __FUNCTION__ , CURRENT_THREAD , process->pid , local_cxy , cycle );
     691__FUNCTION__, CURRENT_THREAD->trdid, process->pid, local_cxy, cycle );
    673692#endif
    674693
     
    695714        vseg    = GET_PTR( vseg_xp );
    696715
    697 #if( DEBUG_VMM_DESTROY & 1 )
    698 if( DEBUG_VMM_DESTROY < cycle )
    699 printk("\n[DBG] %s : found %s vseg / vpn_base %x / vpn_size %d\n",
    700 __FUNCTION__ , vseg_type_str( vseg->type ), vseg->vpn_base, vseg->vpn_size );
    701 #endif
    702716        // unmap and release physical pages
    703717        vmm_unmap_vseg( process , vseg );
     
    751765if( DEBUG_VMM_DESTROY < cycle )
    752766printk("\n[DBG] %s : thread %x exit for process %x in cluster %x / cycle %d\n",
    753 __FUNCTION__ , CURRENT_THREAD , process->pid , local_cxy , cycle );
     767__FUNCTION__, CURRENT_THREAD->trdid, process->pid, local_cxy , cycle );
    754768#endif
    755769
     
    10691083    page_t    * page_ptr;   // page descriptor pointer
    10701084    xptr_t      forks_xp;   // extended pointer on pending forks counter
    1071     uint32_t    count;      // actual number of pendinf forks
     1085    xptr_t      lock_xp;    // extended pointer on lock protecting forks counter
     1086    uint32_t    forks;      // actual number of pendinf forks
    10721087
    10731088#if DEBUG_VMM_UNMAP_VSEG
     
    11151130                page_ptr = GET_PTR( page_xp );
    11161131
    1117                 // FIXME lock the physical page
     1132                // get extended pointers on forks and lock fields
     1133                forks_xp = XPTR( page_cxy , &page_ptr->forks );
     1134                lock_xp  = XPTR( page_cxy , &page_ptr->lock );
     1135
     1136                // get lock protecting page descriptor
     1137                remote_spinlock_lock( lock_xp );
    11181138
    11191139                // get pending forks counter
    1120                 count = hal_remote_lw( XPTR( page_cxy , &page_ptr->forks ) );
     1140                forks = hal_remote_lw( forks_xp );
    11211141               
    1122                 if( count )  // decrement pending forks counter
     1142                if( forks )  // decrement pending forks counter
    11231143                {
    1124                     forks_xp = XPTR( page_cxy , &page_ptr->forks );
    11251144                    hal_remote_atomic_add( forks_xp , -1 );
    11261145                } 
     
    11391158                }
    11401159
    1141                 // FIXME unlock the physical page
     1160                // release lock protecting page descriptor
     1161                remote_spinlock_unlock( lock_xp );
    11421162            }
    11431163        }
     
    14181438#if DEBUG_VMM_GET_ONE_PPN
    14191439thread_t * this = CURRENT_THREAD;
    1420 // if( DEBUG_VMM_GET_ONE_PPN < (uint32_t)hal_get_cycles() )
    1421 if( (vpn == 0x403) && ((local_cxy == 0) || (this->type == THREAD_RPC)) )
     1440if( DEBUG_VMM_GET_ONE_PPN < (uint32_t)hal_get_cycles() )
    14221441printk("\n[DBG] %s : thread %x enter for vpn = %x / type = %s / index = %d\n",
    14231442__FUNCTION__, this, vpn, vseg_type_str(type), index );
     
    14821501
    14831502#if (DEBUG_VMM_GET_ONE_PPN & 0x1)
    1484 if( (vpn == 0x403) && ((local_cxy == 0) || (this->type == THREAD_RPC)) )
    1485 // if( DEBUG_VMM_GET_ONE_PPN < (uint32_t)hal_get_cycles() )
     1503if( DEBUG_VMM_GET_ONE_PPN < (uint32_t)hal_get_cycles() )
    14861504printk("\n[DBG] %s : thread %x for vpn = %x / elf_offset = %x\n",
    14871505__FUNCTION__, this, vpn, elf_offset );
     
    14991517
    15001518#if (DEBUG_VMM_GET_ONE_PPN & 0x1)
    1501 // if( DEBUG_VMM_GET_ONE_PPN < (uint32_t)hal_get_cycles() )
    1502 if( (vpn == 0x403) && ((local_cxy == 0) || (this->type == THREAD_RPC)) )
     1519if( DEBUG_VMM_GET_ONE_PPN < (uint32_t)hal_get_cycles() )
    15031520printk("\n[DBG] %s : thread%x for vpn = %x / fully in BSS\n",
    15041521__FUNCTION__, this, vpn );
     
    15191536
    15201537#if (DEBUG_VMM_GET_ONE_PPN & 0x1)
    1521 // if( DEBUG_VMM_GET_ONE_PPN < (uint32_t)hal_get_cycles() )
    1522 if( (vpn == 0x403) && ((local_cxy == 0) || (this->type == THREAD_RPC)) )
     1538if( DEBUG_VMM_GET_ONE_PPN < (uint32_t)hal_get_cycles() )
    15231539printk("\n[DBG] %s : thread %x, for vpn = %x / fully in mapper\n",
    15241540__FUNCTION__, this, vpn );
     
    15511567
    15521568#if (DEBUG_VMM_GET_ONE_PPN & 0x1)
    1553 // if( DEBUG_VMM_GET_ONE_PPN < (uint32_t)hal_get_cycles() )
    1554 if( (vpn == 0x403) && ((local_cxy == 0) || (this->type == THREAD_RPC)) )
     1569if( DEBUG_VMM_GET_ONE_PPN < (uint32_t)hal_get_cycles() )
    15551570printk("\n[DBG] %s : thread %x for vpn = %x / both mapper & BSS\n"
    15561571"      %d bytes from mapper / %d bytes from BSS\n",
     
    15991614
    16001615#if DEBUG_VMM_GET_ONE_PPN
    1601 // if( DEBUG_VMM_GET_ONE_PPN < (uint32_t)hal_get_cycles() )
    1602 if( (vpn == 0x403) && ((local_cxy == 0) || (this->type == THREAD_RPC)) )
     1616if( DEBUG_VMM_GET_ONE_PPN < (uint32_t)hal_get_cycles() )
    16031617printk("\n[DBG] %s : thread %x exit for vpn = %x / ppn = %x\n",
    16041618__FUNCTION__ , this , vpn , *ppn );
     
    16281642#if DEBUG_VMM_GET_PTE
    16291643uint32_t   cycle = (uint32_t)hal_get_cycles();
    1630 // if( DEBUG_VMM_GET_PTE < cycle )
    1631 if( (vpn == 0x403) && ((local_cxy == 0) || (this->type == THREAD_RPC)) )
    1632 printk("\n[DBG] %s : thread %x enter / vpn %x / process %x / cow %d / cycle %d\n",
    1633 __FUNCTION__ , this , vpn , process->pid , cow , cycle );
     1644if( DEBUG_VMM_GET_PTE < cycle )
     1645printk("\n[DBG] %s : thread %x in process %x enter / vpn %x / cow %d / cycle %d\n",
     1646__FUNCTION__, this->trdid, process->pid, vpn, cow, cycle );
    16341647#endif
    16351648
     
    16441657    // vseg has been checked by the vmm_handle_page_fault() function
    16451658    assert( (vseg != NULL) , __FUNCTION__,
    1646     "vseg undefined / vpn %x / thread %x / process %x / core[%x,%d] / cycle %d\n",
    1647     vpn, this, process->pid, local_cxy, this->core->lid,
     1659    "vseg undefined / vpn %x / thread %x in process %x / core[%x,%d] / cycle %d\n",
     1660    vpn, this->trdid, process->pid, local_cxy, this->core->lid,
    16481661    (uint32_t)hal_get_cycles() );
    16491662
     
    16581671
    16591672        assert( (old_attr & GPT_MAPPED), __FUNCTION__,
    1660         "PTE unmapped for a COW exception / vpn %x / thread %x / process %x / cycle %d\n",
     1673        "PTE unmapped for a COW exception / vpn %x / thread %x in process %x / cycle %d\n",
    16611674        vpn, this, process->pid, (uint32_t)hal_get_cycles() );
    16621675
    16631676#if( DEBUG_VMM_GET_PTE & 1 )
    1664 // if( DEBUG_VMM_GET_PTE < cycle )
    1665 if( (vpn == 0x403) && ((local_cxy == 0) || (this->type == THREAD_RPC)) )
    1666 printk("\n[DBG] %s : thread %x handling COW for vpn %x in process %x\n",
    1667 __FUNCTION__, this, vpn, process->pid );
     1677if( DEBUG_VMM_GET_PTE < cycle )
     1678printk("\n[DBG] %s : thread %x in process %x handling COW for vpn %x\n",
     1679__FUNCTION__, this->trdid, process->pid, vpn );
    16681680#endif
    16691681
     
    16731685        page_t * page_ptr = GET_PTR( page_xp );
    16741686
     1687        // get extended pointers on forks and lock field in page descriptor
     1688        xptr_t forks_xp = XPTR( page_cxy , &page_ptr->forks );
     1689        xptr_t lock_xp  = XPTR( page_cxy , &page_ptr->lock );
     1690
     1691        // take lock protecting page descriptor
     1692        remote_spinlock_lock( lock_xp );
     1693
    16751694        // get number of pending forks in page descriptor
    1676         uint32_t forks = hal_remote_lw( XPTR( page_cxy , &page_ptr->forks ) );
     1695        uint32_t forks = hal_remote_lw( forks_xp );
    16771696
    16781697        if( forks )        // pending fork => allocate a new page, copy old to new
     
    16961715                    GET_PTR( old_base_xp ),
    16971716                    CONFIG_PPM_PAGE_SIZE );
     1717
     1718             // decrement pending forks counter in page descriptor
     1719             hal_remote_atomic_add( forks_xp , -1 );
    16981720        }             
    1699         else               // no pending fork => keep the existing page, reset COW
     1721        else               // no pending fork => keep the existing page
    17001722        {
    17011723            new_ppn = old_ppn;
    17021724        }
    17031725
     1726        // release lock protecting page descriptor
     1727        remote_spinlock_unlock( lock_xp );
     1728
    17041729        // build new_attr : reset COW and set WRITABLE,
    17051730        new_attr = (old_attr | GPT_WRITABLE) & (~GPT_COW);
     
    17071732        // update GPT[vpn] for all GPT copies
    17081733        vmm_global_update_pte( process, vpn, new_attr, new_ppn );
    1709 
    1710         // decrement pending forks counter in page descriptor
    1711         hal_remote_atomic_add( XPTR( page_cxy , &page_ptr->forks ) , -1 );
    17121734    }
    17131735    else        //////////// page_fault request ///////////////////////////
     
    17241746
    17251747#if( DEBUG_VMM_GET_PTE & 1 )
    1726 // if( DEBUG_VMM_GET_PTE < cycle )
    1727 if( (vpn == 0x403) && ((local_cxy == 0) || (this->type == THREAD_RPC)) )
    1728 printk("\n[DBG] %s : thread %x handling page fault for vpn %x in process %x\n",
    1729 __FUNCTION__, this, vpn, process->pid );
     1748if( DEBUG_VMM_GET_PTE < cycle )
     1749printk("\n[DBG] %s : thread %x in process %x handling page fault for vpn %x\n",
     1750__FUNCTION__, this->trdid, process->pid, vpn );
    17301751#endif
    17311752            // allocate new_ppn, and initialize the new page
     
    17671788#if DEBUG_VMM_GET_PTE
    17681789cycle = (uint32_t)hal_get_cycles();
    1769 // if( DEBUG_VMM_GET_PTE < cycle )
    1770 if( (vpn == 0x403) && (local_cxy == 0) )
    1771 printk("\n[DBG] %s : thread %x exit / vpn %x in process %x / ppn %x / attr %x / cycle %d\n",
    1772 __FUNCTION__, this, vpn, process->pid, new_ppn, new_attr, cycle );
     1790if( DEBUG_VMM_GET_PTE < cycle )
     1791printk("\n[DBG] %s : thread %x in process %x exit / vpn %x / ppn %x / attr %x / cycle %d\n",
     1792__FUNCTION__, this->trdid, process->pid, vpn, new_ppn, new_attr, cycle );
    17731793#endif
    17741794
     
    17971817#if DEBUG_VMM_HANDLE_PAGE_FAULT
    17981818uint32_t cycle = (uint32_t)hal_get_cycles();
    1799 // if( DEBUG_VMM_HANDLE_PAGE_FAULT < cycle )
    1800 if( (vpn == 0x403) && (local_cxy == 0) )
     1819if( DEBUG_VMM_HANDLE_PAGE_FAULT < cycle )
    18011820printk("\n[DBG] %s : thread %x in process %x enter for vpn %x / core[%x,%d] / cycle %d\n",
    18021821__FUNCTION__, this, process->pid, vpn, local_cxy, this->core->lid, cycle );
     
    18361855
    18371856#if DEBUG_VMM_HANDLE_PAGE_FAULT
    1838 // if( DEBUG_VMM_HANDLE_PAGE_FAULT < cycle )
    1839 if( (vpn == 0x403) && (local_cxy == 0) )
     1857if( DEBUG_VMM_HANDLE_PAGE_FAULT < cycle )
    18401858printk("\n[DBG] %s : thread %x in process %x call RPC_VMM_GET_PTE\n",
    18411859__FUNCTION__, this, process->pid );
     
    18701888#if DEBUG_VMM_HANDLE_PAGE_FAULT
    18711889cycle = (uint32_t)hal_get_cycles();
    1872 // if( DEBUG_VMM_HANDLE_PAGE_FAULT < cycle )
    1873 if( (vpn == 0x403) && (local_cxy == 0) )
     1890if( DEBUG_VMM_HANDLE_PAGE_FAULT < cycle )
    18741891printk("\n[DBG] %s : thread %x in process %x exit for vpn %x / core[%x,%d] / cycle %d\n",
    18751892__FUNCTION__, this, process->pid, vpn, local_cxy, this->core->lid, cycle );
  • trunk/kernel/mm/vmm.h

    r457 r469  
    166166 *   valid GPT entries in parent GPT are copied to the child GPT. The COW flag is not set.
    167167 * - no STACK vseg is copied from  parent VMM to child VMM, because the child STACK vseg
    168  *   must be copied from the cluster containing the user thread requesting the fork().
     168 *   must be copied later from the cluster containing the user thread requesting the fork().
    169169 *********************************************************************************************
    170170 * @ child_process     : local pointer on local child process descriptor.
  • trunk/kernel/syscalls/sys_read.c

    r459 r469  
    231231tm_end = hal_get_cycles();
    232232if( DEBUG_SYS_READ < tm_end )
    233 printk("\n[DBG] %s : thread %x in process %x exit / cycle %d\n"
    234 "nbytes %d / file_id %d / cost %d\n",
    235 __FUNCTION__ , this->trdid, process->pid,
    236 (uint32_t)tm_start , nbytes , file_id , (uint32_t)(tm_end - tm_start) );
     233printk("\n[DBG] %s : thread %x in process %x exit / cycle %d / cost %d\n",
     234__FUNCTION__ , this->trdid, process->pid, (uint32_t)tm_start, (uint32_t)(tm_end - tm_start) );
    237235#endif
    238236
  • trunk/kernel/syscalls/sys_sem.c

    r457 r469  
    7474
    7575#if DEBUG_SYSCALLS_ERROR
    76 printk("\n[ERROR] in %s : unmapped semaphore pointer %x / thread %x in process %x\n",
    77 __FUNCTION__ , (intptr_t)vaddr, this->trdid, process->pid );
     76printk("\n[ERROR] in %s : unmapped semaphore pointer %x / thread %x in process %x / cycle %d\n",
     77__FUNCTION__ , (intptr_t)vaddr, this->trdid, process->pid, (uint32_t)hal_get_cycles() );
    7878vmm_display( process , false );
    7979#endif
     
    9797
    9898#if DEBUG_SYSCALLS_ERROR
    99 printk("\n[ERROR] in %s : cannot create semaphore / thread %x in process %x\n",
    100 __FUNCTION__, this->trdid, process->pid );
     99printk("\n[ERROR] in %s INIT: cannot create semaphore / thread %x in process %x / cycle %d\n",
     100__FUNCTION__, this->trdid, process->pid, (uint32_t)hal_get_cycles() );
    101101#endif
    102102                this->errno = ENOMEM;
     
    115115
    116116#if DEBUG_SYSCALLS_ERROR
    117 printk("\n[ERROR] in %s : unmapped buffer for current value %x / thread %x in process %x\n",
    118 __FUNCTION__ , (intptr_t)current_value, this->trdid, process->pid );
     117printk("\n[ERROR] in %s GETVALUE: unmapped target buffer %x / thread %x in process %x / cycle %d\n",
     118__FUNCTION__ , (intptr_t)current_value, this->trdid, process->pid, (uint32_t)hal_get_cycles() );
    119119vmm_display( process , false );
    120120#endif
     
    131131
    132132#if DEBUG_SYSCALLS_ERROR
    133 printk("\n[ERROR] in %s : semaphore %x not registered / thread %x in process %x\n",
    134 __FUNCTION__ , (intptr_t)vaddr, this->trdid, process->pid );
     133printk("\n[ERROR] in %s GETVALUE: semaphore %x not found / thread %x in process %x / cycle %d\n",
     134__FUNCTION__ , (intptr_t)vaddr, this->trdid, process->pid, (uint32_t)hal_get_cycles() );
    135135#endif
    136136                this->errno = EINVAL;
     
    157157
    158158#if DEBUG_SYSCALLS_ERROR
    159 printk("\n[ERROR] in %s : semaphore %x not registered / thread %x in process %x\n",
    160 __FUNCTION__ , (intptr_t)vaddr, this->trdid, process->pid );
     159printk("\n[ERROR] in %s WAIT: semaphore %x not found / thread %x in process %x / cycle %d\n",
     160__FUNCTION__ , (intptr_t)vaddr, this->trdid, process->pid, (uint32_t)hal_get_cycles() );
     161vmm_display( process , true );
    161162#endif
    162163                this->errno = EINVAL;
     
    180181
    181182#if DEBUG_SYSCALLS_ERROR
    182 printk("\n[ERROR] in %s : semaphore %x not registered / thread %x in process %x\n",
    183 __FUNCTION__ , (intptr_t)vaddr, this->trdid, process->pid );
     183printk("\n[ERROR] in %s POST: semaphore %x not found / thread %x in process %x / cycle %d\n",
     184__FUNCTION__ , (intptr_t)vaddr, this->trdid, process->pid, (uint32_t)hal_get_cycles() );
    184185#endif
    185186                this->errno = EINVAL;
     
    203204
    204205#if DEBUG_SYSCALLS_ERROR
    205 printk("\n[ERROR] in %s : semaphore %x not registered / thread %x in process %x\n",
    206 __FUNCTION__ , (intptr_t)vaddr, this->trdid, process->pid );
     206printk("\n[ERROR] in %s DESTROY: semaphore %x not found / thread %x in process %x / cycle %d\n",
     207__FUNCTION__ , (intptr_t)vaddr, this->trdid, process->pid, (uint32_t)hal_get_cycles() );
    207208#endif
    208209                this->errno = EINVAL;
     
    220221
    221222#if DEBUG_SYSCALLS_ERROR
    222 printk("\n[ERROR] in %s : undefined operation type %d / thread %x in process %x\n",
    223 __FUNCTION__ , operation, this->trdid, process->pid );
     223printk("\n[ERROR] in %s : undefined operation type %d / thread %x in process %x / cycle %d\n",
     224__FUNCTION__ , operation, this->trdid, process->pid, (uint32_t)hal_get_cycles() );
    224225#endif
    225226            this->errno = EINVAL;
  • trunk/kernel/syscalls/sys_write.c

    r459 r469  
    6161    reg_t        save_sr;         // required to enable IRQs during syscall
    6262
    63 #if (DEBUG_SYS_WRITE & 1)
    64 enter_sys_write = (uint32_t)tm_start;
    65 #endif
    66 
    6763        thread_t   * this = CURRENT_THREAD;
    6864        process_t  * process = this->process;
     
    7773#endif
    7874 
     75#if (DEBUG_SYS_WRITE & 1)
     76enter_sys_write = (uint32_t)tm_start;
     77#endif
     78
    7979    // check file_id argument
    8080        if( file_id >= CONFIG_PROCESS_FILE_MAX_NR )
     
    195195tm_end = hal_get_cycles();
    196196if( DEBUG_SYS_WRITE < tm_end )
    197 printk("\n[DBG] %s : thread %x in process %x exit / cycle %d\n"
    198 "nbytes %d / file_id %d / cost %d\n",
    199 __FUNCTION__, this->trdid, process->pid, (uint32_t)tm_start,
    200 nbytes, file_id , (uint32_t)(tm_end - tm_start) );
     197printk("\n[DBG] %s : thread %x in process %x exit / cycle %d / cost %d\n",
     198__FUNCTION__, this->trdid, process->pid, (uint32_t)tm_start, (uint32_t)(tm_end - tm_start) );
    201199#endif
    202200 
Note: See TracChangeset for help on using the changeset viewer.