/* * sys_exit.c: Terminate the calling process. * * Author Alain Greiner (2016,2017) * * Copyright (c) UPMC Sorbonne Universites * * This file is part of ALMOS-MKH. * * ALMOS-MKH is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2.0 of the License. * * ALMOS-MKH is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ALMOS-MKH; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #include #include #include #include #include #include #include #include /////////////////////////////// int sys_exit( uint32_t status ) { uint32_t save_sr; // required to enable IRQs #if CONFIG_SYSCALL_DEBUG uint64_t tm_start; uint64_t tm_end; tm_start = hal_get_cycles(); #endif thread_t * this = CURRENT_THREAD; process_t * process = this->process; // get owner process cluster cxy_t owner_cxy = CXY_FROM_PID( process->pid ); // enable IRQs hal_enable_irq( &save_sr ); // execute process_make_exit() function in owner cluster if( local_cxy == owner_cxy ) // owner is local { process_make_exit( process , status ); } else // owner is remote { rpc_process_make_exit_client( owner_cxy, process , status ); } // restore IRQs hal_restore_irq( save_sr ); hal_fence(); #if CONFIG_SYSCALL_DEBUG tm_end = hal_get_cycles(); syscall_dmsg("\n[DBG] %s exit : core[%x,%d] / thread %x in process %x / cycle %d\n" "process %x killed / cost = %d\n", __FUNCTION__ , local_cxy , this->core->lid , this->trdid , this->process->pid , tm_start , pid , (uint32_t)(tm_end - tm_start) ); #endif return 0; } // end sys_exit()