Ignore:
Timestamp:
Aug 2, 2018, 11:47:13 AM (6 years ago)
Author:
alain
Message:

This version modifies the exec syscall and fixes a large number of small bugs.
The version number has been updated (0.1)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/syscalls/sys_exec.c

    r441 r457  
    2323
    2424#include <kernel_config.h>
    25 #include <hal_types.h>
     25#include <hal_kernel_types.h>
    2626#include <hal_uspace.h>
    2727#include <errno.h>
     
    152152// It build an exec_info_t structure containing all informations
    153153// required to initialize the new process descriptor and the associated thread.
    154 // It includes the process main() arguments, the environment variables,
     154// It includes the new process main() arguments, the environment variables,
    155155// and the pathname to the new process .elf file.
    156156// It calls the process_exec_get_strings() functions to copy the main() arguments and
    157157// the environment variables from user buffers to the exec_info_t structure, allocate
    158158// and call the process_make_exec() function.
    159 // As it must destroy all parent process copies, and all parent threads in all clusters,
    160 // the process_make_exec() function must be executed in the parent owner cluster,
    161 // and this sys_exec() function uses a RPC to access the owner cluster if required.
     159// As it must destroy all process copies, and all othert threads in all clusters,
     160// the process_make_exec() function must be executed in the owner cluster.
    162161//
    163162// TODO : the args & envs arguments are not supported yet : both must be NULL  [AG]
     
    187186    "args not supported yet\n" );
    188187
    189     // get owner cluster
    190 
    191188    // check pathname length
    192189    if( hal_strlen_from_uspace( pathname ) >= CONFIG_VFS_MAX_PATH_LENGTH )
     
    205202#if DEBUG_SYS_EXEC
    206203uint64_t      tm_start;
    207 uint64_t      tm_end;
    208204tm_start = hal_get_cycles();
    209205if( DEBUG_SYS_EXEC < tm_start )
    210206printk("\n[DBG] %s : thread %x in process %x enter for path <%s> / cycle = %d\n",
    211 __FUNCTION__, this, pid, exec_info.path, (uint32_t)tm_start );
     207__FUNCTION__, this->trdid, pid, exec_info.path, (uint32_t)tm_start );
    212208#endif
    213209
     
    220216#if DEBUG_SYSCALLS_ERROR
    221217printk("\n[ERROR] in %s : thread %x in process %x cannot access args\n",
    222 __FUNCTION__ , this, pid );
     218__FUNCTION__ , this->trdid, pid );
    223219#endif
    224220            this->errno = EINVAL;
     
    235231#if DEBUG_SYCALLS_ERROR
    236232printk("\n[ERROR] in %s : thread %x in process %x cannot access envs\n",
    237 __FUNCTION__ , this, pid );
     233__FUNCTION__ , this->trdid, pid );
    238234#endif
    239235            this->errno = EINVAL;
     
    250246#if DEBUG_SYSCALLS_ERROR
    251247printk("\n[ERROR] in %s : thread %x in process %x cannot create process for <%s>\n",
    252 __FUNCTION__, this, pid, exec_info.path );
     248__FUNCTION__, this->trdid, pid, exec_info.path );
    253249#endif
    254250        this->errno = error;
     
    256252    }
    257253
    258 #if DEBUG_SYS_EXEC
    259 tm_end = hal_get_cycles();
    260 if( DEBUG_SYS_EXEC < tm_end )
    261 printk("\n[DBG] %s : thread %x in process %x exit / cost = %d / cycle %d\n",
    262 __FUNCTION__, this, pid, (uint32_t)(tm_end - tm_start), (uint32_t)tm_end );
    263 #endif
    264 
    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.
    269     sched_yield( "old process suicide in sys_exec()" );
     254    assert( false , __FUNCTION__, "we should not execute this code" );
    270255
    271256    return 0; 
Note: See TracChangeset for help on using the changeset viewer.