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_write.c

    r492 r566  
    11/*
    2  * sys_write.c - write bytes to a file
     2 * sys_write.c - Kernel function implementing the "write" system call.
    33 *
    44 * Author        Alain Greiner (2016,2017,2018)
     
    2929#include <errno.h>
    3030#include <vfs.h>
     31#include <vmm.h>
    3132#include <thread.h>
    3233#include <printk.h>
    3334#include <process.h>
    3435
    35 /* TODO: concurrent user page(s) unmap need to be handled [AG] */
    3636
    3737extern uint32_t enter_sys_write;
     
    6464        process_t  * process = this->process;
    6565
     66#if (DEBUG_SYS_WRITE || CONFIG_INSTRUMENTATION_SYSCALLS)
     67uint64_t     tm_start = hal_get_cycles();
     68#endif
     69
    6670#if DEBUG_SYS_WRITE
    67 uint32_t     tm_start;
    68 uint32_t     tm_end;
    6971tm_start = hal_get_cycles();
    7072if( DEBUG_SYS_WRITE < tm_start )
     
    123125 
    124126    // get file type
    125     vfs_inode_type_t type = hal_remote_lw( XPTR( file_cxy , &file_ptr->type ) );
     127    vfs_inode_type_t type = hal_remote_l32( XPTR( file_cxy , &file_ptr->type ) );
    126128
    127129    // enable IRQs
     
    132134    {
    133135        // check file writable
    134         uint32_t attr = hal_remote_lw( XPTR( file_cxy , &file_ptr->attr ) );
     136        uint32_t attr = hal_remote_l32( XPTR( file_cxy , &file_ptr->attr ) );
    135137        if( (attr & FD_ATTR_WRITE_ENABLE) == 0 )
    136138            {
     
    192194    hal_fence();
    193195
     196#if (DEBUG_SYS_WRITE || CONFIG_INSTRUMENTATION_SYSCALLS)
     197uint64_t     tm_end = hal_get_cycles();
     198#endif
     199
    194200#if DEBUG_SYS_WRITE
    195 tm_end = hal_get_cycles();
    196201if( DEBUG_SYS_WRITE < tm_end )
    197 printk("\n[DBG] %s : thread %x in process %x exit / cycle %d / cost %d\n",
    198 __FUNCTION__, this->trdid, process->pid, (uint32_t)tm_start, (uint32_t)(tm_end - tm_start) );
    199 #endif
    200  
     202printk("\n[DBG] %s : thread %x in process %x exit / cycle %d\n",
     203__FUNCTION__, this->trdid, process->pid, (uint32_t)tm_end );
     204#endif
     205 
     206#if CONFIG_INSTRUMENTATION_SYSCALLS
     207hal_atomic_add( &syscalls_cumul_cost[SYS_WRITE] , tm_end - tm_start );
     208hal_atomic_add( &syscalls_occurences[SYS_WRITE] , 1 );
     209#endif
     210
    201211#if (DEBUG_SYS_WRITE & 1)
    202212exit_sys_write = (uint32_t)tm_end;
Note: See TracChangeset for help on using the changeset viewer.