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/kern/thread.h

    r619 r625  
    33 *
    44 * Author  Ghassan Almaless (2008,2009,2010,2011,2012)
    5  *         Alain Greiner (2016,2017,2018)
     5 *         Alain Greiner (2016,2017,2018,2019)
    66 *
    77 * Copyright (c) UPMC Sorbonne Universites
     
    2929#include <shared_syscalls.h>
    3030#include <hal_special.h>
     31#include <hal_kentry.h>
    3132#include <xlist.h>
    3233#include <list.h>
     
    100101{
    101102        uint32_t              pgfault_nr;    /*! cumulated number of page fault           */
    102         uint32_t              sched_nr;      /*! TODO ???  [AG]                           */
    103         uint32_t              u_err_nr;      /*! TODO ???  [AG]                           */
    104         uint32_t              m_err_nr;      /*! TODO ???  [AG]                           */
    105103        cycle_t               last_cycle;    /*! last cycle counter value (date)          */
    106104        cycle_t               usr_cycles;    /*! user execution duration (cycles)         */
     
    121119 *
    122120 * WARNING (1) Don't modify the first 4 fields order, as this order is used by the
    123  *             hal_kentry assembly code for some architectures (TSAR).
     121 *             hal_kentry assembly code for the TSAR architectures.
    124122 *
    125123 * WARNING (2) Most of the thread state is private and accessed only by this thread,
     
    165163    uint32_t          * ack_rsp_count;   /*! pointer on acknowledge response counter  */
    166164
    167         intptr_t            u_stack_base;    /*! user stack base address                  */
    168         uint32_t            u_stack_size;    /*! user stack size (bytes)                  */
     165        vseg_t            * user_stack_vseg; /*! local pointer on user stack vseg         */
    169166
    170167    void              * entry_func;      /*! pointer on entry function                */
     
    248245
    249246/***************************************************************************************
    250  * This function is used by the sys_fork() system call to create the "child" thread
    251  * in the local cluster. It allocates memory for a thread descriptor, and initializes
    252  * it from the "parent" thread descriptor defined by the <parent_thread_xp> argument.
     247 * This function is used by the sys_fork() syscall to create the "child" main thread
     248 * in the local cluster. It is called, generally through the RPC_PROCESS_MAKE_FORK,
     249 * by the process_make_fork() function. It allocates memory from the local cluster
     250 * for a "child" thread descriptor, and initializes it from the "parent" thread
     251 * descriptor defined by the <parent_thread_xp> argument.
    253252 * The new thread is attached to the core that has the lowest load in local cluster.
    254253 * It is registered in the "child" process defined by the <child_process> argument.
     
    259258 * uses physical addressing on some architectures).
    260259 * The CPU and FPU execution contexts are created and linked to the new thread.
    261  * but the actual context copy is NOT done, and must be done by by the sys_fork().
     260 * but the actual context copy is NOT done, and is done by the sys_fork() function.
    262261 * The THREAD_BLOCKED_GLOBAL bit is set => the thread must be activated to start.
    263262 ***************************************************************************************
     
    273272/***************************************************************************************
    274273 * This function is called by the process_make_exec() function to re-initialise the
    275  * thread descriptor of the calling thread (that will become the new process main
    276  * thread), and immediately jump to user code without returning to kentry!!!
     274 * calling thread descriptor, that will become the new process main thread.
    277275 * It must be called by the main thread of the calling process.
     276 * - The calling thread TRDID is not modified.
     277 * - The kernel stack (currently in use) is not modified. 
    278278 * - A new user stack vseg is created and initialised.
    279  * - The kernel stack (currently in use) is not modified. 
    280279 * - The function calls the hal_cpu_context_exec() to re-initialize the CPU context
    281  *   an jump to user code. 
     280 *   and the uzone registered in kernel stack, an jump to user code. 
    282281 ***************************************************************************************
    283282 * @ entry_func : main thread entry point.
     
    329328
    330329/***************************************************************************************
    331  * This low-level function is called by the sched_handle_signals() function to releases
    332  * the physical memory allocated for a thread in a given cluster, when this thread
    333  * is marked for delete. This include the thread descriptor itself, the associated
    334  * CPU and FPU context, and the physical memory allocated for an user thread local stack.
     330 * This low-level function is called by the sched_handle_signals() function when a
     331 * thread is marked for delete. It removes the thread identified by the <thread>
     332 * argument from the process th_tbl[], and releases all physical memory allocated for
     333 * this. This includes the thread descriptor itself, the associated CPU and FPU context,
     334 * and the physical memory allocated for an user thread stack.
    335335 ***************************************************************************************
    336336 * @ thread  : pointer on the thread descriptor to release.
    337  * @ return true, if the thread was the last registerd thread in local process.
    338  **************************************************************************************/
    339 void thread_destroy( thread_t * thread );
     337 * @ return the number of threads registered in the process th_tbl[] before deletion.
     338 **************************************************************************************/
     339uint32_t thread_destroy( thread_t * thread );
    340340
    341341/***************************************************************************************
     
    383383 * This function is used by the four sys_thread_cancel(), sys_thread_exit(),
    384384 * sys_kill() and sys_exit() system calls to mark for delete a given thread.
    385  * It set the THREAD_BLOCKED_GLOBAL bit and set the the THREAD_FLAG_REQ_DELETE bit
    386  * in the thread descriptor identified by the <thread_xp> argument, to ask the scheduler
     385 * It set the THREAD_BLOCKED_GLOBAL bit and set the THREAD_FLAG_REQ_DELETE bit in the
     386 * thread descriptor identified by the <thread_xp> argument, to ask the scheduler
    387387 * to asynchronously delete the target thread, at the next scheduling point.
    388  * The calling thread can run in any cluster, as it uses remote accesses, but
    389  * the target thread cannot be the main thread of the process identified by the <pid>
    390  * argument, because the main thread must be deleted by the parent process argument.
     388 * The calling thread can run in any cluster, as it uses remote accesses.
     389 * This function makes a kernel panic if the target thread is the main thread,
     390 * because * the main thread deletion will cause the process deletion, and a process
     391 * must be deleted by the parent process, running the wait function.
    391392 * If the target thread is running in "attached" mode, and the <is_forced> argument
    392393 * is false, this function implements the required sychronisation with the joining
Note: See TracChangeset for help on using the changeset viewer.