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_fork.c

    r594 r625  
    22 * sys_fork.c - Kernel function implementing the "fork" system call.
    33 *
    4  * Authors  Alain Greiner  (2016,2017)
     4 * Authors  Alain Greiner  (2016,2017,2018,2019)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    7373#if DEBUG_SYS_FORK
    7474if( DEBUG_SYS_FORK < tm_start )
    75 printk("\n[DBG] %s : thread[%x,%x] enter / cycle =  %d\n",
     75printk("\n[%s] thread[%x,%x] enter / cycle =  %d\n",
    7676__FUNCTION__, parent_pid, parent_thread_ptr->trdid, (uint32_t)tm_start );
    7777#endif
     
    151151
    152152    // set remote child CPU context from parent_thread register values
     153    // replicates the parent thread kernel stack to the child thread descriptor,
     154    // and finally unblock the child thread.
    153155    hal_cpu_context_fork( XPTR( child_cxy , child_thread_ptr ) );
    154156
    155157    // From this point, both parent and child threads execute the following code,
    156     // but they can be distinguished by the (CURRENT_THREAD,local_cxy) values.
    157     // - parent unblock child, and return child PID to user application.
    158     // - child thread does nothing, and return 0 to user pplication
    159     // The child thread will only execute it when it is unblocked by parent thread.
     158    // but child thread will only execute it after being unblocked by parent thread.
     159    // They can be distinguished by the (CURRENT_THREAD,local_cxy) values.
     160    // - parent return child PID to user application.
     161    // - child  return 0 to user application
    160162
    161163    thread_t * current = CURRENT_THREAD;
     
    165167#endif
    166168
     169    if( (current == parent_thread_ptr) && (local_cxy == parent_cxy) )   // parent thread
     170    {
     171
    167172#if DEBUG_SYS_FORK
    168173if( DEBUG_SYS_FORK < tm_end )
    169 printk("\n[%s] thread[%x,%x] exit / cycle %d\n",
    170 __FUNCTION__, current->process->pid, current->trdid, (uint32_t)tm_end );
     174printk("\n[%s] parent thread[%x,%x] exit / child_pid %x / cycle %d\n",
     175__FUNCTION__, current->process->pid, current->trdid, child_pid, (uint32_t)tm_end );
    171176#endif
    172177
    173     if( (current == parent_thread_ptr) && (local_cxy == parent_cxy) )   // parent thread
    174     {
    175         // parent_thread unblock child_thread
    176         thread_unblock( XPTR( child_cxy , child_thread_ptr ) , THREAD_BLOCKED_GLOBAL );
    177 
    178         // only parent contribute to instrumentation
    179 
     178// only parent contribute to instrumentation
    180179#if CONFIG_INSTRUMENTATION_SYSCALLS
    181180hal_atomic_add( &syscalls_cumul_cost[SYS_FORK] , tm_end - tm_start );
     
    186185        else                                                               // child_thread
    187186    {
     187
     188#if DEBUG_SYS_FORK
     189if( DEBUG_SYS_FORK < tm_end )
     190printk("\n[%s] child thread[%x,%x] exit / child_pid %x / cycle %d\n",
     191__FUNCTION__, current->process->pid, current->trdid, child_pid, (uint32_t)tm_end );
     192#endif
     193
    188194        return 0;
    189195    }
Note: See TracChangeset for help on using the changeset viewer.