Ignore:
Timestamp:
Apr 10, 2019, 10:09:39 AM (2 years ago)
Author:
alain
Message:

Fix a bug in the vmm_remove_vseg() function: the physical pages
associated to an user DATA vseg were released to the kernel when
the target process descriptor was in the reference cluster.
This physical pages release should be done only when the page
forks counter value is zero.
All other modifications are cosmetic.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/tsar_mips32/drivers/soclib_tty.c

    r619 r625  
    346346                owner_pid = hal_remote_l32( XPTR( owner_cxy , &owner_ptr->pid ) );
    347347
    348                 // block TXT owner process only if it is not the INIT process
    349                 if( owner_pid != 1 )
    350                 {
    351                     // get parent process descriptor pointers
    352                     parent_xp  = hal_remote_l64( XPTR( owner_cxy , &owner_ptr->parent_xp ) );
    353                     parent_cxy = GET_CXY( parent_xp );
    354                     parent_ptr = GET_PTR( parent_xp );
    355 
    356                     // get pointers on the parent process main thread
    357                     parent_main_ptr = hal_remote_lpt(XPTR(parent_cxy,&parent_ptr->th_tbl[0]));
    358                     parent_main_xp  = XPTR( parent_cxy , parent_main_ptr );
    359 
    360                     // transfer TXT ownership
    361                     process_txt_transfer_ownership( owner_xp );
    362 
    363                     // block all threads in all clusters, but the main thread
    364                     process_sigaction( owner_pid , BLOCK_ALL_THREADS );
    365 
    366                     // block the main thread
    367                     xptr_t main_xp = XPTR( owner_cxy , &owner_ptr->th_tbl[0] );
    368                     thread_block( main_xp , THREAD_BLOCKED_GLOBAL );
    369 
    370                     // atomically update owner process termination state
    371                     hal_remote_atomic_or( XPTR( owner_cxy , &owner_ptr->term_state ) ,
    372                                           PROCESS_TERM_STOP );
    373 
    374                     // unblock the parent process main thread
    375                     thread_unblock( parent_main_xp , THREAD_BLOCKED_WAIT );
    376 
    377                     return;
    378                 }
     348// TXT owner cannot be the INIT process
     349assert( (owner_pid != 1) , "INIT process cannot be the TXT owner" );
     350
     351                // get parent process descriptor pointers
     352                parent_xp  = hal_remote_l64( XPTR( owner_cxy , &owner_ptr->parent_xp ) );
     353                parent_cxy = GET_CXY( parent_xp );
     354                parent_ptr = GET_PTR( parent_xp );
     355
     356                // get pointers on the parent process main thread
     357                parent_main_ptr = hal_remote_lpt(XPTR(parent_cxy,&parent_ptr->th_tbl[0]));
     358                parent_main_xp  = XPTR( parent_cxy , parent_main_ptr );
     359
     360                // transfer TXT ownership
     361                process_txt_transfer_ownership( owner_xp );
     362
     363                // mark for block all threads in all clusters, but the main
     364                process_sigaction( owner_pid , BLOCK_ALL_THREADS );
     365
     366                // block the main thread
     367                xptr_t main_xp = XPTR( owner_cxy , &owner_ptr->th_tbl[0] );
     368                thread_block( main_xp , THREAD_BLOCKED_GLOBAL );
     369
     370                // atomically update owner process termination state
     371                hal_remote_atomic_or( XPTR( owner_cxy , &owner_ptr->term_state ) ,
     372                                      PROCESS_TERM_STOP );
     373
     374                // unblock the parent process main thread
     375                thread_unblock( parent_main_xp , THREAD_BLOCKED_WAIT );
     376
     377                return;
    379378            }
    380379
     
    390389                owner_xp  = process_txt_get_owner( channel );
    391390
    392                 // check process exist
    393                 assert( (owner_xp != XPTR_NULL) ,
    394                 "TXT owner process not found\n" );
     391// check process exist
     392assert( (owner_xp != XPTR_NULL) , "TXT owner process not found\n" );
    395393
    396394                // get relevant infos on TXT owner process
     
    399397                owner_pid = hal_remote_l32( XPTR( owner_cxy , &owner_ptr->pid ) );
    400398
    401                 // kill TXT owner process only if it is not the INIT process
    402                 if( owner_pid != 1 )
    403                 {
    404                     // get parent process descriptor pointers
    405                     parent_xp  = hal_remote_l64( XPTR( owner_cxy , &owner_ptr->parent_xp ) );
    406                     parent_cxy = GET_CXY( parent_xp );
    407                     parent_ptr = GET_PTR( parent_xp );
    408 
    409                     // get pointers on the parent process main thread
    410                     parent_main_ptr = hal_remote_lpt(XPTR(parent_cxy,&parent_ptr->th_tbl[0]));
    411                     parent_main_xp  = XPTR( parent_cxy , parent_main_ptr );
    412 
    413                     // remove process from TXT list
    414                     process_txt_detach( owner_xp );
    415 
    416                     // mark for delete all thread in all clusters, but the main
    417                     process_sigaction( owner_pid , DELETE_ALL_THREADS );
     399// TXT owner cannot be the INIT process
     400assert( (owner_pid != 1) , "INIT process cannot be the TXT owner" );
     401
     402#if DEBUG_HAL_TXT_RX
     403if( DEBUG_HAL_TXT_RX < rx_cycle )
     404printk("\n[%s] TXT%d owner is process %x\n",
     405__FUNCTION__, channel, owner_pid );
     406#endif
     407                // get parent process descriptor pointers
     408                parent_xp  = hal_remote_l64( XPTR( owner_cxy , &owner_ptr->parent_xp ) );
     409                parent_cxy = GET_CXY( parent_xp );
     410                parent_ptr = GET_PTR( parent_xp );
     411
     412                // get pointers on the parent process main thread
     413                parent_main_ptr = hal_remote_lpt(XPTR(parent_cxy,&parent_ptr->th_tbl[0]));
     414                parent_main_xp  = XPTR( parent_cxy , parent_main_ptr );
     415
     416                // transfer TXT ownership
     417                process_txt_transfer_ownership( owner_xp );
     418
     419                // remove process from TXT list
     420                // process_txt_detach( owner_xp );
     421
     422                // mark for delete all thread in all clusters, but the main
     423                process_sigaction( owner_pid , DELETE_ALL_THREADS );
    418424               
    419                     // block main thread
    420                     xptr_t main_xp = XPTR( owner_cxy , &owner_ptr->th_tbl[0] );
    421                     thread_block( main_xp , THREAD_BLOCKED_GLOBAL );
    422 
    423                     // atomically update owner process termination state
    424                     hal_remote_atomic_or( XPTR( owner_cxy , &owner_ptr->term_state ) ,
    425                                           PROCESS_TERM_KILL );
    426 
    427                     // unblock the parent process main thread
    428                     thread_unblock( parent_main_xp , THREAD_BLOCKED_WAIT );
    429 
    430                     return;
    431                 }
     425#if DEBUG_HAL_TXT_RX
     426if( DEBUG_HAL_TXT_RX < rx_cycle )
     427printk("\n[%s] marked for delete all threads of process but main\n",
     428__FUNCTION__, owner_pid );
     429#endif
     430                // block main thread
     431                xptr_t main_xp = XPTR( owner_cxy , &owner_ptr->th_tbl[0] );
     432                thread_block( main_xp , THREAD_BLOCKED_GLOBAL );
     433
     434#if DEBUG_HAL_TXT_RX
     435if( DEBUG_HAL_TXT_RX < rx_cycle )
     436printk("\n[%s] blocked process %x main thread\n",
     437__FUNCTION__, owner_pid );
     438#endif
     439
     440                // atomically update owner process termination state
     441                hal_remote_atomic_or( XPTR( owner_cxy , &owner_ptr->term_state ) ,
     442                                      PROCESS_TERM_KILL );
     443
     444                // unblock the parent process main thread
     445                thread_unblock( parent_main_xp , THREAD_BLOCKED_WAIT );
     446
     447#if DEBUG_HAL_TXT_RX
     448if( DEBUG_HAL_TXT_RX < rx_cycle )
     449printk("\n[%s] unblocked parent process %x main thread\n",
     450__FUNCTION__, hal_remote_l32( XPTR( parent_cxy , &parent_ptr->pid) ) );
     451#endif
     452                return;
    432453            }
    433454
Note: See TracChangeset for help on using the changeset viewer.