Ignore:
Timestamp:
Feb 20, 2018, 5:32:17 PM (6 years ago)
Author:
alain
Message:

Fix a bad bug in scheduler...

File:
1 edited

Legend:

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

    r407 r435  
    2525#include <hal_types.h>
    2626#include <hal_uspace.h>
     27#include <hal_irqmask.h>
    2728#include <shared_syscalls.h>
    2829#include <errno.h>
     
    4445    error_t       error;
    4546    paddr_t       paddr;        // unused, but required for user space checking
    46 
    47         uint64_t      tm_start;
    48         uint64_t      tm_end;
    49 
    50         tm_start = hal_get_cycles();
     47    reg_t         save_sr;      // required to enable IRQs
    5148
    5249        thread_t    * this    = CURRENT_THREAD;
    5350        process_t   * process = this->process;
    5451
     52#if CONFIG_DEBUG_SYS_MMAP
     53uint64_t      tm_start;
     54uint64_t      tm_end;
     55tm_start = hal_get_cycles();
     56if ( CONFIG_DEBUG_SYS_MMAP < tm_start )
     57printk("\n[DBG] %s : thread %x enter / process %x / cycle %d\n",
     58__FUNCTION__, this, process->pid, (uint32_t)tm_start );
     59#endif
     60
    5561    // check arguments in user space
    5662    error = vmm_v2p_translate( false , attr , &paddr );
     
    5864    if ( error )
    5965    {
    60         printk("\n[ERROR] in %s : arguments not in used space = %x\n",
    61         __FUNCTION__ , (intptr_t)attr );
     66
     67#if CONFIG_DEBUG_SYSCALLS_ERROR
     68printk("\n[ERROR] in %s : arguments not in used space = %x\n", __FUNCTION__ , (intptr_t)attr );
     69#endif
    6270                this->errno = EINVAL;
    6371                return -1;
     
    8290    if( map_fixed )
    8391    {
    84         printk("\n[ERROR] in %s : MAP_FIXED not supported\n", __FUNCTION__ );
     92
     93#if CONFIG_DEBUG_SYSCALLS_ERROR
     94printk("\n[ERROR] in %s : MAP_FIXED not supported\n", __FUNCTION__ );
     95#endif
    8596        this->errno = EINVAL;
    8697        return -1;
     
    89100    if( map_shared == map_private )
    90101    {
    91         printk("\n[ERROR] in %s : MAP_SHARED xor MAP_PRIVATE\n", __FUNCTION__ );
     102
     103#if CONFIG_DEBUG_SYSCALLS_ERROR
     104printk("\n[ERROR] in %s : MAP_SHARED xor MAP_PRIVATE\n", __FUNCTION__ );
     105#endif
    92106        this->errno = EINVAL;
    93107        return -1;
     
    108122                if( fdid >= CONFIG_PROCESS_FILE_MAX_NR )
    109123                {
    110                         printk("\n[ERROR] in %s: bad file descriptor = %d\n", __FUNCTION__ , fdid );
     124
     125#if CONFIG_DEBUG_SYSCALLS_ERROR
     126printk("\n[ERROR] in %s: bad file descriptor = %d\n", __FUNCTION__ , fdid );
     127#endif
    111128            this->errno = EBADFD;
    112129            return -1;
     
    118135        if( file_xp == XPTR_NULL )
    119136        {
    120                         printk("\n[ERROR] in %s: file %d not found\n", __FUNCTION__ , fdid );
     137
     138#if CONFIG_DEBUG_SYSCALLS_ERROR
     139printk("\n[ERROR] in %s: file %d not found\n", __FUNCTION__ , fdid );
     140#endif
    121141            this->errno = EBADFD;
    122142            return -1;
     
    138158                if( (offset + length) > size)
    139159                {
    140                         printk("\n[ERROR] in %s: offset (%d) + len (%d) >= file's size (%d)\n",
    141                         __FUNCTION__, k_attr.offset, k_attr.length, size );
     160
     161#if CONFIG_DEBUG_SYSCALLS_ERROR
     162printk("\n[ERROR] in %s: offset (%d) + len (%d) >= file's size (%d)\n",
     163__FUNCTION__, k_attr.offset, k_attr.length, size );
     164#endif
    142165            this->errno = ERANGE;
    143166            return -1;
     
    148171                    (prot_write && !(file_attr & FD_ATTR_WRITE_ENABLE)) )
    149172                {
    150                         printk("\n[ERROR] in %s: prot = %x / file_attr = %x)\n",
    151                         __FUNCTION__ , k_attr.prot , file_attr );
     173
     174#if CONFIG_DEBUG_SYSCALLS_ERROR
     175printk("\n[ERROR] in %s: prot = %x / file_attr = %x)\n",
     176__FUNCTION__ , k_attr.prot , file_attr );
     177#endif
    152178                        this->errno = EACCES;
    153179                        return -1;
     
    178204            if( cluster_is_undefined( vseg_cxy ) )
    179205            {
    180                 printk("\n[ERROR] in %s : illegal cxy for MAP_REMOTE\n", __FUNCTION__ );
     206
     207#if CONFIG_DEBUG_SYSCALLS_ERROR
     208printk("\n[ERROR] in %s : illegal cxy for MAP_REMOTE\n", __FUNCTION__ );
     209#endif
    181210                this->errno = EINVAL;
    182211                return -1;
     
    184213        }
    185214    }
     215
     216    // enable IRQs
     217    hal_enable_irq( &save_sr );
    186218
    187219    // get reference process cluster and local pointer
     
    216248    }
    217249   
     250    // restore IRQs
     251    hal_restore_irq( save_sr );
     252
    218253    if( vseg == NULL )
    219254    {
    220         printk("\n[ERROR] in %s : cannot create vseg\n", __FUNCTION__ );
     255
     256#if CONFIG_DEBUG_SYSCALLS_ERROR
     257printk("\n[ERROR] in %s : cannot create vseg\n", __FUNCTION__ );
     258#endif
    221259        this->errno = ENOMEM;
    222260        return -1;
     
    226264    hal_copy_to_uspace( &attr->addr , &vseg->min , sizeof(intptr_t) );
    227265
    228     tm_end = hal_get_cycles();
    229 
    230 syscall_dmsg("\n[DBG] %s : core[%x,%d] created vseg %s in cluster %x / cycle %d\n"
    231 "      base = %x / length = %x / cost = %d\n",
    232 __FUNCTION__, local_cxy , this->core->lid , vseg_type_str(vseg->type) ,
    233 vseg->cxy , (uint32_t)tm_start , vseg->min , length , (uint32_t)(tm_end - tm_start) );
     266    hal_fence();
     267
     268#if CONFIG_DEBUG_SYS_MMAP
     269tm_end = hal_get_cycles();
     270if ( CONFIG_DEBUG_SYS_MMAP < tm_start )
     271printk("\n[DBG] %s : thread %x enter / process %x / cycle %d\n"
     272"vseg %s / cluster %x / base %x / size %x / cost %d\n",
     273__FUNCTION__, this, process->pid, (uint32_t)tm_end,
     274vseg_type_str(vseg->type), vseg->cxy, vseg->min, length, (uint32_t)(tm_end - tm_start) );
     275#endif
    234276
    235277        return 0;
Note: See TracChangeset for help on using the changeset viewer.