source: trunk/kernel/syscalls/sys_place_fork.c @ 687

Last change on this file since 687 was 683, checked in by alain, 4 years ago

All modifications required to support the <tcp_chat> application
including error recovery in case of packet loss.A

File size: 2.5 KB
RevLine 
[584]1/*
2 * sys_get_core.c - get calling core cluster and local index.
3 *
[623]4 * Author    Alain Greiner (2016,2017,2018,2019)
[584]5 * 
6 * Copyright (c) UPMC Sorbonne Universites
7 *
8 * This file is part of ALMOS-MKH.
9 *
10 * ALMOS-MKH is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2.0 of the License.
13 *
14 * ALMOS-MKH is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#include <hal_kernel_types.h>
25#include <hal_uspace.h>
26#include <hal_special.h>
27#include <errno.h>
28#include <core.h>
29#include <thread.h>
30#include <process.h>
31#include <vmm.h>
32#include <printk.h>
33
34#include <syscalls.h>
35
36///////////////////////////////////
37int sys_place_fork( uint32_t  cxy )
38{
39    thread_t  * this    = CURRENT_THREAD;
40
[670]41#if DEBUG_SYS_PLACE_FORK || DEBUG_SYSCALLS_ERROR || CONFIG_INSTRUMENTATION_SYSCALLS
42uint64_t    tm_start = hal_get_cycles();
43process_t * process  = this->process;
[637]44#endif
45
46#if DEBUG_SYS_PLACE_FORK
47if( DEBUG_SYS_PLACE_FORK < tm_start )
48printk("\n[%s] thread[%x,%x] enter / cxy %x / cycle %d\n",
49__FUNCTION__, process->pid, this->trdid, cxy, (uint32_t)tm_start );
50#endif
51
[584]52    // check cxy argument
[637]53    if( cluster_is_active( cxy ) == false )
[584]54    {
55       
56#if DEBUG_SYSCALLS_ERROR
[683]57if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start )
[584]58printk("\n[ERROR] in %s : thread[%x,‰x] / illegal cxy argument %x\n",
59__FUNCTION__ , process->pid , this->trdid , cxy );
60#endif
61        this->errno = EFAULT;
62                return -1;
63        }
64
65    // set relevant arguments in calling thread descriptor
66    this->fork_user = true;
67    this->fork_cxy  = cxy;
68
[637]69#if (DEBUG_SYS_PLACE_FORK || CONFIG_INSTRUMENTATION_SYSCALLS)
70uint64_t     tm_end = hal_get_cycles();
71#endif
72
73#if DEBUG_SYS_PLACE_FORK
74if( DEBUG_SYS_PLACE_FORK < tm_end )
75printk("\n[%s] thread[%x,%x] exit / cycle %d\n",
76__FUNCTION__ , process->pid, this->trdid, (uint32_t)tm_end );
77#endif
78
79#if CONFIG_INSTRUMENTATION_SYSCALLS
80hal_atomic_add( &syscalls_cumul_cost[SYS_PLACE_FORK] , tm_end - tm_start );
81hal_atomic_add( &syscalls_occurences[SYS_PLACE_FORK] , 1 );
82#endif
83
[584]84        return 0; 
85
86}  // end sys_place_fork()
Note: See TracBrowser for help on using the repository browser.