Ignore:
Timestamp:
May 16, 2018, 4:15:22 PM (6 years ago)
Author:
alain
Message:

Fix few bugs whike debugging the sort multi-thread application.

File:
1 edited

Legend:

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

    r440 r443  
    3030#include <process.h>
    3131#include <string.h>
    32 
     32#include <shared_syscalls.h>
     33
     34/////////////////////////////////////////////////////////////////////////////////
     35// This static function returns a printable string for the type of display.
     36/////////////////////////////////////////////////////////////////////////////////
     37
     38#if DEBUG_SYS_DISPLAY
     39static char* display_type_str( uint32_t type )
     40{
     41    if     ( type == DISPLAY_STRING            ) return "STRING";
     42    else if( type == DISPLAY_VMM               ) return "VMM";
     43    else if( type == DISPLAY_SCHED             ) return "SCHED";
     44    else if( type == DISPLAY_CLUSTER_PROCESSES ) return "CLUSTER_PROCESSES";
     45    else if( type == DISPLAY_VFS               ) return "VFS";
     46    else if( type == DISPLAY_CHDEV             ) return "CHDEV";
     47    else if( type == DISPLAY_TXT_PROCESSES     ) return "TXT_PROCESSES";
     48}
     49#endif
    3350
    3451/////////////////////////////
     
    4966tm_start = hal_get_cycles();
    5067if( DEBUG_SYS_DISPLAY < tm_start )
    51 printk("\n[DBG] %s : thread %d enter / process %x / type  %d / cycle = %d\n",
    52 __FUNCTION__, this, this->process->pid, type, (uint32_t)tm_start );
     68printk("\n[DBG] %s : thread %d enter / process %x / type  %s / cycle = %d\n",
     69__FUNCTION__, this, this->process->pid, display_type_str(type), (uint32_t)tm_start );
    5370#endif
    5471
     
    98115    else if( type == DISPLAY_VMM )
    99116    {
    100         pid_t pid = (pid_t)arg0;
    101 
    102         // get extended pointer on reference process
    103         xptr_t process_xp = cluster_get_reference_process_from_pid( pid );
     117        cxy_t cxy = (cxy_t)arg0;
     118        pid_t pid = (pid_t)arg1;
     119
     120        // check cxy argument
     121            if( cluster_is_undefined( cxy ) )
     122        {
     123
     124#if DEBUG_SYSCALLS_ERROR
     125printk("\n[ERROR] in %s : illegal cxy argument %x / thread %x / process %x\n",
     126__FUNCTION__ , cxy , this->trdid , process->pid );
     127#endif
     128            this->errno = EINVAL;
     129            return -1;
     130        }
     131
     132        // get extended pointer on process PID in cluster CXY
     133        xptr_t process_xp = cluster_get_process_from_pid_in_cxy( cxy , pid );
    104134
    105135            if( process_xp == XPTR_NULL )
     
    107137
    108138#if DEBUG_SYSCALLS_ERROR
    109 printk("\n[ERROR] in %s : undefined pid argument %d / thread %x / process %x\n",
    110 __FUNCTION__ , pid , this->trdid , process->pid );
    111 #endif
    112             this->errno = EINVAL;
    113             return -1;
    114         }
    115 
    116         // get cluster and local pointer on process
    117         cxy_t       process_cxy = GET_CXY( process_xp );
    118         process_t * process_ptr = (process_t *)GET_PTR( process_xp );
     139printk("\n[ERROR] in %s : process %x in cluster %x not found / thread %x / process %x\n",
     140__FUNCTION__ , pid , cxy , this->trdid , process->pid );
     141#endif
     142            this->errno = EINVAL;
     143            return -1;
     144        }
     145
     146        // get local pointer on process
     147        process_t * process = (process_t *)GET_PTR( process_xp );
    119148
    120149        // call kernel function
    121         if( process_cxy == local_cxy )
    122         {
    123                 vmm_display( process_ptr , true );
     150        if( cxy == local_cxy )
     151        {
     152                vmm_display( process , true );
    124153        }
    125154        else
    126155        {
    127             rpc_vmm_display_client( process_cxy , process_ptr , true );
     156            rpc_vmm_display_client( cxy , process , true );
    128157        }
    129158    }
Note: See TracChangeset for help on using the changeset viewer.