Changeset 441 for trunk


Ignore:
Timestamp:
May 9, 2018, 3:13:56 PM (7 years ago)
Author:
alain
Message:

Fix a bug in rpc_vmm_get_pte_client() function (bad RPC index).

Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/fs/vfs.c

    r438 r441  
    14411441            if( error )
    14421442            {
    1443                 printk("\n[ERROR] in %s : no memory for inode <%s> in path <%s>\n",
    1444                 __FUNCTION__ , name , pathname );
     1443                printk("\n[ERROR] in %s : thread %x cannot allocate inode for path <%s>\n",
     1444                __FUNCTION__ , this , pathname );
    14451445                return ENOMEM;
    14461446            }
     
    14641464            if ( error )
    14651465            {
    1466                 printk("\n[ERROR] in %s : core[%x,%d] / <%s> node not found in <%s>\n",
    1467                 __FUNCTION__ , local_cxy , this->core->lid , name , pathname );
     1466                printk("\n[ERROR] in %s : thread %x / <%s> node not found in <%s>\n",
     1467                __FUNCTION__ , this , name , pathname );
    14681468                return ENOENT;
    14691469            }
     
    14891489                if ( error )
    14901490                {
    1491                     printk("\n[ERROR] in %s : core[%x,%d] cannot access device for <%s>\n",
    1492                     __FUNCTION__ , local_cxy , this->core->lid , name );
     1491                    printk("\n[ERROR] in %s : thread %x / cannot access device for <%s>\n",
     1492                    __FUNCTION__ , this , name );
    14931493                    return EIO;
    14941494                }
     
    15191519        // if( error )
    15201520        // {
    1521         //     printk("\n[ERROR] in %s : permission denied for %s\n", __FUNCTION__ , name );
     1521        //     printk("\n[ERROR] in %s : thread %x / permission denied for %s\n",
     1522        //     __FUNCTION__ , this , name );
    15221523        //     return EACCES;
    15231524        // }
  • trunk/kernel/kern/process.c

    r440 r441  
    11651165cycle = (uint32_t)hal_get_cycles();
    11661166if( DEBUG_PROCESS_MAKE_FORK < cycle )
    1167 printk("\n[DBG] %s : thread %x created child thread %x / cycle %d\n",
    1168 __FUNCTION__ , CURRENT_THREAD, thread, cycle );
     1167printk("\n[DBG] %s : thread %x created child thread %x on core[%x,%d] / cycle %d\n",
     1168__FUNCTION__ , CURRENT_THREAD, thread, local_cxy, thread->core->lid, cycle );
    11691169#endif
    11701170
     
    12221222{
    12231223    char           * path;                    // pathname to .elf file
    1224     pid_t            pid;                     // old_process PID / given to new_process
     1224    pid_t            pid;                     // old_process PID, given to new_process
    12251225    pid_t            temp_pid;                // temporary PID / given to old_process
    12261226    process_t      * old_process;             // local pointer on old process
     
    12311231    pthread_attr_t   attr;                    // new thread attributes
    12321232    lid_t            lid;                     // selected core local index
    1233         error_t          error;
    1234 
     1233        error_t          error;                   // value returned by called functions
     1234   
    12351235    // get old_thread / old_process / PID / parent_xp
    12361236    old_thread  = CURRENT_THREAD;
     
    12401240   
    12411241        // get .elf pathname from exec_info
    1242         path     = exec_info->path;
     1242        path        = exec_info->path;
    12431243
    12441244    // this function must be executed by a thread running in owner cluster
     
    12611261    if( new_process == NULL )
    12621262    {
    1263         printk("\n[ERROR] in %s : cannot allocate process descriptor in cluster %x\n",
    1264         __FUNCTION__ , local_cxy );
     1263        printk("\n[ERROR] in %s : cannot allocate process for %s\n", __FUNCTION__ , path );
    12651264        return -1;
    12661265    }
     
    12971296    // register code & data vsegs as well as entry-point in new process VMM,
    12981297    // and register extended pointer on .elf file in process descriptor
    1299         if( elf_load_process( path , new_process ) )
     1298        error = elf_load_process( path , new_process );
     1299
     1300    if( error )
    13001301        {
    1301                 printk("\n[ERROR] in %s : failed to access .elf file for path %s\n",
    1302                 __FUNCTION__ , path );
     1302                printk("\n[ERROR] in %s : failed to access <%s>\n", __FUNCTION__ , path );
     1303        process_txt_set_ownership( XPTR( local_cxy , old_process) );
     1304        process_txt_detach( XPTR( local_cxy , new_process) );
    13031305        process_destroy( new_process );
     1306        old_process->pid = pid;
    13041307        return -1;
    13051308        }
     
    13281331        if( error )
    13291332        {
    1330                 printk("\n[ERROR] in %s : cannot create thread for process %x\n",
    1331             __FUNCTION__ , new_process );
     1333                printk("\n[ERROR] in %s : cannot create thread for %s\n", __FUNCTION__ , path );
     1334        process_txt_set_ownership( XPTR( local_cxy , old_process) );
     1335        process_txt_detach( XPTR( local_cxy , new_process) );
    13321336        process_destroy( new_process );
     1337        old_process->pid = pid;
    13331338        return -1;
    13341339        }
     
    13751380cycle = (uint32_t)hal_get_cycles();
    13761381if( DEBUG_PROCESS_MAKE_EXEC < cycle )
    1377 printk("\n[DBG] %s : old_thread %x blocked / new_thread %x activated / cycle %d\n",
     1382printk("\n[DBG] %s : old thread %x blocked for delete / new thread %x activated / cycle %d\n",
    13781383__FUNCTION__ , old_thread , new_thread , cycle );
    13791384#endif
     
    17351740    remote_spinlock_unlock( lock_xp );
    17361741
    1737 #if( DEBUG_PROCESS_TXT_ATTACH & 1 )
     1742#if DEBUG_PROCESS_TXT_ATTACH
     1743cycle  = (uint32_t)hal_get_cycles();
     1744uint32_t txt_id = hal_remote_lw( XPTR( chdev_cxy , &chdev_ptr->channel ) );
    17381745if( DEBUG_PROCESS_TXT_ATTACH < cycle )
    1739 {
    1740     xptr_t root_xp = XPTR( chdev_cxy , &chdev_ptr->ext.txt.root );
    1741     xptr_t iter_xp;
    1742     XLIST_FOREACH( root_xp , iter_xp )
    1743     {
    1744         xptr_t      current_xp  = XLIST_ELEMENT( iter_xp , process_t , txt_list );
    1745         process_t * current_ptr = GET_PTR( current_xp );
    1746 
    1747         printk("\n[DBG] %s : attached_process %x (pid = %x)\n",
    1748         __FUNCTION__, current_ptr, current_ptr->pid );
    1749     }
    1750 }
    1751 #endif
    1752 
    1753 #if DEBUG_PROCESS_TXT_ATTACH
    1754 cycle = (uint32_t)hal_get_cycles();
    1755 if( DEBUG_PROCESS_TXT_ATTACH < cycle )
    1756 printk("\n[DBG] %s : thread %x exit / process %x detached from TXT / cycle %d\n",
    1757 __FUNCTION__, CURRENT_THREAD, process->pid, cycle );
     1746printk("\n[DBG] %s : thread %x exit / process %x detached from TXT %d / cycle %d\n",
     1747__FUNCTION__, CURRENT_THREAD, process_pid, txt_id, cycle );
    17581748#endif
    17591749
     
    18421832uint32_t cycle = (uint32_t)hal_get_cycles();
    18431833if( DEBUG_PROCESS_TXT_ATTACH < cycle )
    1844 printk("\n[DBG] %s : thread %x enter / process %x / pid %x / cycle %d\n",
    1845 __FUNCTION__, CURRENT_THREAD, process_ptr, process_pid, cycle );
     1834printk("\n[DBG] %s : thread %x enter / process %x / cycle %d\n",
     1835__FUNCTION__, CURRENT_THREAD, process_pid, cycle );
    18461836#endif
    18471837
  • trunk/kernel/kern/process.h

    r440 r441  
    510510 * It is called only by the process_reference_init() function when creating a KSH process.
    511511 * It makes a kernel panic if no free TXT terminal is found.
    512  * As a KSH process is never deleted, the allocated TXT terminal is never released.
     512 * The allocated TXT terminal is only released if the KSH process is deleted,
     513 * which is a rare and abnormal event.
    513514 *********************************************************************************************
    514515 * @ return TXT terminal index if succes / kernel panic if no terminal found.
  • trunk/kernel/kern/rpc.c

    r440 r441  
    16661666
    16671667/////////////////////////////////////////////////////////////////////////////////////////
    1668 // [21]          Marshaling functions attached to RPC_VMM_GET_VSEG  (blocking)
     1668// [21]          Marshaling functions attached to RPC_VMM_GET_PTE  (blocking)
    16691669/////////////////////////////////////////////////////////////////////////////////////////
    16701670
     
    16891689    // initialise RPC descriptor header
    16901690    rpc_desc_t  rpc;
    1691     rpc.index    = RPC_VMM_GET_VSEG;
     1691    rpc.index    = RPC_VMM_GET_PTE;
    16921692    rpc.blocking = true;
    16931693    rpc.responses = 1;
     
    17691769    // initialise RPC descriptor header
    17701770    rpc_desc_t  rpc;
    1771     rpc.index    = RPC_THREAD_USER_CREATE;
     1771    rpc.index    = RPC_KCM_ALLOC;
    17721772    rpc.blocking = true;
    17731773    rpc.responses = 1;
     
    18191819    // initialise RPC descriptor header
    18201820    rpc_desc_t  rpc;
    1821     rpc.index    = RPC_THREAD_USER_CREATE;
     1821    rpc.index    = RPC_KCM_FREE;
    18221822    rpc.blocking = true;
    18231823    rpc.responses = 1;
  • trunk/kernel/kernel_config.h

    r440 r441  
    121121
    122122#define DEBUG_SYS_DISPLAY              0
    123 #define DEBUG_SYS_EXEC                 2
    124 #define DEBUG_SYS_EXIT                 2
     123#define DEBUG_SYS_EXEC                 0
     124#define DEBUG_SYS_EXIT                 0
    125125#define DEBUG_SYS_FG                   0
    126 #define DEBUG_SYS_FORK                 2
     126#define DEBUG_SYS_FORK                 0
    127127#define DEBUG_SYS_GET_CONFIG           0
    128128#define DEBUG_SYS_ISATTY               0
    129 #define DEBUG_SYS_KILL                 2
     129#define DEBUG_SYS_KILL                 0
    130130#define DEBUG_SYS_MMAP                 0
    131131#define DEBUG_SYS_READ                 0
    132132#define DEBUG_SYS_THREAD_CANCEL        0
    133133#define DEBUG_SYS_THREAD_CREATE        0
    134 #define DEBUG_SYS_THREAD_EXIT          0
     134#define DEBUG_SYS_THREAD_EXIT          1
    135135#define DEBUG_SYS_THREAD_JOIN          0
    136136#define DEBUG_SYS_THREAD_SLEEP         0
  • trunk/kernel/libk/elf.c

    r438 r441  
    4646           && (header->e_ident[EI_DATA] == ELFDATA2LSB)
    4747           && (header->e_ident[EI_VERSION] == EV_CURRENT)
    48 /*
    49            && (header->e_ident[EI_OSABI] == ELFOSABI_NONE)
    50 */
    5148           && ((header->e_machine == EM_MIPS) ||
    5249               (header->e_machine == EM_MIPS_RS3_LE) ||
     
    6360        if( header->e_ident[EI_VERSION] != EV_CURRENT )
    6461                printk("\n[ERROR] in %s : Elf is not in Current Version\n", __FUNCTION__);
    65 /*
    66         if( header->e_ident[EI_OSABI] != ELFOSABI_NONE )
    67                 printk("\n[ERROR] in %s : Unexpected Elf ABI, need UNIX System V ABI\n", __FUNCTION__ );
    68 */
     62
    6963        if( (header->e_machine != EM_MIPS) &&
    7064            (header->e_machine != EM_MIPS_RS3_LE) &&
     
    248242        if( error )
    249243        {
    250                 printk("\n[ERROR] in %s : failed to open file %s\n", __FUNCTION__ , pathname );
     244                printk("\n[ERROR] in %s : failed to open file <%s>\n", __FUNCTION__ , pathname );
    251245                return -1;
    252246        }
     
    263257        if( error )
    264258        {
    265                 printk("\n[ERROR] in %s : cannot get header file %s\n", __FUNCTION__ , pathname );
     259                printk("\n[ERROR] in %s : cannot get header for <%s>\n", __FUNCTION__ , pathname );
    266260                vfs_close( file_xp , file_id );
    267261                return -1;
     
    270264#if (DEBUG_ELF_LOAD & 1)
    271265if( DEBUG_ELF_LOAD < cycle )
    272 printk("\n[DBG] %s : loaded elf header for %s\n", __FUNCTION__ , pathname );
     266printk("\n[DBG] %s : loaded elf header for <%s>\n", __FUNCTION__ , pathname );
    273267#endif
    274268
     
    310304#if (DEBUG_ELF_LOAD & 1)
    311305if( DEBUG_ELF_LOAD < cycle )
    312 printk("\n[DBG] %s : segments array allocated for %s\n", __FUNCTION__ , pathname );
     306printk("\n[DBG] %s : segments array allocated for <%s>\n", __FUNCTION__ , pathname );
    313307#endif
    314308
     
    330324#if (DEBUG_ELF_LOAD & 1)
    331325if( DEBUG_ELF_LOAD < cycle )
    332 printk("\n[DBG] %s loaded segments descriptors for %s \n", __FUNCTION__ , pathname );
     326printk("\n[DBG] %s loaded segments descriptors for <%s>\n", __FUNCTION__ , pathname );
    333327#endif
    334328
  • trunk/kernel/mm/vmm.c

    r440 r441  
    13951395
    13961396#if DEBUG_VMM_GET_ONE_PPN
    1397 if( DEBUG_VMM_GET_ONE_PPN < (uint32_t)hal_get_cycles() )
     1397thread_t * this = CURRENT_THREAD;
     1398// if( DEBUG_VMM_GET_ONE_PPN < (uint32_t)hal_get_cycles() )
     1399if( (vpn == 0x403) && ((local_cxy == 0) || (this->type == THREAD_RPC)) )
    13981400printk("\n[DBG] %s : thread %x enter for vpn = %x / type = %s / index = %d\n",
    1399 __FUNCTION__, CURRENT_THREAD, vpn, vseg_type_str(type), index );
     1401__FUNCTION__, this, vpn, vseg_type_str(type), index );
    14001402#endif
    14011403
     
    14581460
    14591461#if (DEBUG_VMM_GET_ONE_PPN & 0x1)
    1460 if( DEBUG_VMM_GET_ONE_PPN < (uint32_t)hal_get_cycles() )
     1462if( (vpn == 0x403) && ((local_cxy == 0) || (this->type == THREAD_RPC)) )
     1463// if( DEBUG_VMM_GET_ONE_PPN < (uint32_t)hal_get_cycles() )
    14611464printk("\n[DBG] %s : thread %x for vpn = %x / elf_offset = %x\n",
    1462 __FUNCTION__, CURRENT_THREAD, vpn, elf_offset );
     1465__FUNCTION__, this, vpn, elf_offset );
    14631466#endif
    14641467
     
    14741477
    14751478#if (DEBUG_VMM_GET_ONE_PPN & 0x1)
    1476 if( DEBUG_VMM_GET_ONE_PPN < (uint32_t)hal_get_cycles() )
     1479// if( DEBUG_VMM_GET_ONE_PPN < (uint32_t)hal_get_cycles() )
     1480if( (vpn == 0x403) && ((local_cxy == 0) || (this->type == THREAD_RPC)) )
    14771481printk("\n[DBG] %s : thread%x for vpn = %x / fully in BSS\n",
    1478 __FUNCTION__, CURRENT_THREAD, vpn );
     1482__FUNCTION__, this, vpn );
    14791483#endif
    14801484
     
    14931497
    14941498#if (DEBUG_VMM_GET_ONE_PPN & 0x1)
    1495 if( DEBUG_VMM_GET_ONE_PPN < (uint32_t)hal_get_cycles() )
     1499// if( DEBUG_VMM_GET_ONE_PPN < (uint32_t)hal_get_cycles() )
     1500if( (vpn == 0x403) && ((local_cxy == 0) || (this->type == THREAD_RPC)) )
    14961501printk("\n[DBG] %s : thread %x, for vpn = %x / fully in mapper\n",
    1497 __FUNCTION__, CURRENT_THREAD, vpn );
     1502__FUNCTION__, this, vpn );
    14981503#endif
    14991504                if( mapper_cxy == local_cxy )
     
    15241529
    15251530#if (DEBUG_VMM_GET_ONE_PPN & 0x1)
    1526 if( DEBUG_VMM_GET_ONE_PPN < (uint32_t)hal_get_cycles() )
     1531// if( DEBUG_VMM_GET_ONE_PPN < (uint32_t)hal_get_cycles() )
     1532if( (vpn == 0x403) && ((local_cxy == 0) || (this->type == THREAD_RPC)) )
    15271533printk("\n[DBG] %s : thread %x for vpn = %x / both mapper & BSS\n"
    15281534"      %d bytes from mapper / %d bytes from BSS\n",
    1529 __FUNCTION__, CURRENT_THREAD, vpn,
     1535__FUNCTION__, this, vpn,
    15301536file_size - offset , offset + CONFIG_PPM_PAGE_SIZE - file_size  );
    15311537#endif
     
    15711577
    15721578#if DEBUG_VMM_GET_ONE_PPN
    1573 if( DEBUG_VMM_GET_ONE_PPN < (uint32_t)hal_get_cycles() )
     1579// if( DEBUG_VMM_GET_ONE_PPN < (uint32_t)hal_get_cycles() )
     1580if( (vpn == 0x403) && ((local_cxy == 0) || (this->type == THREAD_RPC)) )
    15741581printk("\n[DBG] %s : thread %x exit for vpn = %x / ppn = %x\n",
    1575 __FUNCTION__ , CURRENT_THREAD , vpn , *ppn );
     1582__FUNCTION__ , this , vpn , *ppn );
    15761583#endif
    15771584
     
    15951602    error_t    error;
    15961603
     1604    thread_t * this  = CURRENT_THREAD;
     1605
    15971606#if DEBUG_VMM_GET_PTE
    1598 uint32_t cycle = (uint32_t)hal_get_cycles();
    1599 if( DEBUG_VMM_GET_PTE < cycle )
     1607uint32_t   cycle = (uint32_t)hal_get_cycles();
     1608// if( DEBUG_VMM_GET_PTE < cycle )
     1609if( (vpn == 0x403) && ((local_cxy == 0) || (this->type == THREAD_RPC)) )
    16001610printk("\n[DBG] %s : thread %x enter / vpn %x / process %x / cow %d / cycle %d\n",
    1601 __FUNCTION__ , CURRENT_THREAD , vpn , process->pid , cow , cycle );
     1611__FUNCTION__ , this , vpn , process->pid , cow , cycle );
    16021612#endif
    16031613
     
    16131623    assert( (vseg != NULL) , __FUNCTION__,
    16141624    "vseg undefined / vpn %x / thread %x / process %x / core[%x,%d] / cycle %d\n",
    1615     vpn, CURRENT_THREAD, process->pid, local_cxy, CURRENT_THREAD->core->lid,
     1625    vpn, this, process->pid, local_cxy, this->core->lid,
    16161626    (uint32_t)hal_get_cycles() );
    16171627
     
    16271637        assert( (old_attr & GPT_MAPPED), __FUNCTION__,
    16281638        "PTE unmapped for a COW exception / vpn %x / thread %x / process %x / cycle %d\n",
    1629         vpn, CURRENT_THREAD, process->pid, (uint32_t)hal_get_cycles() );
     1639        vpn, this, process->pid, (uint32_t)hal_get_cycles() );
    16301640
    16311641#if( DEBUG_VMM_GET_PTE & 1 )
    1632 if( DEBUG_VMM_GET_PTE < cycle )
     1642// if( DEBUG_VMM_GET_PTE < cycle )
     1643if( (vpn == 0x403) && ((local_cxy == 0) || (this->type == THREAD_RPC)) )
    16331644printk("\n[DBG] %s : thread %x handling COW for vpn %x in process %x\n",
    1634 __FUNCTION__, CURRENT_THREAD, vpn, process->pid );
     1645__FUNCTION__, this, vpn, process->pid );
    16351646#endif
    16361647
     
    16911702
    16921703#if( DEBUG_VMM_GET_PTE & 1 )
    1693 if( DEBUG_VMM_GET_PTE < cycle )
     1704// if( DEBUG_VMM_GET_PTE < cycle )
     1705if( (vpn == 0x403) && ((local_cxy == 0) || (this->type == THREAD_RPC)) )
    16941706printk("\n[DBG] %s : thread %x handling page fault for vpn %x in process %x\n",
    1695 __FUNCTION__, CURRENT_THREAD, vpn, process->pid );
     1707__FUNCTION__, this, vpn, process->pid );
    16961708#endif
    16971709            // allocate new_ppn, and initialize the new page
     
    17331745#if DEBUG_VMM_GET_PTE
    17341746cycle = (uint32_t)hal_get_cycles();
    1735 if( DEBUG_VMM_GET_PTE < cycle )
     1747// if( DEBUG_VMM_GET_PTE < cycle )
     1748if( (vpn == 0x403) && (local_cxy == 0) )
    17361749printk("\n[DBG] %s : thread %x exit / vpn %x in process %x / ppn %x / attr %x / cycle %d\n",
    1737 __FUNCTION__, CURRENT_THREAD, vpn, process->pid, new_ppn, new_attr, cycle );
     1750__FUNCTION__, this, vpn, process->pid, new_ppn, new_attr, cycle );
    17381751#endif
    17391752
     
    17621775#if DEBUG_VMM_HANDLE_PAGE_FAULT
    17631776uint32_t cycle = (uint32_t)hal_get_cycles();
    1764 if( DEBUG_VMM_HANDLE_PAGE_FAULT < cycle )
    1765 printk("\n[DBG] %s : thread %x enter for vpn %x / process %x / core[%x,%d] / cycle %d\n",
    1766 __FUNCTION__, this, vpn, process->pid, local_cxy, this->core->lid, cycle );
     1777// if( DEBUG_VMM_HANDLE_PAGE_FAULT < cycle )
     1778if( (vpn == 0x403) && (local_cxy == 0) )
     1779printk("\n[DBG] %s : thread %x in process %x enter for vpn %x / core[%x,%d] / cycle %d\n",
     1780__FUNCTION__, this, process->pid, vpn, local_cxy, this->core->lid, cycle );
    17671781#endif
    17681782
     
    17981812    if( local_cxy != ref_cxy ) 
    17991813    {
     1814
     1815#if DEBUG_VMM_HANDLE_PAGE_FAULT
     1816// if( DEBUG_VMM_HANDLE_PAGE_FAULT < cycle )
     1817if( (vpn == 0x403) && (local_cxy == 0) )
     1818printk("\n[DBG] %s : thread %x in process %x call RPC_VMM_GET_PTE\n",
     1819__FUNCTION__, this, process->pid );
     1820#endif
     1821
    18001822        rpc_vmm_get_pte_client( ref_cxy,
    18011823                                ref_ptr,
     
    18261848#if DEBUG_VMM_HANDLE_PAGE_FAULT
    18271849cycle = (uint32_t)hal_get_cycles();
    1828 if( DEBUG_VMM_HANDLE_PAGE_FAULT < cycle )
    1829 printk("\n[DBG] %s : thread %x exit for vpn %x / process %x / cycle %d\n",
    1830 __FUNCTION__, this->trdid, vpn, process->pid, cycle );
     1850// if( DEBUG_VMM_HANDLE_PAGE_FAULT < cycle )
     1851if( (vpn == 0x403) && (local_cxy == 0) )
     1852printk("\n[DBG] %s : thread %x in process %x exit for vpn %x / core[%x,%d] / cycle %d\n",
     1853__FUNCTION__, this, process->pid, vpn, local_cxy, this->core->lid, cycle );
    18311854#endif
    18321855
    18331856    return error;
    18341857
    1835 }  // end vmm_handle_page_fault()
     1858}   // end vmm_handle_page_fault()
     1859
     1860
     1861
     1862
     1863
     1864
     1865
     1866
    18361867
    18371868/* deprecated April 2018  [AG]
  • trunk/kernel/syscalls/sys_exec.c

    r438 r441  
    150150// Implementation note:
    151151// This function must be called by the main thread (thread 0 in owner cluster).
    152 // IT build an exec_info_t structure containing all informations
     152// It build an exec_info_t structure containing all informations
    153153// required to initialize the new process descriptor and the associated thread.
    154154// It includes the process main() arguments, the environment variables,
     
    208208tm_start = hal_get_cycles();
    209209if( DEBUG_SYS_EXEC < tm_start )
    210 printk("\n[DBG] %s : thread %x enter / process %x / path %s / cycle = %d\n",
     210printk("\n[DBG] %s : thread %x in process %x enter for path <%s> / cycle = %d\n",
    211211__FUNCTION__, this, pid, exec_info.path, (uint32_t)tm_start );
    212212#endif
     
    219219
    220220#if DEBUG_SYSCALLS_ERROR
    221 printk("\n[ERROR] in %s : cannot access args\n", __FUNCTION__ );
     221printk("\n[ERROR] in %s : thread %x in process %x cannot access args\n",
     222__FUNCTION__ , this, pid );
    222223#endif
    223224            this->errno = EINVAL;
     
    233234
    234235#if DEBUG_SYCALLS_ERROR
    235 printk("\n[ERROR] in %s : cannot access envs\n", __FUNCTION__ );
     236printk("\n[ERROR] in %s : thread %x in process %x cannot access envs\n",
     237__FUNCTION__ , this, pid );
    236238#endif
    237239            this->errno = EINVAL;
     
    247249
    248250#if DEBUG_SYSCALLS_ERROR
    249 printk("\n[ERROR] in %s : cannot create process %x in cluster %x\n",
    250 __FUNCTION__, pid, CXY_FROM_PID(pid) );
     251printk("\n[ERROR] in %s : thread %x in process %x cannot create process for <%s>\n",
     252__FUNCTION__, this, pid, exec_info.path );
    251253#endif
    252254        this->errno = error;
     
    257259tm_end = hal_get_cycles();
    258260if( DEBUG_SYS_EXEC < tm_end )
    259 printk("\n[DBG] %s : thread %x exit / process %x / cost = %d / cycle %d\n",
     261printk("\n[DBG] %s : thread %x in process %x exit / cost = %d / cycle %d\n",
    260262__FUNCTION__, this, pid, (uint32_t)(tm_end - tm_start), (uint32_t)tm_end );
    261263#endif
    262264
    263     // deschedule <=> old thread suicide because the BLOCKED_GLOBAL
    264     // and the FLAG_REQ_DELETE have been set by process_make_exec()
     265    // In case of success, this calling thread deschedules, causing suicide,
     266    // because a new process descriptor and its associated main thread
     267    // have been created by the process_make_exec() function, and the
     268    // BLOCKED_GLOBAL & FLAG_REQ_DELETE bits have been set for the calling thread.
    265269    sched_yield( "old process suicide in sys_exec()" );
    266270
    267     assert( false , __FUNCTION__ , "This code should not be executed\n" );
    268 
    269271    return 0; 
    270272
  • trunk/kernel/syscalls/sys_exit.c

    r440 r441  
    5151#endif
    5252
    53     // get owner process descriptor pointers an cluster
     53    // get owner process descriptor pointers and cluster
    5454    xptr_t      owner_xp  = cluster_get_owner_process_from_pid( pid );
    5555    cxy_t       owner_cxy = GET_CXY( owner_xp );
     
    128128    sched_yield( "process exit" );
    129129
    130     // this code should never be executed
    131     assert( false , __FUNCTION__ , "this code should not be executed...\n" );
    132130        return 0;
    133131
  • trunk/kernel/syscalls/sys_read.c

    r440 r441  
    223223if( DEBUG_SYS_READ < tm_end )
    224224printk("\n[DBG] %s : thread %x exit / process %x / cycle %d\n"
    225 "nbytes = %d / first byte = %c / file_id = %d / cost = %d\n",
     225"nbytes = %d / file_id = %d / cost = %d\n",
    226226__FUNCTION__ , this, process->pid,
    227 (uint32_t)tm_start , nbytes , *((char *)(intptr_t)paddr) , file_id ,
    228 (uint32_t)(tm_end - tm_start) );
     227(uint32_t)tm_start , nbytes , file_id , (uint32_t)(tm_end - tm_start) );
    229228#endif
    230229
     
    232231exit_sys_read = (uint32_t)tm_end;
    233232
    234 printk("\n@@@@@@@@@@@@ timing to read character %c\n"
     233printk("\n@@@@@@@@@@@@ timing to read character\n"
    235234" - enter_sys_read          = %d / delta %d\n"
    236235" - enter_devfs_read        = %d / delta %d\n"
     
    247246" - exit_devfs_read         = %d / delta %d\n"
    248247" - exit_sys_read           = %d / delta %d\n",
    249 *((char *)(intptr_t)paddr) ,
    250248enter_sys_read          , 0 ,
    251249enter_devfs_read        , enter_devfs_read        - enter_sys_read          ,
  • trunk/kernel/syscalls/sys_write.c

    r440 r441  
    184184if( DEBUG_SYS_WRITE < tm_end )
    185185printk("\n[DBG] %s : thread %x exit / process %x / cycle %d\n"
    186 "nbytes = %d / first byte = %c / file_id = %d / cost = %d\n",
     186"nbytes = %d / file_id = %d / cost = %d\n",
    187187__FUNCTION__, this, process->pid, (uint32_t)tm_start,
    188 nbytes, *((char *)(intptr_t)paddr) , file_id , (uint32_t)(tm_end - tm_start) );
     188nbytes, file_id , (uint32_t)(tm_end - tm_start) );
    189189#endif
    190190 
     
    192192exit_sys_write = (uint32_t)tm_end;
    193193
    194 printk("\n@@@@@@@@@@@@ timing to write string %c\n"
     194printk("\n@@@@@@@@@@@@ timing to write\n"
    195195" - enter_sys_write          = %d / delta %d\n"
    196196" - enter_devfs_write        = %d / delta %d\n"
     
    207207" - exit_devfs_write         = %d / delta %d\n"
    208208" - exit_sys_write           = %d / delta %d\n",
    209 *((char *)(intptr_t)paddr) ,
    210209enter_sys_write          , 0 ,
    211210enter_devfs_write        , enter_devfs_write        - enter_sys_write          ,
  • trunk/libs/mini-libc/stdlib.c

    r439 r441  
    166166                    va_list      * args )
    167167{
    168     unsigned int ps = 0;    // write pointer to the string buffer
     168    unsigned int ps = 0;    // write index to the string buffer
    169169
    170170#define TO_STREAM(x) do { string[ps] = (x); ps++; if(ps==length) return -1; } while(0);
  • trunk/user/init/init.c

    r440 r441  
    1818#include <pthread.h>
    1919
    20 #define DEBUG_INIT 1
     20#define DEBUG_INIT_PROCESS 1
    2121
    2222// TODO make the cxy computation portable [AG]
     
    7676    }
    7777 
    78 #if DEBUG_INIT
     78#if DEBUG_INIT_PROCESS
    7979
    8080    unsigned int  x_size;        // number of clusters in a row
     
    160160        } // end KSH kill handling
    161161
    162 #if( DEBUG_INIT )
     162#if DEBUG_INIT_PROCESS
    163163
    164164        // INIT displays processes and threads in all clusters
  • trunk/user/ksh/ksh.c

    r440 r441  
    395395        int                  ret_exec;           // return value from exec
    396396    unsigned int         ksh_pid;            // KSH process PID
    397     unsigned int         new_pid;            // new process PID
    398     unsigned int         rcv_pid;            // terminating process PID
    399397        char               * pathname;           // path to .elf file
    400398    unsigned int         background;         // background execution if non zero
     
    425423    else if (ret_fork == 0)      // it is the CHILD process
    426424    {
    427         // give back to KSH terminal ownership if required
    428         if( background ) fg( ksh_pid );
    429 
    430425        // CHILD process exec NEW process
    431426        ret_exec = exec( pathname , NULL , NULL );
    432427
     428        // this is only executed in case of exec failure
    433429        if( ret_exec )
    434430        {
    435             printf("  error: new process unable to exec <%s>\n", pathname );
    436             return;
     431            printf("  error: child process unable to exec <%s>\n", pathname );
     432            exit( 0 );
    437433        }   
    438434        }
    439435    else                        // it is the parent KSH : ret_fork is the new process PID
    440436    {
    441         new_pid = ret_fork;
    442 
    443         // wait new process completion
    444         rcv_pid = wait( &status );
    445 
    446         if( rcv_pid == new_pid )
    447         {
    448             printf("\n\n   %s normal termination / status = %x\n\n",
    449             pathname , (status &0xFF) );
    450             return;
    451         }
    452         else
    453         {
    454             printf("\n\n   %s abnormal termination / status = %x\n\n",
    455             pathname , (status &0xFF) );
    456             return;
    457         }
     437        // give back terminal ownership to KSH if new process created in background /
     438        // wait new process completion before returning to command interpreter otherwise
     439        if( background )   fg( ksh_pid );
     440        else               wait( &status );
     441
     442        // return to command interpreter
     443        return;
    458444    }
    459445}   // end cmd_load
     
    758744                                                printf("# ");
    759745                                        }
     746                    else
     747                    {
     748                        printf("\n# ");
     749                    }
    760750                                }
    761751                                else if (c == '\t')     // tabulation => do nothing
  • trunk/user/sort/sort.c

    r440 r441  
    156156    unsigned int  main_uid   = ptr->main_uid;
    157157
    158 printf("\n### core[%x,%d] enter sort : threads %d / thread_uid %x / main_uid %x / cycle %d\n",
    159 cxy, lid, threads, thread_uid, main_uid, (int)cycle );
    160 
    161     while( 1 ) { asm volatile("nop"); }
    162 
    163158    unsigned int  items      = ARRAY_LENGTH / threads;
    164159    unsigned int  stages     = __builtin_ctz( threads ) + 1;
     
    316311                if( thread_uid != main_uid )
    317312                {
    318 
    319 get_cycle( &cycle );
    320 printf("\n### main creates thread_uid %d / &sort_arg %x / cycle %d\n",
    321 thread_uid, &arg[thread_uid], (unsigned int)cycle );
    322 
    323313                    if ( pthread_create( &trdid,              // not used because no join
    324314                                         &attr[thread_uid],   // thread attributes
     
    344334    sort( &arg[main_uid] );
    345335
     336while( 1 ) asm volatile( "nop" );
     337   
    346338    // Check result
    347339    int    success = 1;
     
    352344                         (threads==512) ) ? array1 : array0;
    353345   
    354     for( n=0 ; n<(ARRAY_LENGTH-1) ; n++ )
     346    for( n=0 ; n<(ARRAY_LENGTH-2) ; n++ )
    355347    {
    356348        if ( res_array[n] > res_array[n+1] )
Note: See TracChangeset for help on using the changeset viewer.