Ignore:
Timestamp:
Jul 17, 2017, 8:42:59 AM (5 years ago)
Author:
alain
Message:

Bug fix in kernel_init
-This line, and those below, will be ignored--

M params.mk
M kernel_config.h
M Makefile
M hdd/virt_hdd.dmg
M tools/bootloader_tsar/boot.c
M kernel/libk/bits.h
M kernel/libk/elf.c
M kernel/libk/xhtab.c
M kernel/libk/elf.h
M kernel/libk/xhtab.h
M kernel/devices/dev_pic.c
M kernel/mm/vmm.c
M kernel/mm/mapper.c
M kernel/mm/mapper.h
M kernel/vfs/devfs.h
M kernel/vfs/vfs.c
M kernel/vfs/vfs.h
M kernel/vfs/devfs.c
M kernel/kern/chdev.h
M kernel/kern/kernel_init.c
M kernel/kern/process.c
M kernel/kern/process.h
M hal/tsar_mips32/core/hal_remote.c
M hal/tsar_mips32/drivers/soclib_pic.c

File:
1 edited

Legend:

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

    r188 r204  
    112112    }
    113113
     114    // initialize PID and PPID
     115        process->pid   = pid;
     116    process->ppid  = parent_pid;
     117
    114118    // reset reference process vmm (not for kernel process)
    115119    if( pid ) vmm_init( process );
     
    152156    spinlock_init( &process->th_lock );
    153157
    154     // initialize PID and PPID
    155         process->pid   = pid;
    156     process->ppid  = parent_pid;
    157 
    158158    // set ref_xp field
    159159    process->ref_xp = XPTR( local_cxy , process );
     
    171171    process_dmsg("\n[INFO] %s : exit for process %x in cluster %x\n",
    172172                 __FUNCTION__ , pid );
    173 }
     173
     174}  // process_reference init()
    174175
    175176/////////////////////////////////////////////////////
     
    230231
    231232    return 0;
    232 }
     233
     234} // end process_copy_init()
    233235
    234236///////////////////////////////////////////
     
    578580
    579581    return (found) ? 0 : ENOMEM;
    580 }
     582
     583}  // end process_register_thread()
     584
    581585///////////////////////////////////////////////
    582586void process_remove_thread( thread_t * thread )
     
    596600    process->th_tbl[ltid] = NULL;
    597601    process->th_nr--;
    598 }
     602
     603}  // process_remove_thread()
    599604
    600605/////////////////////////////////////////////////////
     
    623628    parent_pid = hal_remote_lw( XPTR( parent_cxy , &parent_ptr->pid ) );
    624629
    625     exec_dmsg("\n[INFO] %s enters in cluster %x for path = %s\n",
     630    exec_dmsg("\n[INFO] %s : enters in cluster %x for path = %s\n",
    626631                __FUNCTION__ , local_cxy , path );
    627632
     
    650655    process_reference_init( process , pid , parent_xp );
    651656
    652     exec_dmsg("\n[INFO] %s created process %x cluster %x / path = %s\n",
    653                 __FUNCTION__, parent_pid , local_cxy , path );
     657    exec_dmsg("\n[INFO] %s : created process %x in cluster %x / path = %s\n",
     658                __FUNCTION__, pid , local_cxy , path );
    654659
    655660    // initialize vfs_root and vfs_cwd from parent process
     
    663668
    664669    // initialize embedded fd_array from parent process
    665     process_fd_remote_copy( XPTR( local_cxy , &process->fd_array ),
     670    process_fd_remote_copy( XPTR( local_cxy  , &process->fd_array ),
    666671                            XPTR( parent_cxy , &parent_ptr->fd_array) );
     672
     673    exec_dmsg("\n[INFO] %s : fd_array copied from process %x to process %x\n",
     674                __FUNCTION__, parent_pid , pid );
    667675
    668676        // initialize signal manager TODO ??? [AG]
    669677        // signal_manager_init( process );
    670 
    671     // initialize process VMM
    672         vmm_init( process );
    673 
    674     exec_dmsg("\n[INFO] %s initialized VMM in cluster %x for process %x / path = %s\n",
    675                 __FUNCTION__ , local_cxy , pid , path );
    676678
    677679    // register "code" and "data" vsegs as well as the process entry-point in VMM,
     
    687689        }
    688690
    689     // register "heap" vseg descriptor in VMM
    690     vseg_t * heap_vseg = vmm_create_vseg( process,
    691                                           CONFIG_VMM_HEAP_BASE,
    692                                           CONFIG_VMM_HEAP_SIZE,
    693                                           VSEG_TYPE_HEAP );
    694     if( heap_vseg == NULL )
    695         {
    696                 printk("\n[ERROR] in %s : cannot create heap vseg for process %x / path = %s\n",
    697                        __FUNCTION__, pid , path );
    698         process_destroy( process );
    699         return error;
    700         }
     691    exec_dmsg("\n[INFO] %s : code and data vsegs from <%s> registered for process %x\n",
     692                __FUNCTION__ , path , pid );
    701693
    702694    // select a core in cluster
     
    718710        {
    719711                printk("\n[ERROR] in %s : cannot create thread for process %x / path = %s\n",
    720                        __FUNCTION__, pid , path );
     712                       __FUNCTION__, pid );
    721713        process_destroy( process );
    722714        return error;
    723715        }
     716
     717        exec_dmsg("\n[INFO] %s : thread created for process %x on core %d in cluster %x\n",
     718               __FUNCTION__ , pid , core->lid , local_cxy );
    724719
    725720    // update children list in parent process
     
    731726        sched_register_thread( core , thread );
    732727
    733         exec_dmsg("\n[INFO] %s created thread for process %x on core %d in cluster %x\n",
    734                __FUNCTION__ , pid , core->lid , local_cxy );
    735 
    736728    // activate new thread
    737729        thread_unblock( XPTR( local_cxy , thread ) , THREAD_BLOCKED_GLOBAL );
    738730
     731    exec_dmsg("\n[INFO] %s : exit for process %x\n",
     732                __FUNCTION__, process->pid );
     733
    739734        return 0;
    740 }
     735
     736}  // end proces_make_exec()
    741737
    742738//////////////////////////
     
    755751    uint32_t  stderr_id;
    756752
    757         process_dmsg("\n[INFO] %s enters in cluster %x\n", __FUNCTION__ , local_cxy );
     753        process_dmsg("\n[INFO] %s : enters in cluster %x\n", __FUNCTION__ , local_cxy );
    758754
    759755    // open stdin / stdout / stderr pseudo-files
     
    762758        error3 = vfs_open( XPTR_NULL, CONFIG_DEV_STDERR, O_WRONLY, 0, &stderr_xp, &stderr_id );
    763759
    764         if( error1 || error2 || error3 )
    765         {
    766                 if( !error1 ) vfs_close( stdin_xp  , stdin_id );
    767                 if( !error2 ) vfs_close( stdout_xp , stdout_id );
    768                 if( !error3 ) vfs_close( stderr_xp , stderr_id );
    769                 printk("\n[PANIC] in %s : cannot open stdin/stdout/stderr in cluster %x\n",
    770                __FUNCTION__ , local_cxy );
    771         hal_core_sleep();
    772         }
    773 
    774     // check stdin / stdout / stderr indexes
    775     if( (stdin_id != 0) || (stdout_id != 1) || (stderr_id != 2) )
    776     {
    777                 vfs_close( stdin_xp  , stdin_id );
    778                 vfs_close( stdout_xp , stdout_id );
    779                 vfs_close( stderr_xp , stderr_id );
    780                 printk("\n[PANIC] in %s : bad indexes for stdin/stdout/stderr in cluster %x\n",
    781             __FUNCTION__ , local_cxy );
    782         hal_core_sleep();
    783     }
     760        assert( ((error1 == 0) && (error2 == 0) && (error3 == 0)) , __FUNCTION__ ,
     761            "cannot open stdin/stdout/stderr pseudo files\n");
     762
     763    assert( ((stdin_id == 0) && (stdout_id == 1) && (stderr_id == 2)) , __FUNCTION__ ,
     764            "bad indexes for stdin/stdout/stderr\n");
    784765
    785766    // initialize the exec_info structure
     
    792773        error1 = process_make_exec( &exec_info );
    793774
    794         if( error1 )
    795         {
    796         printk("\n[PANIC] in %s : cannot create main thread in cluster %x\n",
    797                __FUNCTION__ , local_cxy );
    798                 hal_core_sleep();
    799     }
    800 
    801         process_dmsg("\n[INFO] %s successfully exit in cluster %x\n", __FUNCTION__ , local_cxy );
     775        assert( (error1 == 0) , __FUNCTION__ , "cannot create process_init\n");
     776
     777        process_dmsg("\n[INFO] %s : exit in cluster %x\n", __FUNCTION__ , local_cxy );
    802778               
    803779    hal_fence();
    804 }
    805 
     780
     781}  // end process_init_create()
     782
Note: See TracChangeset for help on using the changeset viewer.