Ignore:
Timestamp:
Oct 4, 2018, 11:50:21 PM (6 years ago)
Author:
alain
Message:

Complete restructuration of kernel locks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/syscalls/sys_getpid.c

    r506 r566  
    11/*
    2  * kern/sys_getpid.c - get process id
     2 * kern/sys_getpid.c - Kernel function implementing the "get_pid" system call.
    33 *
    4  * Author     Alain Greiner  (2016,2017)
     4 * Author     Alain Greiner  (2016,2017, 2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    2323
    2424#include <thread.h>
    25 
     25#include <process.h>
    2626#include <syscalls.h>
    2727
    28 ////////////////
     28//////////////////////
    2929int sys_getpid( void )
    3030{
    31         return CURRENT_THREAD->process->pid;
    32 }
     31    thread_t  * this    = CURRENT_THREAD;
     32    process_t * process = this->process;
     33
     34#if (DEBUG_SYS_GETPID || CONFIG_INSTRUMENTATION_SYSCALLS)
     35uint64_t     tm_start = hal_get_cycles();
     36#endif
     37
     38#if DEBUG_SYS_GETPID
     39tm_start = hal_get_cycles();
     40if( DEBUG_SYS_FG < tm_start )
     41printk("\n[DBG] %s : thread %x in process %x enter / cycle %d\n",
     42__FUNCTION__ , this->trdid , process->pid, (uint32_t)tm_start );
     43#endif
     44
     45    // get pid value from local process descriptor   
     46    pid_t pid = process->pid;
     47
     48#if (DEBUG_SYS_GETPID || CONFIG_INSTRUMENTATION_SYSCALLS)
     49uint64_t     tm_end = hal_get_cycles();
     50#endif
     51
     52#if DEBUG_SYS_GETPID
     53tm_end = hal_get_cycles();
     54if( DEBUG_SYS_GETPID < tm_end )
     55printk("\n[DBG] %s : thread %x in process %x exit / cycle %d\n",
     56__FUNCTION__, this->trdid, process->pid, (uint32_t)tm_end );
     57#endif
     58
     59#if CONFIG_INSTRUMENTATION_SYSCALLS
     60hal_atomic_add( &syscalls_cumul_cost[SYS_GETPID] , tm_end - tm_start );
     61hal_atomic_add( &syscalls_occurences[SYS_GETPID] , 1 );
     62#endif
     63
     64        return pid;
     65
     66}  // end sys_getpid()
Note: See TracChangeset for help on using the changeset viewer.