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

Last change on this file since 669 was 637, checked in by alain, 5 years ago

Introduce the non-standard pthread_parallel_create() system call
and re-write the <fft> and <sort> applications to improve the
intrinsic paralelism in applications.

File size: 2.4 KB
Line 
1/*
2 * sys_get_core.c - get calling core cluster and local index.
3 *
4 * Author    Alain Greiner (2016,2017,2018,2019)
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    process_t * process = this->process;
41
42#if (DEBUG_SYS_PLACE_FORK || CONFIG_INSTRUMENTATION_SYSCALLS)
43uint64_t     tm_start = hal_get_cycles();
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
52    // check cxy argument
53    if( cluster_is_active( cxy ) == false )
54    {
55       
56#if DEBUG_SYSCALLS_ERROR
57printk("\n[ERROR] in %s : thread[%x,‰x] / illegal cxy argument %x\n",
58__FUNCTION__ , process->pid , this->trdid , cxy );
59#endif
60        this->errno = EFAULT;
61                return -1;
62        }
63
64    // set relevant arguments in calling thread descriptor
65    this->fork_user = true;
66    this->fork_cxy  = cxy;
67
68#if (DEBUG_SYS_PLACE_FORK || CONFIG_INSTRUMENTATION_SYSCALLS)
69uint64_t     tm_end = hal_get_cycles();
70#endif
71
72#if DEBUG_SYS_PLACE_FORK
73if( DEBUG_SYS_PLACE_FORK < tm_end )
74printk("\n[%s] thread[%x,%x] exit / cycle %d\n",
75__FUNCTION__ , process->pid, this->trdid, (uint32_t)tm_end );
76#endif
77
78#if CONFIG_INSTRUMENTATION_SYSCALLS
79hal_atomic_add( &syscalls_cumul_cost[SYS_PLACE_FORK] , tm_end - tm_start );
80hal_atomic_add( &syscalls_occurences[SYS_PLACE_FORK] , 1 );
81#endif
82
83        return 0; 
84
85}  // end sys_place_fork()
Note: See TracBrowser for help on using the repository browser.