Ignore:
Timestamp:
May 3, 2018, 5:51:22 PM (6 years ago)
Author:
alain
Message:

1/ Fix a bug in the Multithreaded "sort" applicationr:
The pthread_create() arguments must be declared as global variables.
2/ The exit syscall can be called by any thread of a process..

File:
1 edited

Legend:

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

    r23 r440  
    22 * sys_sem.c - Acces a POSIX unamed semaphore.
    33 *
    4  * Authors     Alain Greiner (2016,2017)
     4 * Authors     Alain Greiner (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    3636             uint32_t     * value )       // pointer on in/out argument
    3737{
    38         uint32_t             data;   
    39         paddr_t              paddr;
    40     error_t              error;
     38        uint32_t         data;   
     39        vseg_t         * vseg;
     40    error_t          error;
    4141
    42     thread_t           * this = CURRENT_THREAD;
     42    thread_t       * this    = CURRENT_THREAD;
     43    process_t      * process = this->process;
    4344
    4445    // check vaddr in user vspace
    45         error = vmm_v2p_translate( false , vaddr , &paddr );
     46        error = vmm_get_vseg( process , (intptr_t)vaddr , &vseg );
    4647        if( error )
    4748    {
    48         printk("\n[ERROR] in %s : illegal semaphore virtual address = %x\n",
    49                __FUNCTION__ , (intptr_t)vaddr );
    50         this->errno = error;
     49
     50#if DEBUG_SYSCALLS_ERROR
     51printk("\n[ERROR] in %s : unmapped semaphore %x / thread %x / process %x\n",
     52__FUNCTION__ , (intptr_t)vaddr, this->trdid, process->pid );
     53vmm_display( process , false );
     54#endif
     55        this->errno = EINVAL;
    5156        return -1;
    5257    }
    5358
    5459    // check value in user vspace
    55         error = vmm_v2p_translate( false , value , &paddr );
     60        error = vmm_get_vseg( process , (intptr_t)value , &vseg );
    5661        if( error )
    5762    {
    58         printk("\n[ERROR] in %s : illegal argument virtual address = %x\n",
    59                __FUNCTION__ , (intptr_t)value );
    60         this->errno = error;
    61         return -1;   
     63
     64#if DEBUG_SYSCALLS_ERROR
     65printk("\n[ERROR] in %s : unmapped value %x / thread %x / process %x\n",
     66__FUNCTION__ , (intptr_t)vaddr, this->trdid, process->pid );
     67vmm_display( process , false );
     68#endif
     69        this->errno = EINVAL;
     70        return -1;
    6271    }
    63    
     72
    6473    // execute requested operation
    6574        switch( operation )
     
    91100            if( sem_xp == XPTR_NULL )     // user error
    92101            {
    93                 printk("\n[ERROR] in %s : semaphore %x not registered\n",
    94                        __FUNCTION__ , (intptr_t)value );
     102
     103#if DEBUG_SYSCALLS_ERROR
     104printk("\n[ERROR] in %s : semaphore %x not registered / thread %x / process %x\n",
     105__FUNCTION__ , (intptr_t)value, this->trdid, process->pid );
     106#endif
    95107                this->errno = EINVAL;
    96108                return -1;
     
    114126            if( sem_xp == XPTR_NULL )     // user error
    115127            {
    116                 printk("\n[ERROR] in %s : semaphore %x not registered\n",
    117                        __FUNCTION__ , (intptr_t)value );
     128
     129#if DEBUG_SYSCALLS_ERROR
     130printk("\n[ERROR] in %s : semaphore %x not registered / thread %x / process %x\n",
     131__FUNCTION__ , (intptr_t)value, this->trdid, process->pid );
     132#endif
    118133                this->errno = EINVAL;
    119134                return -1;
     
    134149            if( sem_xp == XPTR_NULL )     // user error
    135150            {
    136                 printk("\n[ERROR] in %s : semaphore %x not registered\n",
    137                        __FUNCTION__ , (intptr_t)value );
     151
     152#if DEBUG_SYSCALLS_ERROR
     153printk("\n[ERROR] in %s : semaphore %x not registered / thread %x / process %x\n",
     154__FUNCTION__ , (intptr_t)value, this->trdid, process->pid );
     155#endif
    138156                this->errno = EINVAL;
    139157                return -1;
     
    154172            if( sem_xp == XPTR_NULL )     // user error
    155173            {
    156                 printk("\n[ERROR] in %s : semaphore %x not registered\n",
    157                        __FUNCTION__ , (intptr_t)value );
     174
     175#if DEBUG_SYSCALLS_ERROR
     176printk("\n[ERROR] in %s : semaphore %x not registered / thread %x / process %x\n",
     177__FUNCTION__ , (intptr_t)value, this->trdid, process->pid );
     178#endif
    158179                this->errno = EINVAL;
    159180                return -1;
Note: See TracChangeset for help on using the changeset viewer.