Ignore:
Timestamp:
Apr 10, 2019, 10:09:39 AM (5 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/kernel/syscalls/sys_exit.c

    r619 r625  
    22 * sys_exit.c - Kernel function implementing the "exit" system call.
    33 *
    4  * Author    Alain Greiner (2016,2017,2018)
     4 * Author    Alain Greiner (2016,2017,2018,2019)
    55 *
    66 * Copyright (c)  UPMC Sorbonne Universites
     
    5353    pid_t       pid     = process->pid;
    5454
     55#if (DEBUG_SYS_EXIT || CONFIG_INSTRUMENTATION_SYSCALLS)
     56uint64_t     tm_start = hal_get_cycles();
     57#endif
     58
    5559#if DEBUG_SYS_EXIT
    56 uint64_t    tm_start;
    57 uint64_t    tm_end;
    58 tm_start = hal_get_cycles();
    5960if( DEBUG_SYS_EXIT < tm_start )
    6061printk("\n[%s] thread[%x,%x] enter / status %x / cycle %d\n",
    61 __FUNCTION__, process->pid, this->trdid , status , (uint32_t)tm_start );
     62__FUNCTION__, pid, this->trdid , status , (uint32_t)tm_start );
    6263#endif
    6364
     
    6667    owner_cxy = GET_CXY( owner_xp );
    6768    owner_ptr = GET_PTR( owner_xp );
    68 
    69 #if (DEBUG_SYS_EXIT & 1)
    70 if( DEBUG_SYS_EXIT < tm_start )
    71 printk("\n[%s] thread[%x,%x] get owner process in cluster %x\n",
    72 __FUNCTION__, process->pid, this->trdid, owner_cxy );
    73 #endif
    7469
    7570    // get local pointer on the main thread
     
    8075    parent_cxy = GET_CXY( parent_xp );
    8176    parent_ptr = GET_PTR( parent_xp );
    82 
    83 #if (DEBUG_SYS_EXIT & 1)
    84 if( DEBUG_SYS_EXIT < tm_start )
    85 printk("\n[%s] thread[%x,%x] get parent process in cluster %x\n",
    86 __FUNCTION__, process->pid, this->trdid, parent_cxy );
    87 #endif
    8877
    8978    // get pointers on the parent process main thread
     
    9685#if( DEBUG_SYS_EXIT & 1)
    9786if( DEBUG_SYS_EXIT < tm_start )
    98 printk("\n[%s] thread[%x,%x] detached process from TXT\n",
    99 __FUNCTION__, process->pid, this->trdid );
     87printk("\n[%s] thread[%x,%x] detached process %x from TXT\n",
     88__FUNCTION__, pid, this->trdid, pid );
    10089#endif
    10190
    10291    // mark for delete all process threads in all clusters,
    10392    // but the main thread and this calling thread
    104     process_sigaction( process->pid , DELETE_ALL_THREADS );
     93    process_sigaction( pid , DELETE_ALL_THREADS );
    10594
    10695#if( DEBUG_SYS_EXIT & 1)
    10796if( DEBUG_SYS_EXIT < tm_start )
    108 printk("\n[%s] thread[%x,%x] deleted all threads but itself\n",
    109 __FUNCTION__, process->pid, this->trdid );
     97printk("\n[%s] thread[%x,%x] deleted all threads in process %x (but itself)\n",
     98__FUNCTION__, pid, this->trdid, pid );
    11099#endif
    111100
     
    116105#if( DEBUG_SYS_EXIT & 1)
    117106if( tm_start > DEBUG_SYS_EXIT )
    118 printk("\n[%u] thread[%x,%x] marked iself for delete\n",
    119 __FUNCTION__, process->pid, this->trdid );
     107printk("\n[%s] thread[%x,%x] marked iself for delete\n",
     108__FUNCTION__, pid, this->trdid );
    120109#endif
    121110        thread_delete( XPTR( local_cxy , this ) , pid , true );
    122111    }
    123112
    124     // block this main thread
     113    // block the main thread
    125114    thread_block( XPTR( owner_cxy , main_ptr ) , THREAD_BLOCKED_GLOBAL );
    126115
    127116#if( DEBUG_SYS_EXIT & 1)
     117trdid_t main_trdid = hal_remote_l32( XPTR( owner_cxy , &main_ptr->trdid ) );
    128118if( tm_start > DEBUG_SYS_EXIT )
    129 printk("\n[%s] thread[%x,%x] blocked main thread\n",
    130 __FUNCTION__, process->pid, this->trdid );
     119printk("\n[%s] thread[%x,%x] blocked main thread[%x,%x]\n",
     120__FUNCTION__, pid, this->trdid, pid, main_trdid );
    131121#endif
    132122
    133     // atomically update owner process descriptor term_state to ask
    134     // the parent process sys_wait() function to delete the main thread
     123    // update term_state in owner process descriptor to ask
     124    // the parent process sys_wait() function to delete the process
    135125    term_state = (status & 0xFF) | PROCESS_TERM_EXIT;
    136126    hal_remote_atomic_or( XPTR( owner_cxy , &owner_ptr->term_state ) , term_state );
     
    139129if( tm_start > DEBUG_SYS_EXIT )
    140130printk("\n[%s] thread[%x,%x] set exit status %x in owner process\n",
    141 __FUNCTION__, process->pid, this->trdid, term_state );
     131__FUNCTION__, pid, this->trdid, term_state );
    142132#endif
    143133
     
    148138if( tm_start > DEBUG_SYS_EXIT )
    149139printk("\n[%s] thread[%x,%x] unblocked parent main thread in process %x\n",
    150 __FUNCTION__ , process->pid, this->trdid,
     140__FUNCTION__ , pid, this->trdid,
    151141hal_remote_l32( XPTR( parent_cxy , &parent_ptr->pid) ) );
    152142#endif
     
    154144    hal_fence();
    155145
     146#if (DEBUG_SYS_EXIT || CONFIG_INSTRUMENTATION_SYSCALLS)
     147uint64_t     tm_end = hal_get_cycles();
     148#endif
     149
    156150#if DEBUG_SYS_EXIT
    157 tm_end = hal_get_cycles();
    158151if( DEBUG_SYS_EXIT < tm_end )
    159 printk("\n[%s] thread[%x,%x] exit / status %x / cost = %d / cycle %d\n",
    160 __FUNCTION__, process->pid, this->trdid, status,
    161 (uint32_t)(tm_end - tm_start), (uint32_t)tm_end );
     152printk("\n[%s] thread[%x,%x] exit / term_state %x / cycle %d\n",
     153__FUNCTION__, pid, this->trdid, term_state,  (uint32_t)tm_end );
     154#endif
     155
     156#if CONFIG_INSTRUMENTATION_SYSCALLS
     157hal_atomic_add( &syscalls_cumul_cost[SYS_EXIT] , tm_end - tm_start );
     158hal_atomic_add( &syscalls_occurences[SYS_EXIT] , 1 );
    162159#endif
    163160
Note: See TracChangeset for help on using the changeset viewer.